{"commit":"4cc0a9fdd03719a8ce63f8db30199c3dd894f806","subject":"Start implementing task5","message":"Start implementing task5\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task3.clp","new_file":"ssu-ai-level-2\/chapter5\/task3.clp","new_contents":"(defrule fact\n =>\n (printout t \"n=\")\n (bind ?n (read))\n (bind ?r 1)\n (loop-for-count (?i 2 ?n) do\n \t(bind ?r (* ?r ?i))\n )\n (printout t \"fact is:\")\n (printout t ?r)\n (printout t \"\")\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task3.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"b67dbd4f5b4f729c40783c2a0b20941c4b8a388b","subject":"Added some helper functions for color handling","message":"Added some helper functions for color handling\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery\/color.clp","new_file":"lib\/chicanery\/color.clp","new_contents":"; \/lib\/chicanery\/color.clp - Routines for handling chicanery color features\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb2cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/chicanery\/color.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"229d2301c03187aafbae18ce0f6360d54021232d","subject":"Added a short description of what LLVMConstant.clp contains","message":"Added a short description of what LLVMConstant.clp contains\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/LLVMConstant.clp","new_file":"modules\/llvm\/LLVMConstant.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMConstant.clp - Contains classes that represent the different LLVM\n; constant types\n;------------------------------------------------------------------------------\n(defclass llvm::Constant \n (is-a LLVMUser)\n (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))\n (slot RelocationInfo (type SYMBOL) (default nil) \n\t\t (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))\n;------------------------------------------------------------------------------\n(defclass llvm::BlockAddress \n (is-a Constant)\n (slot TargetBlock (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantAggregateZero \n (is-a Constant)\n (slot Element (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantArray \n (is-a Constant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataSequential \n (is-a Constant)\n (multislot Elements)\n (slot ElementType (type SYMBOL))\n (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))\n (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))\n (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataArray \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataVector \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantExpression \n (is-a Constant)\n (slot Operation)\n (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot Opcode (type NUMBER) (range 0 ?VARIABLE))\n (slot Predicate (type NUMBER) (range 0 ?VARIABLE))\n (multislot Indices)\n (slot OpcodeName (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::BinaryConstantExpression \n (is-a ConstantExpression))\n;------------------------------------------------------------------------------\n(defclass llvm::CompareConstantExpression \n (is-a ConstantExpression)\n (slot Predicate (type NUMBER)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantFloatingPoint \n (is-a Constant)\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Value (type FLOAT)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantInteger \n (is-a Constant)\n (slot ZeroExtendedValue (type NUMBER))\n (slot SignExtendedValue (type NUMBER))\n (slot Width (type NUMBER) (range 0 ?VARIABLE))\n (slot Value (type SYMBOL NUMBER))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::PointerConstant \n (is-a Constant)\n (slot PointerType (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantPointerNull \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantStruct \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantVector \n (is-a PointerConstant)\n (slot SplatValue (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalValue \n (is-a Constant)\n (slot Alignment (type NUMBER))\n (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Section (type SYMBOL))\n (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAvailableExternallyLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))\n (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Initializer))\n\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalVariable \n (is-a GlobalValue)\n (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalAlias \n (is-a GlobalValue)\n (slot Aliasee))\n\n;------------------------------------------------------------------------------\n(defclass llvm::UndefValue \n (is-a Constant))\n\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass llvm::Constant \n (is-a LLVMUser)\n (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))\n (slot RelocationInfo (type SYMBOL) (default nil) \n\t\t (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))\n;------------------------------------------------------------------------------\n(defclass llvm::BlockAddress \n (is-a Constant)\n (slot TargetBlock (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantAggregateZero \n (is-a Constant)\n (slot Element (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantArray \n (is-a Constant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataSequential \n (is-a Constant)\n (multislot Elements)\n (slot ElementType (type SYMBOL))\n (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))\n (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))\n (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataArray \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataVector \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantExpression \n (is-a Constant)\n (slot Operation)\n (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot Opcode (type NUMBER) (range 0 ?VARIABLE))\n (slot Predicate (type NUMBER) (range 0 ?VARIABLE))\n (multislot Indices)\n (slot OpcodeName (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::BinaryConstantExpression \n (is-a ConstantExpression))\n;------------------------------------------------------------------------------\n(defclass llvm::CompareConstantExpression \n (is-a ConstantExpression)\n (slot Predicate (type NUMBER)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantFloatingPoint \n (is-a Constant)\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Value (type FLOAT)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantInteger \n (is-a Constant)\n (slot ZeroExtendedValue (type NUMBER))\n (slot SignExtendedValue (type NUMBER))\n (slot Width (type NUMBER) (range 0 ?VARIABLE))\n (slot Value (type SYMBOL NUMBER))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::PointerConstant \n (is-a Constant)\n (slot PointerType (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantPointerNull \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantStruct \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantVector \n (is-a PointerConstant)\n (slot SplatValue (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalValue \n (is-a Constant)\n (slot Alignment (type NUMBER))\n (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Section (type SYMBOL))\n (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAvailableExternallyLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))\n (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Initializer))\n\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalVariable \n (is-a GlobalValue)\n (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalAlias \n (is-a GlobalValue)\n (slot Aliasee))\n\n;------------------------------------------------------------------------------\n(defclass llvm::UndefValue \n (is-a Constant))\n\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3fff8ce11486bd1c85478e581ca7fed4814a1e8e","subject":"Recomendations Works So Flawless, Much Intense","message":"Recomendations Works So Flawless, Much Intense\n","repos":"yzaguirre\/P1IA","old_file":"src\/run.clp","new_file":"src\/run.clp","new_contents":"(deftemplate campeon\n\t(slot nombre (type STRING))\n (multislot tiene-rols)\n\t(slot salud (type INTEGER))\n\t(slot ataque (type INTEGER))\n\t(slot hechizo (type INTEGER))\n\t(slot dificultad (type INTEGER))\n\t(slot fecha (type STRING))\n\t(slot puntosip (type INTEGER))\n\t(slot puntosrp (type INTEGER))\n\t(slot prioridad (type INTEGER))\n (slot ban (type INTEGER))\n)\n; Aatrox\n(defglobal ?*op1* = 0)\n(defglobal ?*op2* = 0)\n(defglobal ?*op3* = 0)\n(defglobal ?*equipo* = 0)\n(defglobal ?*player* = 0)\n(defglobal ?*candidatos* = 0)\n(defglobal ?*prioridades* = 0)\n;(defrule le-fue-bien\n;\t(salience 187)\n;\t(comolefue 1)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (+ prioridad 1))\n;)\n;(defrule le-fue-mal\n;\t(salience 187)\n;\t(comolefue 0)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (- prioridad 1))\n;)\n;(defrule como-le-fue\n;(declare salience 186)\n;\t(initial-fact)\n;=>\n;\t(printout t \"Le fue bien? si o no: \")\n;\t(assert (comolefue =(readline)))\n;)\n\n;(defrule analisis-ingreso-jugador\n;\t(declare (salience 187))\n;\t?p <- (juega-con ?jA ?campeon)\n;\t(juega-con ?jX ?campeon)\n;=>\n\t;(printout t \"Campeon \" ?campeon \" ya pertenece a jugador \" ?jX)\n;)\n;(defrule ingreso-jugador1a\n;(declare (salience 200))\n\t;(initial-fact)\n;\n\t;(not (juega-con ?* ?*op1*))\n;\n;\t(not (juega-con ?* ?*op2*))\n;\n;\t(not (juega-con ?* ?*op3*))\n;=>\n;\t(printout t \"Jugador 1 equipo azul, estas son tus 3 recomendaciones de campeon: \" crlf)\n;\t()\n\t;(bind ?campeon (readline))\n\t;(assert (juega-con \"1a\" ?campeon))\n;)\n;analisar rol\n;no banneado (ban ?campeon)\n;no elegido (juega-con ?x ?campeon)\n;ordenarlos segun prioridad\n;top 3\n;assert juega-con j1a campeon\n; ORDEN DE ELECCION\n; 1a\n; 1m\n; 2m\n; 2a\n; 3a\n; 3m\n; 4m\n; 4a\n; 5a\n; 5m\n\n;(\n; (4)\n; (Pida su jugador)\n; (5)\n; )\n; -1 - 5\n;(defrule prioridad-gw\n ;(juega-con ?j ?nombre)\n ;?f1 <- (campeon (nombre ?nombre) (gw $?gw))\n ;(juega-con ? $?gw )\n;=>\n ;(modify ?f1 (+ prioridad 1))\n;)\n(defrule ingreso-campeon-fase2\n (declare (salience 199)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)\n=>\n (printout t crlf \"Top 3 Campeones Recomendados:\" crlf)\n (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)\n (bind ?*candidatos* 0) ; limpiar la lista\n (bind ?*prioridades* 0) ; limpiar la lista\n (printout t \"Ingrese nombre del campeon: \")\n (bind ?campeon (readline))\n (assert (juega-con ?jugador ?equipo ?campeon))\n (assert (ban ?campeon)) ; ya no se podra elegir\n (printout t crlf)\n)\n(defrule ingreso-campeon\n (declare (salience 200)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)\n (puede-con ?pos $?rols)\n\n (campeon \n (nombre ?campeon\n ;&:(not (member ?campeon $?*bans*))\n ;&:()\n )\n (tiene-rols ?r1 ?r2\n &:(or (member ?r1 $?rols)(member ?r2 $?rols))\n )\n (prioridad ?prioridad)\n (ban 0)\n )\n ;(juega-con ? ?&~?nombre)\n=>\n (if (integerp ?*candidatos*)\n then\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n (bind ?*candidatos* (delete$ ?*candidatos* 1 1))\n (bind ?*prioridades* (delete$ ?*prioridades* 1 1))\n ;(printout t \"ELIMINANDO\" crlf)\n else ; ingrese ordenado segun prioridad\n (bind ?length (length$ ?*candidatos*))\n (bind ?nswapped True)\n (loop-for-count (?x 1 ?length)\n (bind ?prioridadLista (nth$ ?x ?*prioridades*))\n (if (>= ?prioridad ?prioridadLista)\n then\n ; make the swap happen :)\n (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))\n (bind ?*prioridades* (insert$ ?*prioridades* ?x ?prioridad))\n (bind ?nswapped False)\n ;(printout t \"ROMPIENDO\" crlf)\n (break)\n )\n )\n (if (eq ?nswapped True)\n then ; anadir al final de la lista\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n )\n )\n ;(printout t crlf \"== \" ?jugador \" == \" ?posicion \" == \" $?rols \" == \" ?r1 \" == \" ?r2 \" == \" ?campeon \" == prioridad \" ?prioridad crlf crlf)\n)\n(defrule ingreso-5m\n (declare (salience 190))\n (jugador 5 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"m\" ?pos))\n ;(assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-5a\n (declare (salience 190))\n (jugador 5 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"a\" ?pos))\n (assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-4a\n (declare (salience 190))\n (jugador 4 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"a\" ?pos))\n (assert (jugador 5 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-4m\n (declare (salience 190))\n (jugador 4 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"m\" ?pos))\n (assert (jugador 4 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-3m\n (declare (salience 190))\n (jugador 3 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"m\" ?pos))\n (assert (jugador 4 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-3a\n (declare (salience 190))\n (jugador 3 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"a\" ?pos))\n (assert (jugador 3 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-2a\n (declare (salience 190))\n (jugador 2 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"a\" ?pos))\n (assert (jugador 3 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-2m\n (declare (salience 190))\n (jugador 2 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"m\" ?pos))\n (assert (jugador 2 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-1m\n (declare (salience 190))\n (jugador 1 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 1 \"m\" ?pos))\n (assert (jugador 2 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-1a\n (declare (salience 190))\n (jugador 1 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert (jugador 1 \"m\")) ; proximo jugador que elije\n (assert(con-posicion 1 \"a\" ?pos))\n)\n(defrule trato-ban\n(declare (salience 201))\n ?b <- (ban ?campeon)\n ?p <- (campeon (nombre ?campeon) (ban 0))\n=>\n (modify ?p (ban 1))\n (retract ?b)\n)\n(defrule ingreso-informacion1\n(declare (salience 201))\n (initial-fact)\n=>\t\n\t(printout t \"Modo Blind-Pick\" crlf)\n\t\n\t;(assert (flag201 1))\n (assert (ban \"Irelia\"))\n (assert (ban \"Janna\"))\n (assert (ban \"Jarvan IV\"))\n (assert (ban \"Jax\"))\n (assert (ban \"Jayce\"))\n (assert (ban \"Jinx\"))\n\n\t(printout t crlf \"Ingrese equipo a pertener, Azul o Morado: \")\n\t(bind ?*equipo* Azul)\n\n\t(printout t crlf \"Ingrese el # de jugador (1 - 6) del equipo \" ?*equipo* \": \")\n\t(bind ?*player* 1)\n\t(printout t crlf)\n (assert (jugador 1 \"a\")) ; proximo jugador que elije\n)\n(defrule inicio\n(declare (salience 202))\n (initial-fact)\n=>\n (load-facts limited_facts.clp)\n\t(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n)","old_contents":"(deftemplate campeon\n\t(slot nombre (type STRING))\n (multislot tiene-rols)\n\t(slot salud (type INTEGER))\n\t(slot ataque (type INTEGER))\n\t(slot hechizo (type INTEGER))\n\t(slot dificultad (type INTEGER))\n\t(slot fecha (type STRING))\n\t(slot puntosip (type INTEGER))\n\t(slot puntosrp (type INTEGER))\n\t(slot prioridad (type INTEGER))\n (slot ban (type INTEGER))\n)\n; Aatrox\n(defglobal ?*op1* = 0)\n(defglobal ?*op2* = 0)\n(defglobal ?*op3* = 0)\n(defglobal ?*equipo* = 0)\n(defglobal ?*player* = 0)\n(defglobal ?*candidatos* = 0)\n(defglobal ?*prioridades* = 0)\n;(defrule le-fue-bien\n;\t(salience 187)\n;\t(comolefue 1)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (+ prioridad 1))\n;)\n;(defrule le-fue-mal\n;\t(salience 187)\n;\t(comolefue 0)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (- prioridad 1))\n;)\n;(defrule como-le-fue\n;(declare salience 186)\n;\t(initial-fact)\n;=>\n;\t(printout t \"Le fue bien? si o no: \")\n;\t(assert (comolefue =(readline)))\n;)\n\n;(defrule analisis-ingreso-jugador\n;\t(declare (salience 187))\n;\t?p <- (juega-con ?jA ?campeon)\n;\t(juega-con ?jX ?campeon)\n;=>\n\t;(printout t \"Campeon \" ?campeon \" ya pertenece a jugador \" ?jX)\n;)\n;(defrule ingreso-jugador1a\n;(declare (salience 200))\n\t;(initial-fact)\n;\n\t;(not (juega-con ?* ?*op1*))\n;\n;\t(not (juega-con ?* ?*op2*))\n;\n;\t(not (juega-con ?* ?*op3*))\n;=>\n;\t(printout t \"Jugador 1 equipo azul, estas son tus 3 recomendaciones de campeon: \" crlf)\n;\t()\n\t;(bind ?campeon (readline))\n\t;(assert (juega-con \"1a\" ?campeon))\n;)\n;analisar rol\n;no banneado (ban ?campeon)\n;no elegido (juega-con ?x ?campeon)\n;ordenarlos segun prioridad\n;top 3\n;assert juega-con j1a campeon\n; ORDEN DE ELECCION\n; 1a\n; 1m\n; 2m\n; 2a\n; 3a\n; 3m\n; 4m\n; 4a\n; 5a\n; 5m\n\n;(\n; (4)\n; (Pida su jugador)\n; (5)\n; )\n; -1 - 5\n;(defrule prioridad-gw\n ;(juega-con ?j ?nombre)\n ;?f1 <- (campeon (nombre ?nombre) (gw $?gw))\n ;(juega-con ? $?gw )\n;=>\n ;(modify ?f1 (+ prioridad 1))\n;)\n(defrule ingreso-campeon-fase2\n (declare (salience 199)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)\n=>\n (printout t crlf \"Top 3 Campeones Recomendados:\" crlf)\n (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)\n (bind ?*candidatos* 0) ; limpiar la lista\n (bind ?*prioridades* 0) ; limpiar la lista\n (printout t \"Ingrese nombre del campeon: \")\n (bind ?campeon (readline))\n (assert (juega-con ?jugador ?equipo ?campeon))\n (printout t crlf)\n)\n(defrule ingreso-campeon\n (declare (salience 200)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)\n (puede-con ?pos $?rols)\n\n (campeon \n (nombre ?campeon\n ;&:(not (member ?campeon $?*bans*))\n ;&:()\n )\n (tiene-rols ?r1 ?r2\n &:(or (member ?r1 $?rols)(member ?r2 $?rols))\n )\n (prioridad ?prioridad)\n (ban 0)\n )\n ;(juega-con ? ?&~?nombre)\n=>\n (if (integerp ?*candidatos*)\n then\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n (bind ?*candidatos* (delete$ ?*candidatos* 1 1))\n (bind ?*prioridades* (delete$ ?*prioridades* 1 1))\n ;(printout t \"ELIMINANDO\" crlf)\n else ; ingrese ordenado segun prioridad\n (bind ?length (length$ ?*candidatos*))\n (bind ?nswapped True)\n (loop-for-count (?x 1 ?length)\n (bind ?prioridadLista (nth$ ?x ?*prioridades*))\n (if (>= ?prioridad ?prioridadLista)\n then\n ; make the swap happen :)\n (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))\n (bind ?*prioridades* (insert$ ?*prioridades* ?x ?prioridad))\n (bind ?nswapped False)\n ;(printout t \"ROMPIENDO\" crlf)\n (break)\n )\n )\n (if (eq ?nswapped True)\n then ; anadir al final de la lista\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n )\n )\n ;(printout t crlf \"== \" ?jugador \" == \" ?posicion \" == \" $?rols \" == \" ?r1 \" == \" ?r2 \" == \" ?campeon \" == prioridad \" ?prioridad crlf crlf)\n)\n(defrule ingreso-5m\n (declare (salience 190))\n (jugador 5 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"m\" ?pos))\n ;(assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-5a\n (declare (salience 190))\n (jugador 5 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"a\" ?pos))\n (assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-4a\n (declare (salience 190))\n (jugador 4 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"a\" ?pos))\n (assert (jugador 5 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-4m\n (declare (salience 190))\n (jugador 4 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"m\" ?pos))\n (assert (jugador 4 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-3m\n (declare (salience 190))\n (jugador 3 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"m\" ?pos))\n (assert (jugador 4 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-3a\n (declare (salience 190))\n (jugador 3 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"a\" ?pos))\n (assert (jugador 3 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-2a\n (declare (salience 190))\n (jugador 2 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"a\" ?pos))\n (assert (jugador 3 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-2m\n (declare (salience 190))\n (jugador 2 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"m\" ?pos))\n (assert (jugador 2 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-1m\n (declare (salience 190))\n (jugador 1 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 1 \"m\" ?pos))\n (assert (jugador 2 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-1a\n (declare (salience 190))\n (jugador 1 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert (jugador 1 \"m\")) ; proximo jugador que elije\n (assert(con-posicion 1 \"a\" ?pos))\n)\n(defrule trato-ban\n(declare (salience 201))\n ?b <- (ban ?campeon)\n ?p <- (campeon (nombre ?campeon) (ban 0))\n=>\n (modify ?p (ban 1))\n (retract ?b)\n)\n(defrule ingreso-informacion1\n(declare (salience 201))\n (initial-fact)\n=>\t\n\t(printout t \"Modo Blind-Pick\" crlf)\n\t\n\t;(assert (flag201 1))\n (assert (ban \"Irelia\"))\n (assert (ban \"Janna\"))\n (assert (ban \"Jarvan IV\"))\n (assert (ban \"Jax\"))\n (assert (ban \"Jayce\"))\n (assert (ban \"Jinx\"))\n\n\t(printout t crlf \"Ingrese equipo a pertener, Azul o Morado: \")\n\t(bind ?*equipo* Azul)\n\n\t(printout t crlf \"Ingrese el # de jugador (1 - 6) del equipo \" ?*equipo* \": \")\n\t(bind ?*player* 1)\n\t(printout t crlf)\n (assert (jugador 1 \"a\")) ; proximo jugador que elije\n)\n(defrule inicio\n(declare (salience 202))\n (initial-fact)\n=>\n (load-facts limited_facts.clp)\n\t(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n)","returncode":0,"stderr":"","license":"mpl-2.0","lang":"CLIPS"} {"commit":"f636a76be5e44be06b9ce049f84cfab72769cf24","subject":"Cleaned up the module definition in rampancy\/ModuleHeader.clp","message":"Cleaned up the module definition in rampancy\/ModuleHeader.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/rampancy\/ModuleHeader.clp","new_file":"lib\/durandal\/modules\/rampancy\/ModuleHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the rampancy module. \n;------------------------------------------------------------------------------\n\n(defmodule rampancy \n (import core ?ALL)\n (import llvm ?ALL)\n (export ?ALL))\n\n(load* \"modules\/rampancy\/CompilerWrappers.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the rampancy module. \n;------------------------------------------------------------------------------\n\n(defmodule rampancy \n (import core defclass ?ALL)\n (import llvm defclass ?ALL)\n (import core deffunction ?ALL)\n (export defclass ?ALL)\n (export deffunction ?ALL))\n\n\n(load* \"modules\/rampancy\/CompilerWrappers.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"131794f83371b1bd7e8358e657bd2c99e9c2bd94","subject":"Fixed a bug in lib\/chicanery\/color.clp","message":"Fixed a bug in lib\/chicanery\/color.clp\n\nThe file should load correctly now.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"lib\/chicanery\/color.clp","new_file":"lib\/chicanery\/color.clp","new_contents":"; \/lib\/chicanery\/color.clp - Routines for handling chicanery color features\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n","old_contents":"; \/lib\/chicanery\/color.clp - Routines for handling chicanery color features\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb2cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"195a86044f6d156754205b4095ff9ece0d3c9b44","subject":"Fixed a bug where the determinant-cleanup module was missing.","message":"Fixed a bug where the determinant-cleanup module was missing.\n\nThis has been fixed.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-determinant-cleanup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront-scheduling)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-determinant\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-determinant-cleanup\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-determinant-cleanup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront-scheduling)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"92d285c1ed7874cce923d5161b8edfd744a128a3","subject":"added waltz test file","message":"added waltz test file\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltzTest.clp","new_file":"clipsfiles\/waltzTest.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n; ;;; #################################################################\n; ;;; Deffunctions\n; ;;;\n; ;;; In the OPS5 version of this program, the following deffunctions\n; ;;; were implemented in C code that needed to be linked with the OPS5\n; ;;; interpreter. Using deffunctions allows the benchmark to be run\n; ;;; without having to recompile and relink CLIPS with the C code used\n; ;;; in the original benchmark. The performance impact of using\n; ;;; deffunctions for this benchmark rather than C code is minimal.\n; ;;; #################################################################\n\n; (defglobal ?*MOD-NUM* = 100)\n\n; ;;; *****\n; ;;; atan2\n; ;;; *****\n\n; (deffunction atan2 (?y ?x)\n; (if (> ?x 0)\n; then\n; (return (atan (\/ ?y ?x))))\n\n; (if (< ?x 0)\n; then\n; (return (- (atan (\/ ?y ?x)) (pi))))\n\n; (if (> ?y 0) then\n; then\n; (return (pi)))\n\n; (if (< ?y 0)\n; then\n; (return (- 0 (pi))))\n\n; (return undefined))\n\n; ;;; *****\n; ;;; get-y\n; ;;; *****\n\n; (deffunction get-y (?val)\n; (mod ?val ?*MOD-NUM*))\n\n; ;;; *****\n; ;;; get-x\n; ;;; *****\n\n; (deffunction get-x (?val)\n; (integer (\/ ?val ?*MOD-NUM*)))\n\n; ;;; *********\n; ;;; get-angle\n; ;;; *********\n\n; (deffunction get-angle (?p1 ?p2)\n; (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n; (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n; (if (= ?delta-x 0)\n; then\n; (if (> ?delta-y 0)\n; \t\t then (return (\/ (pi) 2))\n; \t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n; else\n; (if (= ?delta-y 0)\n; then\n; (if (> ?delta-x 0)\n; then (return 0.0)\n; \t\t else (if (< ?delta-x 0) then return (pi)))\n; else\n; (return (atan2 ?delta-y ?delta-x)))))\n\n; ;;; ***************\n; ;;; inscribed-angle\n; ;;; ***************\n\n; (deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n; \t;; Get the angle between line #1 and the origin and the angle\n; \t;; between line #2 and the origin, and then subtract these values.\n\n; (bind ?angle1 (get-angle ?basepoint ?p1))\n; (bind ?angle2 (get-angle ?basepoint ?p2))\n; (bind ?temp (- ?angle1 ?angle2))\n\n; (if (< ?temp 0)\n; then (bind ?temp (- 0 ?temp)))\n\n; ;; We always want the smaller of the two angles inscribed, so\n; ;; if the answer is greater than 180 degrees, calculate the\n; ;; smaller angle and return it.\n\n; (if (> ?temp (pi))\n; then\n; (bind ?temp (- (* 2 (pi)) ?temp)))\n\n; (if (< ?temp 0)\n; then (return (- 0 ?temp)))\n\n; (return ?temp))\n\n; ;;; ***************\n; ;;; make-3-junction\n; ;;; ***************\n\n; (deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n; (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n; (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n; (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n; (bind ?sum1213 (+ ?angle12 ?angle13))\n; (bind ?sum1223 (+ ?angle12 ?angle23))\n; (bind ?sum1323 (+ ?angle13 ?angle23))\n\n; (if (< ?sum1213 ?sum1223)\n; then\n; (if (< ?sum1213 ?sum1323)\n; then\n; (bind ?sum ?sum1213)\n; (bind ?shaft ?p1)\n; (bind ?barb1 ?p2)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2))\n; else\n; (if (< ?sum1223 ?sum1323)\n; then\n; (bind ?sum ?sum1223)\n; (bind ?shaft ?p2)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2)))\n\n; (bind ?delta (- ?sum (pi)))\n; (if (< ?delta 0)\n; then (bind ?delta (- 0 ?delta)))\n\n; (if (< ?delta 0.001)\n; then (bind ?jtype tee)\n; else\n; (if (> ?sum (pi))\n; then (bind ?jtype fork)\n; else (bind ?jtype arrow)))\n\n; (assert (junction (p1 (integer ?barb1))\n; (p2 (integer ?shaft))\n; (p3 (integer ?barb2))\n; (base_point (integer ?basepoint))\n; (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(set-compiler ecblocksrand)\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(set-compiler pathblocks)\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(set-compiler ecblocksrand)\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(set-compiler pathblocks)\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrules\n(initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n)\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(set-compiler ecblocksrand)\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrules\n(label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n)\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrules\n(label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n)\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrules\n(plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n)\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(set-compiler pathblocks)\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n\n(export-gv \"waltzTest.gv\")\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'clipsfiles\/waltzTest.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"3356035691b3d5982085e0605e20aa3e74e9f581","subject":"Updated menu.clp to use the pointer class","message":"Updated menu.clp to use the pointer class\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery\/menu.clp","new_file":"lib\/chicanery\/menu.clp","new_contents":"; \/lib\/chicanery\/menu.clp - Contains methods and classes to simplify accessing\n; menus\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric defmenu)\n(defgeneric translate-menu-id)\n(defclass Menu\n (is-a Pointer)\n (slot pointer-class \n (source composite)\n (default menu))\n (multislot menu-elements\n (type LEXEME)\n (storage local)\n (access initialize-only)\n (default ?NONE))\n (message-handler show-menu primary))\n\n(defmessage-handler Menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n ($?entries LEXEME))\n (defmenu ?name ?entries))\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n (?entries MULTIFIELD LEXEME))\n (make-instance ?name of Menu\n (pointer (quickmenu ?entries))\n (menu-elements ?entries)))\n\n(defmethod translate-menu-id\n \"If we get -1 back then return the nil symbol\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n nil)\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n","old_contents":"; \/lib\/chicanery\/menu.clp - Contains methods and classes to simplify accessing\n; menus\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric defmenu)\n(defgeneric translate-menu-id)\n(defclass Menu\n (is-a USER)\n (slot pointer \n (type EXTERNAL-ADDRESS)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (multislot menu-elements\n (type LEXEME)\n (storage local)\n (access initialize-only)\n (default ?NONE))\n (message-handler show-menu primary))\n\n(defmessage-handler Menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n ($?entries LEXEME))\n (defmenu ?name ?entries))\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n (?entries MULTIFIELD LEXEME))\n (make-instance ?name of Menu\n (pointer (quickmenu ?entries))\n (menu-elements ?entries)))\n\n(defmethod translate-menu-id\n \"If we get -1 back then return the nil symbol\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n nil)\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"7f856b3a53ddfbb9a432642634f3f6aeefceaf06","subject":"Nuevo menu de cambio de estado","message":"Nuevo menu de cambio de estado\n","repos":"yzaguirre\/P2IA","old_file":"src\/main.clp","new_file":"src\/main.clp","new_contents":"; David Yzaguirre Gonzalez\n; 200819312\n(deftemplate Seleccion\n\t(slot nombre (type STRING))\n\t(slot ata (type INTEGER))\n\t(slot med (type INTEGER))\n\t(slot def (type INTEGER))\n\t(slot ip (type INTEGER))\n)\n(deftemplate Jugador\n\t(slot nombre (type STRING))\n\t(slot Seleccion (type STRING))\n\t(slot Media (type INTEGER))\n\t(slot Dorsal (type INTEGER))\n\n\t(slot centros (type INTEGER)) ; ATAQUE\n\t(slot definicion (type INTEGER)) ; ATAQUE\n\t(slot precision_cabeza (type INTEGER)) ; ATAQUE\n\t(slot pases_cortos (type INTEGER)) ; ATAQUE\n\t(slot voleas (type INTEGER)) ; ATAQUE\n\t(slot regates (type INTEGER)) ; HABILIDAD\n\t(slot efecto (type INTEGER)) ; HABILIDAD\n\t(slot precision_falta (type INTEGER)) ; HABILIDAD\n\t(slot pases_largos (type INTEGER)) ; HABILIDAD\n\t(slot control_balon (type INTEGER)) ; HABILIDAD\n\t(slot aceleracion (type INTEGER)) ; MOVIMIENTO\n\t(slot velocidad_sprint (type INTEGER)) ; MOVIMIENTO\n\t(slot agilidad (type INTEGER)) ; MOVIMIENTO\n\t(slot mreflejos (type INTEGER)) ; MOVIMIENTO\n\t(slot equilibrio (type INTEGER)) ; MOVIMIENTO\n\t(slot potencia_disparo (type INTEGER)) ; POTENCIA\n\t(slot saldo (type INTEGER)) ; POTENCIA\n\t(slot resistencia (type INTEGER)) ; POTENCIA\n\t(slot fuerza (type INTEGER)) ; POTENCIA\n\t(slot disparos_lejanos (type INTEGER)) ; POTENCIA\n\t(slot agresividad (type INTEGER)) ; MENTALIDAD\n\t(slot tactico (type INTEGER)) ; MENTALIDAD\n\t(slot mposicionamiento (type INTEGER)) ; MENTALIDAD\n\t(slot vision (type INTEGER)) ; MENTALIDAD\n\t(slot penaltis (type INTEGER)) ; MENTALIDAD\n\t(slot marcaje (type INTEGER)) ; DEFENSA\n\t(slot entrada (type INTEGER)) ; DEFENSA\n\t(slot entrada_agresiva (type INTEGER)) ; DEFENSA\n\t(slot estirada (type INTEGER)) ; PORTEROS\n\t(slot parada (type INTEGER)) ; PORTEROS\n\t(slot saque_puerta (type INTEGER)) ; PORTEROS\n\t(slot posicionamiento (type INTEGER)) ; PORTEROS\n\t(slot reflejos (type INTEGER)) ; PORTEROS\n)\n(defglobal ?*rival* = \"\")\n(defglobal ?*EstrategiaRival* = \"Defensiva\")\n(defglobal ?*EstrategiaBolivia* = \"Defensiva\")\n(defglobal ?*Defensa* = \"Bien\")\n(defglobal ?*Ataque* = \"Bien\")\n(deftemplate tiene-goles\n\t(slot equipo (type STRING))\n\t(slot goles (type INTEGER))\n)\n(defrule menu-o9\n\t?f <- (menu-oficial 8)\n=>\n\t(retract ?f)\n)\n(defrule menu-o8\n\t?f <- (menu-oficial 7)\n=>\n\t(printout t \"se recomienda\" crlf)\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o7\n\t?f <- (menu-oficial 6)\n=>\n\t(printout t \"Bolivia esta atacando actualmente: \" ?*Ataque* crlf \"La nueva es [Bien|Mal]: \")\n\t(bind ?*Ataque* (readline))\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o6\n\t?f <- (menu-oficial 5)\n=>\n\t(printout t \"Bolivia se esta defendiendo actualmente: \" ?*Defensa* crlf \"La nueva es [Bien|Mal]: \")\n\t(bind ?*Defensa* (readline))\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o5\n\t?f <- (menu-oficial 4)\n=>\n\t(printout t \"Bolivia tiene estrategia actual: \" ?*EstrategiaBolivia* crlf \"La nueva es [Ofensiva|Defensiva]: \")\n\t(bind ?*EstrategiaBolivia* (readline))\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o4\n\t?f <- (menu-oficial 3)\n=>\n\t(printout t ?*rival* \" tiene estrategia actual: \" ?*EstrategiaRival* crlf \"La nueva es [Ofensiva|Defensiva]: \")\n\t(bind ?*EstrategiaRival* (readline))\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o3\n\t?f <- (menu-oficial 2)\n\t?tg <- (tiene-goles (equipo ?r) (goles ?goles))\n\t(test (eq ?r ?*rival*))\n=>\n\t(bind ?g (+ ?goles 1))\n\t(modify ?tg (goles ?g))\n\t(printout t \"Marcador\" ?*rival* \": \" ?g)\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-o2\n\t?f <- (menu-oficial 1)\n\t?tg <- (tiene-goles (equipo \"Bolivia\") (goles ?goles))\n=>\n\t(bind ?g (+ ?goles 1))\n\t(modify ?tg (goles ?g))\n\t(printout t \"Marcador Bolivia: \" ?g)\n\t(retract ?f)\n\t(assert (menu-oficial 0))\n)\n(defrule menu-oficial1\n\t?f <- (menu-oficial 0)\n=>\n\t(printout t crlf crlf \"Opciones de ingreso para estado del partido:\" crlf \"1.) Nuestro Equipo anot\u00f3 gol\" crlf \"2.) Equipo Rival anot\u00f3 gol\" crlf \"3.) Equipo Rival tiene estrategia...\" crlf \"4.) Equipo Bolivia tiene estrategia...\" crlf \"5.) Nuestra defensa cambio para...\" crlf \"6.) Nuestro ataque cambio para...\" crlf \"7.) Solicitar Recomendacion\" crlf \"8.) Salir\" crlf) \n\t(printout t \"Elija opcion [1-7]: \")\n\t(bind ?opcion (read))\n\t(retract ?f)\n\t(assert (menu-oficial ?opcion))\n\t(printout t crlf)\n)\n(defrule seleccion-jugador\n\t(declare (salience 201))\n\t(initial-fact)\n=>\n\t(printout t crlf \"Ingrese dorsal de jugador 1: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 1))\n\t(printout t crlf \"Ingrese dorsal de jugador 2: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 2))\n\t(printout t crlf \"Ingrese dorsal de jugador 3: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 3))\n\t(printout t crlf \"Ingrese dorsal de jugador 4: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 4))\n\t(printout t crlf \"Ingrese dorsal de jugador 5: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 5))\n\t(printout t crlf \"Ingrese dorsal de jugador 6: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 6))\n\t(printout t crlf \"Ingrese dorsal de jugador 7: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 7))\n\t(printout t crlf \"Ingrese dorsal de jugador 8: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 8))\n\t(printout t crlf \"Ingrese dorsal de jugador 9: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 9))\n\t(printout t crlf \"Ingrese dorsal de jugador 10: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 10))\n\t(printout t crlf \"Ingrese dorsal de jugador 11: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 11))\n\t(assert (menu-oficial 0))\n)\n(defrule jugadores\n\t(declare (salience 202))\n\t(initial-fact)\n\t(Jugador (nombre ?nombre) (Media ?media) (Dorsal ?dorsal))\n=>\n\t(printout t ?dorsal \": \" ?nombre \", tiene media \" ?media \".\" crlf)\n)\n(defrule seleccion-rival\n\t(declare (salience 203))\n\t(initial-fact)\n=>\n\t(printout t crlf \"Seleccione Pais Rival: \")\n\t(bind ?*rival* (readline))\n\t(assert (tiene-goles (equipo ?*rival*) (goles 0)))\n\t(assert (tiene-goles (equipo \"Bolivia\") (goles 0)))\n\t;(assert (rival =(readline)))\n\t(printout t crlf \"JUGADORES SELECCION BOLIVIA\" crlf)\n)\n(defrule mostrar-paises\n\t(declare (salience 204))\n\t(initial-fact)\n\t(Seleccion (nombre ?nombre))\n=>\n\t(printout t ?nombre crlf)\n)\n(defrule inicio\n\t(declare (salience 205))\n\t(initial-fact)\n=>\n\t(load-facts main_facts.clp)\n\t;(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n\t(printout t \"Paises: \" crlf)\n)\n","old_contents":"; David Yzaguirre Gonzalez\n; 200819312\n(deftemplate Seleccion\n\t(slot nombre (type STRING))\n\t(slot ata (type INTEGER))\n\t(slot med (type INTEGER))\n\t(slot def (type INTEGER))\n\t(slot ip (type INTEGER))\n)\n(deftemplate Jugador\n\t(slot nombre (type STRING))\n\t(slot Seleccion (type STRING))\n\t(slot Media (type INTEGER))\n\t(slot Dorsal (type INTEGER))\n\n\t(slot centros (type INTEGER)) ; ATAQUE\n\t(slot definicion (type INTEGER)) ; ATAQUE\n\t(slot precision_cabeza (type INTEGER)) ; ATAQUE\n\t(slot pases_cortos (type INTEGER)) ; ATAQUE\n\t(slot voleas (type INTEGER)) ; ATAQUE\n\t(slot regates (type INTEGER)) ; HABILIDAD\n\t(slot efecto (type INTEGER)) ; HABILIDAD\n\t(slot precision_falta (type INTEGER)) ; HABILIDAD\n\t(slot pases_largos (type INTEGER)) ; HABILIDAD\n\t(slot control_balon (type INTEGER)) ; HABILIDAD\n\t(slot aceleracion (type INTEGER)) ; MOVIMIENTO\n\t(slot velocidad_sprint (type INTEGER)) ; MOVIMIENTO\n\t(slot agilidad (type INTEGER)) ; MOVIMIENTO\n\t(slot mreflejos (type INTEGER)) ; MOVIMIENTO\n\t(slot equilibrio (type INTEGER)) ; MOVIMIENTO\n\t(slot potencia_disparo (type INTEGER)) ; POTENCIA\n\t(slot saldo (type INTEGER)) ; POTENCIA\n\t(slot resistencia (type INTEGER)) ; POTENCIA\n\t(slot fuerza (type INTEGER)) ; POTENCIA\n\t(slot disparos_lejanos (type INTEGER)) ; POTENCIA\n\t(slot agresividad (type INTEGER)) ; MENTALIDAD\n\t(slot tactico (type INTEGER)) ; MENTALIDAD\n\t(slot mposicionamiento (type INTEGER)) ; MENTALIDAD\n\t(slot vision (type INTEGER)) ; MENTALIDAD\n\t(slot penaltis (type INTEGER)) ; MENTALIDAD\n\t(slot marcaje (type INTEGER)) ; DEFENSA\n\t(slot entrada (type INTEGER)) ; DEFENSA\n\t(slot entrada_agresiva (type INTEGER)) ; DEFENSA\n\t(slot estirada (type INTEGER)) ; PORTEROS\n\t(slot parada (type INTEGER)) ; PORTEROS\n\t(slot saque_puerta (type INTEGER)) ; PORTEROS\n\t(slot posicionamiento (type INTEGER)) ; PORTEROS\n\t(slot reflejos (type INTEGER)) ; PORTEROS\n)\n(defrule seleccion-jugador\n\t(declare (salience 201))\n\t(initial-fact)\n=>\n\t(printout t crlf \"Ingrese dorsal de jugador 1: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 1))\n\t(printout t crlf \"Ingrese dorsal de jugador 2: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 2))\n\t(printout t crlf \"Ingrese dorsal de jugador 3: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 3))\n\t(printout t crlf \"Ingrese dorsal de jugador 4: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 4))\n\t(printout t crlf \"Ingrese dorsal de jugador 5: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 5))\n\t(printout t crlf \"Ingrese dorsal de jugador 6: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 6))\n\t(printout t crlf \"Ingrese dorsal de jugador 7: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 7))\n\t(printout t crlf \"Ingrese dorsal de jugador 8: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 8))\n\t(printout t crlf \"Ingrese dorsal de jugador 9: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 9))\n\t(printout t crlf \"Ingrese dorsal de jugador 10: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 10))\n\t(printout t crlf \"Ingrese dorsal de jugador 11: \")\n\t(bind ?dorsal (read))\n\t(assert (jugador-en-pos ?dorsal 11))\n)\n(defrule jugadores\n\t(declare (salience 202))\n\t(initial-fact)\n\t(Jugador (nombre ?nombre) (Media ?media) (Dorsal ?dorsal))\n=>\n\t(printout t ?dorsal \": \" ?nombre \", tiene media \" ?media \".\" crlf)\n)\n(defrule seleccion-rival\n\t(declare (salience 203))\n\t(initial-fact)\n=>\n\t(printout t crlf \"Seleccione Pais Rival: \")\n\t(assert (rival =(readline)))\n\t(printout t crlf \"JUGADORES SELECCION BOLIVIA\" crlf)\n)\n(defrule mostrar-paises\n\t(declare (salience 204))\n\t(initial-fact)\n\t(Seleccion (nombre ?nombre))\n=>\n\t(printout t ?nombre crlf)\n)\n(defrule inicio\n\t(declare (salience 205))\n\t(initial-fact)\n=>\n\t(load-facts main_facts.clp)\n\t;(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n\t(printout t \"Paises: \" crlf)\n)\n","returncode":0,"stderr":"","license":"mpl-2.0","lang":"CLIPS"} {"commit":"8300c727ee9ba610127573175ac1e39e26ccde9f","subject":"Updated Init.clp in loop-region-merging to skip loopless functions","message":"Updated Init.clp in loop-region-merging to skip loopless functions\n\nThis is a simple optimization that will cause the loop-region-merging pass to\nskip the current function if it turns out that there are no loops.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/Init.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Contains the defmodules that make up the process of\n; loop-region-merging.\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-build\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-expand\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-claim\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-arbitrate\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-resolve\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-construction\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-population\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-indirect-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-update\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-rename\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-cleanup-merger\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging::modify-pass-description\n\t\t\t\"Modifies the target pass description to load the target subpasses.\n\t\t\tThis will only happen if the current function has loops\"\t\n\t\t\t?fct <- (message (to loop-region-merging) (action initial-fact))\n\t\t\t(exists (object (is-a Loop)))\n\t\t\t?obj <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (passes \n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-build\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-expand\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-claim\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-arbitrate\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-resolve\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-construction\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-population\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-indirect-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-update\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-rename\n\t\t\t\t\t\t\t\t\t loop-region-merging-cleanup-merger\n\t\t\t\t\t\t\t\t\t $?passes)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging::skip-pass\n\t\t\t\"This rule fires if the given function does not have any defined loops!\"\n\t\t\t?fct <- (message (to loop-region-merging) (action initial-fact))\n\t\t\t(not (exists (object (is-a Loop))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Contains the defmodules that make up the process of\n; loop-region-merging.\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-build\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-expand\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-claim\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-arbitrate\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-resolve\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-construction\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-population\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-indirect-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-update\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-rename\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-cleanup-merger\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging::modify-pass-description\n\t\t\t\"Modifies the target pass description to load the target subpasses\"\n\t\t\t?fct <- (message (to loop-region-merging) (action initial-fact))\n\t\t\t?obj <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (passes \n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-build\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-expand\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-claim\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-arbitrate\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-resolve\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-construction\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-population\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-indirect-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-update\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-rename\n\t\t\t\t\t\t\t\t\t loop-region-merging-cleanup-merger\n\t\t\t\t\t\t\t\t\t $?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c1257332a31c033daf733e8950dc4f6e956950d7","subject":"cortex\/parsing\/SymbolDeclarationFunctions.clp: Fixed defsymbol-lexer","message":"cortex\/parsing\/SymbolDeclarationFunctions.clp: Fixed defsymbol-lexer\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"src\/lib\/cortex\/parsing\/SymbolDeclarationFunctions.clp","new_file":"src\/lib\/cortex\/parsing\/SymbolDeclarationFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(deffunction cortex::blank-on-empty-string(?str)\n \"Returns a blank multifield if the given input string is empty\"\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction cortex::split-on-symbol (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction cortex::input-is-target-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(deffunction cortex::defsymbol-lexer\n \"Builds a rule for parsing a given input string for the given symbol\"\n (?module-name ?symbol ?name ?docString)\n (build (format nil \"(defrule %s::%s \n \\\"%s\\\"\n ?fct <- (object (is-a file-line) \n (contents $?b ?s $?a))\n (test (input-is-target-symbol \\\"%s\\\" ?s))\n =>\n (modify-instance ?fct \n (contents $?b \n (split-on-symbol \\\"%s\\\" ?s) \n $?a)))\" \n ?module-name ?name ?docString ?symbol ?symbol)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(deffunction cortex::blank-on-empty-string(?str)\n \"Returns a blank multifield if the given input string is empty\"\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction cortex::split-on-symbol (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction cortex::input-is-target-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(deffunction cortex::defsymbol\n \"Builds a rule for parsing a given input string for the given symbol\"\n (?module-name ?symbol ?name ?docString)\n (build (format nil \"(defrule %s::%s \n \\\"%s\\\"\n ?fct <- (object (is-a file-line) \n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \\\"%s\\\" ?s))\n =>\n (modify-instance ?fct \n (contents $?b \n (break-apart \\\"%s\\\" ?s) \n $?a)))\" \n ?module-name ?name ?docString ?symbol ?symbol)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"ad9236ff72f4fc77ee5977008a60ae65a7ec391f","subject":"Fix minor typo","message":"Fix minor typo","repos":"md5crypt\/clipsgame,md5crypt\/clipsgame","old_file":"levels\/tea.clp","new_file":"levels\/tea.clp","new_contents":"(defrule boston-tea-party\n\t; they dumped the tea into the sea!\n\t?ship <- (ship ?name boston)\n\t?route <- (route london boston)\n\t(cargo ?name tea)\n\t=>\n\t(retract ?ship ?route)\n\t(assert (route hong-kong boston))\n)\n\n(defrule set-sail\n\t?anchor <- (ship ?name ?location)\n\t?command <- (sail ?name ?destination)\n\t(route ?location ?destination)\n\t=>\n\t(retract ?anchor ?command)\n\t(assert (ship ?name ?destination))\n)\n\n(defrule unload-cargo\n\t(ship ?name ?location)\n\t(cargo ?name ?type)\n\t=>\n\t(assert (stock ?location ?type))\n)\n\n(defrule load-cargo\n\t(ship ?name ?location)\n\t(stock ?location ?type)\n\t=>\n\t(assert (cargo ?name ?type))\n)\n\n(defrule opium-war\n\t; because East India Company was evil\n\t(stock hong-kong opium)\n\t?route <- (route hong-kong ?)\n\t=>\n\t(retract ?route)\n)\n\n(deffacts initial-facts\n\t(ship flying-cloud london)\n\t(ship hornet london)\n\t(ship sea-witch hong-kong)\n\t(route boston hong-kong)\n\t(route boston london)\n\t(route london boston)\n\t(route london hong-kong)\n\t(route hong-kong london)\n\t(stock hong-kong tea)\n\t(stock london opium)\n\t(stock boston cotton)\n)\n","old_contents":"(defrule boston-tea-party\n\t; they dumped the tea into the sea!\n\t?ship <- (ship ?name boston)\n\t?route <- (route london boston)\n\t(cargo ?name tea)\n\t=>\n\t(retract ?ship ?route)\n\t(assert (route hong-kong boston))\n)\n\n(defrule set-sail\n\t?anchor <- (ship ?name ?location)\n\t?command <- (sail ?name ?destenation)\n\t(route ?location ?destenation)\n\t=>\n\t(retract ?anchor ?command)\n\t(assert (ship ?name ?destenation))\n)\n\n(defrule unload-cargo\n\t(ship ?name ?location)\n\t(cargo ?name ?type)\n\t=>\n\t(assert (stock ?location ?type))\n)\n\n(defrule load-cargo\n\t(ship ?name ?location)\n\t(stock ?location ?type)\n\t=>\n\t(assert (cargo ?name ?type))\n)\n\n(defrule opium-war\n\t; because East India Company was evil\n\t(stock hong-kong opium)\n\t?route <- (route hong-kong ?)\n\t=>\n\t(retract ?route)\n)\n\n(deffacts initial-facts\n\t(ship flying-cloud london)\n\t(ship hornet london)\n\t(ship sea-witch hong-kong)\n\t(route boston hong-kong)\n\t(route boston london)\n\t(route london boston)\n\t(route london hong-kong)\n\t(route hong-kong london)\n\t(stock hong-kong tea)\n\t(stock london opium)\n\t(stock boston cotton)\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"e482eb96213caa5909c086741811a81fdf78f3bb","subject":"Exposed the List class in the module definition","message":"Exposed the List class in the module definition\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/ModuleHeader.clp","new_file":"modules\/core\/ModuleHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the core module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n(defmodule core \n ; Modify this export to add more classes\n ; Just remember that these three classes are pretty critical to the rest of\n ; the optimization\n (export defclass Object InteropObject Hint List)\n ; Modify this export to add more functions to be exposed\n ; I would advise against removing these functions\n (export deffunction superset equal$ has-common-element disjoint) \n\n(load* \"modules\/core\/Object.clp\")\n(load* \"modules\/core\/InteropObject.clp\")\n(load* \"modules\/core\/Hint.clp\")\n(load* \"modules\/core\/List.clp\")\n; Add more defclasses here\n; The programmer is responsible for ordering the load statements so that\n; class dependencies are met\n(load* \"modules\/core\/SetExtensions.clp\")\n; Add more deffunctions here\n; The programmer is responsible for ordering the load statements so that\n; function dependencies are met\n\n\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the core module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n(defmodule core \n ; Modify this export to add more classes\n ; Just remember that these three classes are pretty critical to the rest of\n ; the optimization\n (export defclass Object InteropObject Hint)\n ; Modify this export to add more functions to be exposed\n ; I would advise against removing these functions\n (export deffunction superset equal$ has-common-element disjoint) \n\n(load* \"modules\/core\/Object.clp\")\n(load* \"modules\/core\/InteropObject.clp\")\n(load* \"modules\/core\/Hint.clp\")\n; Add more defclasses here\n; The programmer is responsible for ordering the load statements so that\n; class dependencies are met\n(load* \"modules\/core\/SetExtensions.clp\")\n; Add more deffunctions here\n; The programmer is responsible for ordering the load statements so that\n; function dependencies are met\n\n\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9bff3a99488ef265eea3593dcad14d38f6ac0a5b","subject":"marc noob","message":"marc noob\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","old_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?e get-edad+maxima) (send ?e get-edad+maxima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"88367ee3d40b09a0a0ea71647177eff3a4b3e50a","subject":"and we are done","message":"and we are done\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-altura ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","old_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-altura ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona Persona:objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"cf301a8ae68c2ac58789b4bcc962398a5f40cd8f","subject":"nothing really","message":"nothing really\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\n)\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"f2bc56f7d4848168e95f62efa5d8611955e1e6f8","subject":"Added a doc string to InteropObject.clp","message":"Added a doc string to InteropObject.clp\n","repos":"DrItanium\/LibExpertSystem,DrItanium\/LibExpertSystem","old_file":"clips\/Types\/InteropObject.clp","new_file":"clips\/Types\/InteropObject.clp","new_contents":"; An InteropObject stores a pointer to a type outside CLIPS\n\n(defclass InteropObject \n \"The class that allows CLIPS to interact with LLVM. Well that was what it was\n designed for. However this class can be used to allow objects outside CLIPS to\n be modified by request within CLIPS. It is up to the programmer to provide\n functions to act on these pointers though.\"\n (is-a USER)\n (slot Pointer (visibility public) (type NUMBER)))\n\n","old_contents":"; An InteropObject stores a pointer to a type outside CLIPS\n\n(defclass InteropObject (is-a USER)\n (slot Pointer (visibility public) (type NUMBER)))\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d9be2ab9d5f4de57bca758271da28c866cb9becc","subject":"Rewrote the merge rules for producers and consumers to reduce activations","message":"Rewrote the merge rules for producers and consumers to reduce activations\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-consumer-list\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-consume-list)\n\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-producer-list\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-produce-list)\n\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-consumer-list\n (declare (salience 1))\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-producer-list\n (declare (salience 1))\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consumes)\n;\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consumes)\n;\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (action instruction-consume-list)\n;\t\t\t\t\t (arguments ?id => ?a ?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produces)\n;\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produces)\n;\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (action instruction-produce-list)\n;\t\t\t\t\t (arguments ?id => ?a ?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consume-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consume-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n;\t\t\t(test (neq ?f0 ?f1))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produce-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produce-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n;\t\t\t(test (neq ?f0 ?f1))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n;\t\t\t(declare (salience -2))\n;\t\t\t?f <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t(action instruction-consumes)\n;\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n;\t\t\t=>\n;\t\t\t(modify ?f (action instruction-consume-list)\n;\t\t\t\t\t (arguments ?b => ?a)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n;\t\t\t(declare (salience -2))\n;\t\t\t?f <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t(action instruction-produces)\n;\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n;\t\t\t=>\n;\t\t\t(modify ?f (action instruction-produce-list)\n;\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-consume-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-produce-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-consumes)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-consume-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-produces)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-produce-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9db32a7a9e8e63ae855145277f29200f6f772033","subject":"Fixed name issues in WavefrontAdvancement.clp","message":"Fixed name issues in WavefrontAdvancement.clp\n\nI fixed the calls to get-Contents and the Contents slot insert to be values\ninstead.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (values $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (values $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave values ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?rest))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-values)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (modify-instance ?wave (DeleteNodes $?rest))\n (if ?ind then (slot-delete$ ?wave values ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => $?npe)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-Match\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => ?next $?rest))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (values $?contents))\n =>\n (modify ?fct (arguments ?id => $?rest))\n (if (not (member$ ?next $?contents)) then\n (modify-instance ?wave (contents $?contents ?next))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-NoMoreElements\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:values) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (values $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (values $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?rest))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (modify-instance ?wave (DeleteNodes $?rest))\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => $?npe)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-Match\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => ?next $?rest))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (values $?contents))\n =>\n (modify ?fct (arguments ?id => $?rest))\n (if (not (member$ ?next $?contents)) then\n (modify-instance ?wave (contents $?contents ?next))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-NoMoreElements\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:values) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"bd54c92436691961aceeed35097997d552eb1c5c","subject":"Added RunConverter.clp","message":"Added RunConverter.clp\n\nIt is a file that runs the GLConstantConversion expert system on\n\/usr\/include\/GL\/gl.h\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/RunConverter.clp","new_file":"src\/tools\/conv\/gl\/RunConverter.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunConverter.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n(batch* GLConstantConversion.clp)\n(reset)\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\"))\n(run)\n(exit)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/tools\/conv\/gl\/RunConverter.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"62e14fb550287899bf5ce3e990cd6f5e830f9833","subject":"Fixed a bug in the FinishSchedulingIntoBlock rule","message":"Fixed a bug in the FinishSchedulingIntoBlock rule\n\nI was calling get-Contents on a wavefront object which does not have a contents\nmultifield anymore\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3f4cc7fc2088f762a4e44a7faddaa9e9e48cdc69","subject":"Added a rule to strip out blank lines","message":"Added a rule to strip out blank lines\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-blank-lines\n ?f <- (file-line (contents))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"a60fe78839738614b71891aaa070efe7672684ab","subject":"Fixed errors in LoopRegionMerging.clp","message":"Fixed errors in LoopRegionMerging.clp\n\nThese errors include:\n1) Needing to replace Contents with contents due to changes in slot names\n2) Updating module names to use merging instead of building\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n\t\t\t\"Creates a flat representation of the contents of the given region\"\n\t\t\t(object (is-a Region) (id ?id) (contents $?z))\n\t\t\t(not (exists (object (is-a FlatList) (parent ?id))))\n\t\t\t=>\n\t\t\t(make-instance of FlatList (parent ?id)) \n\t\t\t(assert (Populate FlatList of ?id with $?z)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a BasicBlock) (id ?first))\n\t\t\t=>\n\t\t\t(slot-insert$ ?o contents 1 ?first)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a Region) (id ?first))\n\t\t\t(object (is-a FlatList) (parent ?first) (id ?name))\n\t\t\t=>\n\t\t\t;Add the reference to FlatList for the time being until we have\n\t\t\t;finished constructing an entire flat list\n\t\t\t(slot-insert$ ?o contents 1 ?name)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n\t\t\t?f <- (Populate FlatList of ? with)\n\t\t\t=>\n\t\t\t(retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n\t\t\t\"Takes a flat list and expands one of the elements of the contents if \n\t\t\tit turns out that element is another flat list\"\n\t\t\t?id <- (object (is-a FlatList) (contents $?a ?b $?c))\n\t\t\t(object (is-a FlatList) (id ?b) (contents $?j))\n\t\t\t=>\n\t\t\t(modify-instance ?id (contents $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n\t\t\t\"Asserts that a region owns another through a subset check. The first \n\t\t\tflat list is checked to see if it is a _proper_ subset of the second\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (contents $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (contents $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (> (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (claim ?p1 owns ?p0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n\t\t\t\"This rule is used to assert ownership claims on basic blocks\"\n\t\t\t?f0 <- (object (is-a FlatList) (parent ?p) (contents $? ?b $?))\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t=>\n\t\t\t(assert (claim ?p owns ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n\t\t\t\"Asserts that two regions are equivalent if one flat list contains the\n\t\t\tsame elements as a second one.\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (contents $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (contents $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (= (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (claim ?p1 equivalent ?p0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n\t\t\t\"It is possible for two facts of equivalence to actually be the same \n\t\t\tfact\"\n\t\t\t(declare (salience -1))\n\t\t\t?f0 <- (claim ?a equivalent ?b)\n\t\t\t?f1 <- (claim ?b equivalent ?a)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?a equivalent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region \n\t\t\tdies. The loop is the first entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (claim ?a equivalent ?b)\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (delete region ?b)\n\t\t\t\t\t (replace ?b with ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region\n\t\t\tdies. The loop is the second entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (claim ?b equivalent ?a)\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (delete region ?b)\n\t\t\t\t\t (replace ?b with ?a)))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n\t\t\t\"We target claims of ownership that deal with a given region that has \n\t\t\tto be replaced by another due to equivalence\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t?f1 <- (claim ?old owns ?other)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?new owns ?other)\n\t\t\t\t\t (replace ?old with ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t?f1 <- (claim ?other owns ?old)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?other owns ?new)\n\t\t\t\t\t (replace ?old with ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n\t\t\t\"Retract replacement facts because there are no more claims to worry \n\t\t\tabout\"\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t=>\n\t\t\t(retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::DeleteTargetRegion\n\t\t\t\"Deletes the target region slated for deletion\"\n\t\t\t?f0 <- (delete region ?r0)\n\t\t\t?region <- (object (is-a Region) (id ?r0))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::DeleteFlatLists \n\t\t\t\"Deletes all of the flat lists in a single rule fire\"\n\t\t\t=>\n\t\t\t(progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n\t\t\t\t\t (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n\t\t\t\"Creates a flat representation of the contents of the given region\"\n\t\t\t(object (is-a Region) (id ?id) (Contents $?z))\n\t\t\t(not (exists (object (is-a FlatList) (parent ?id))))\n\t\t\t=>\n\t\t\t(make-instance of FlatList (parent ?id)) \n\t\t\t(assert (Populate FlatList of ?id with $?z)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a BasicBlock) (id ?first))\n\t\t\t=>\n\t\t\t(slot-insert$ ?o Contents 1 ?first)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a Region) (id ?first))\n\t\t\t(object (is-a FlatList) (parent ?first) (id ?name))\n\t\t\t=>\n\t\t\t;Add the reference to FlatList for the time being until we have\n\t\t\t;finished constructing an entire flat list\n\t\t\t(slot-insert$ ?o Contents 1 ?name)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n\t\t\t?f <- (Populate FlatList of ? with)\n\t\t\t=>\n\t\t\t(retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n\t\t\t\"Takes a flat list and expands one of the elements of the contents if \n\t\t\tit turns out that element is another flat list\"\n\t\t\t?id <- (object (is-a FlatList) (Contents $?a ?b $?c))\n\t\t\t(object (is-a FlatList) (id ?b) (Contents $?j))\n\t\t\t=>\n\t\t\t(modify-instance ?id (Contents $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n\t\t\t\"Asserts that a region owns another through a subset check. The first \n\t\t\tflat list is checked to see if it is a _proper_ subset of the second\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (Contents $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (Contents $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (> (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (claim ?p1 owns ?p0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n\t\t\t\"This rule is used to assert ownership claims on basic blocks\"\n\t\t\t?f0 <- (object (is-a FlatList) (parent ?p) (Contents $? ?b $?))\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t=>\n\t\t\t(assert (claim ?p owns ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n\t\t\t\"Asserts that two regions are equivalent if one flat list contains the\n\t\t\tsame elements as a second one.\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (Contents $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (Contents $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (= (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (claim ?p1 equivalent ?p0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n\t\t\t\"It is possible for two facts of equivalence to actually be the same \n\t\t\tfact\"\n\t\t\t(declare (salience -1))\n\t\t\t?f0 <- (claim ?a equivalent ?b)\n\t\t\t?f1 <- (claim ?b equivalent ?a)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?a equivalent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region \n\t\t\tdies. The loop is the first entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (claim ?a equivalent ?b)\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (delete region ?b)\n\t\t\t\t\t (replace ?b with ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region\n\t\t\tdies. The loop is the second entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (claim ?b equivalent ?a)\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (delete region ?b)\n\t\t\t\t\t (replace ?b with ?a)))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-building-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n\t\t\t\"We target claims of ownership that deal with a given region that has \n\t\t\tto be replaced by another due to equivalence\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t?f1 <- (claim ?old owns ?other)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?new owns ?other)\n\t\t\t\t\t (replace ?old with ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-building-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t?f1 <- (claim ?other owns ?old)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (claim ?other owns ?new)\n\t\t\t\t\t (replace ?old with ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-building-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n\t\t\t\"Retract replacement facts because there are no more claims to worry \n\t\t\tabout\"\n\t\t\t?f0 <- (replace ?old with ?new)\n\t\t\t=>\n\t\t\t(retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-building-flatlist-resolve::DeleteTargetRegion\n\t\t\t\"Deletes the target region slated for deletion\"\n\t\t\t?f0 <- (delete region ?r0)\n\t\t\t?region <- (object (is-a Region) (id ?r0))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-building-cleanup-merger::DeleteFlatLists \n\t\t\t\"Deletes all of the flat lists in a single rule fire\"\n\t\t\t=>\n\t\t\t(progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n\t\t\t\t\t (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9da22c734e2d662ff1750e4f701e8eb6fc8fcfcb","subject":"Added the ProducersPropagation logic to the dependency-analysis pass","message":"Added the ProducersPropagation logic to the dependency-analysis pass\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/ProducersPropagation.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/ProducersPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateBlockProducers\n\t\t\t(object (is-a BasicBlock) (id ?b) (parent ?r) \n\t\t\t\t\t (Produces $?produces))\n\t\t\t=>\n\t\t\t(assert (Give ?r from ?b the following produced items $?produces)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentExists\n\t\t\t?fct <- (Give ?r from ? the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(exists (object (is-a Region) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Give ?p from ?r the following produced items $?produced))\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentDoesntExist\n\t\t\t?fct <- (Give ?r from ? the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(not (exists (object (is-a Region) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::IdentifyNonLocalDependencies\n\t\t\t?i0 <- (object (is-a Instruction) (parent ?p) (id ?t0) \n\t\t\t\t\t\t\t\t(Operands $? ?op $?))\n\t\t\t(object (is-a ParentedObject) (id ?op) (parent ~?p))\n\t\t\t;(test (not (member$ ?op (send ?i0 get-NonLocalDependencies))))\n\t\t\t=>\n\t\t\t;since we don't copy the set of producers at the start anymore we\n\t\t\t;need this operation as well\n\t\t\t(slot-insert$ ?i0 Producers 1 ?op)\n\t\t\t(slot-insert$ ?i0 NonLocalDependencies 1 ?op))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/passes\/dependency-analysis\/ProducersPropagation.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"b98077e916b2227fb408521788057cd2e4b91ef5","subject":"Added the Library entry point for the widget library","message":"Added the Library entry point for the widget library\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/lib\/widget\/Library.clp","new_file":"src\/lib\/widget\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/lib\/widget\/Library.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"aaa9d2739d27e5b08c6735331a2413a9f82ad917","subject":"Fixed bugs in lib\/chicanery.clp","message":"Fixed bugs in lib\/chicanery.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery.clp","new_file":"lib\/chicanery.clp","new_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?mask INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?mask)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (create-accessor read))\n (multislot buttons \n (create-accessor read))\n (slot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler mouse clear primary\n ()\n (bind ?self:position (create$))\n (bind ?self:buttons (create$))\n (bind ?self:timestamp 0))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons (translate\/mouse\/buttons))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (slot-direct-delete$ keys 1 ?self:length)\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:length 1)\n ?key)\n (bind ?self:length (+ ?self:length 1))\n else\n (bind ?self:keys ?key)\n (bind ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-entries))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n(defmethod translate-menu-id\n \"Handles the case when -1 is passed\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n (return NIL))\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n; system initialization features\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n; on-resized handling\n\n(defgeneric on-resized)\n\n(defrule on-resized\n \"library defined rule which calls the on-resized method\"\n (declare (salience 10000))\n ?f <- (event resized new ?value)\n =>\n (retract ?f)\n (on-resized ?value))\n\n","old_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (type INTEGER)\n (create-accessor read))\n (multislot buttons \n (type SYMBOL)\n (create-accessor read))\n (multislot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler query primary))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons\n (translate\/mouse\/buttons (mouse\/buttons)))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (bind ?self:keys (create$))\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:index 1)\n ?key)\n else\n (bind ?self:keys (create$ ?key)))\n (bind ?self:length (+ ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"830a0f99c2cbf3e44195fdb8d99aa8120694d4c3","subject":"Fixed bugs in WavefrontAdvancement.clp","message":"Fixed bugs in WavefrontAdvancement.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (values $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (values $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?rest))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (modify-instance ?wave (DeleteNodes $?rest))\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => $?npe)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-Match\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => ?next $?rest))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (values $?contents))\n =>\n (modify ?fct (arguments ?id => $?rest))\n (if (not (member$ ?next $?contents)) then\n (modify-instance ?wave (contents $?contents ?next))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-NoMoreElements\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:values) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (contents $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (contents $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?rest))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (modify-instance ?wave (DeleteNodes $?rest))\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => $?npe)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-Match\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => ?next $?rest))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (contents $?contents))\n =>\n (modify ?fct (arguments ?id => $?rest))\n (if (not (member$ ?next $?contents)) then\n (modify-instance ?wave (contents $?contents ?next))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-NoMoreElements\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:contents) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ee41761913b9c684164e696dc4dd9a001f6deefe","subject":"Ported WavefrontPropagation.clp to the new format","message":"Ported WavefrontPropagation.clp to the new format\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (Parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n (\/ (length$ $?elements) 2) \n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule PropagateAggregateInformation\n\t\t\t\"Pulls instruction propagation information from all elements on paths \n\t\t\tthat immediately precede this element on the wavefront and merges it \n\t\t\tinto the path aggregate itself\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t(Propagate aggregates of ?e)\n\t\t\t;if this element is on the wavefront then we can be certain that all \n\t\t\t;of it's predecessors are above it. That is the definition of being on\n\t\t\t;the wavefront\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?e) (ID ?pp))\n\t\t\t(object (is-a Diplomat) (ID ?e) (PreviousPathElements $? ?z $?))\n\t\t\t(object (is-a PathAggregate) (Parent ?z) \n\t\t\t\t\t (InstructionPropagation $? ?targ ?alias ? ! $?))\n\t\t\t=>\n\t\t\t;replace parent blocks of previous path elements with the name of the\n\t\t\t;element this was acquired from\n\t\t\t;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n\t\t\t(slot-insert$ ?pa InstructionPropagation 1 ?targ ?alias ?z !))\n;------------------------------------------------------------------------------\n(defrule RetractAggregationInformation\n\t\t\t(declare (salience -50))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t?fct <- (Propagate aggregates of ?)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule AssertPhiNodePropagationPredicateIsBlock\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiIdentify $?)\n\t\t\t(object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?e) \n\t\t\t\t\t\t\t\t(InstructionPropagation ?targ ?alias ?pred ! $?rest))\n\t\t\t=>\n\t\t\t(modify-instance ?pa (InstructionPropagation $?rest))\n\t\t\t(assert (Propagation target ?targ with alias ?alias\n\t\t\t\t\t\t\t\t\t\tfrom block ?pred for block ?e)))\n;------------------------------------------------------------------------------\n(defrule RemoveDuplicateElements \n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?f0 <- (Propagation target ?t with alias ?a from block ?p0 \n\t\t\t\t\t\t\t\t\t for block ?b)\n\t\t\t?f1 <- (Propagation target ?t with alias ?a from block ?p1 \n\t\t\t\t\t\t\t\t\t for block ?b)\n\t\t\t(test (and (neq ?f0 ?f1) (neq ?p0 ?p1)))\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?b))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(slot-insert$ ?pa InstructionPropagation 1 ?t ?a ?b !))\n;------------------------------------------------------------------------------\n(defrule MergePhiNodePropagationWithOtherPropagation\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?f0 <- (Propagation target ?t with alias ?a0 from block ?p0 \n\t\t\t\t\t\t\t\t\t for block ?b)\n\t\t\t?f1 <- (Propagation target ?t with alias ?a1 from block ?p1 \n\t\t\t\t\t\t\t\t\t for block ?b)\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (Create phinode targeting instruction ?t for block ?b \n\t\t\t\t\t\t\t\t consisting of ?a0 ?p0 ?a1 ?p1 )))\n;------------------------------------------------------------------------------\n(defrule MergePhiNodePropagationWithCreateStatement\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?f0 <- (Propagation target ?t with alias ?a0 from block ?p0 \n\t\t\t\t\t\t\t\t\t for block ?b)\n\t\t\t?f1 <- (Create phinode targeting instruction ?t for block ?b \n\t\t\t\t\t\t\t\tconsisting of $?targets)\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (Create phinode targeting instruction ?t for block ?b \n\t\t\t\t\t\t\t\t consisting of $?targets ?a0 ?p0 )))\n;------------------------------------------------------------------------------\n(defrule PutUnfulfilledItemsBackIntoPropagationList\n\t\t\t(declare (salience -10))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?f0 <- (Propagation target ?t with alias ?a0 from block ?p0 for \n\t\t\t\t\t\t\t\t\t block ?b)\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(slot-insert$ ?pa InstructionPropagation 1 ?t ?a0 ?b !))\n;------------------------------------------------------------------------------\n(defrule NamePhiNodeFromCreateStatement-NotOriginalBlock\n\t\t\t(declare (salience -12))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?fct <- (Create phinode targeting instruction ?t for block ?b\n\t\t\t\t\t\t\t\t consisting of $?elements)\n\t\t\t?agObj <- (object (is-a PathAggregate) \n\t\t\t\t\t\t\t\t\t(Parent ?b))\n\t\t\t?bb <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t(ID ?b) \n\t\t\t\t\t\t\t\t(Contents ?first $?rest)\n\t\t\t\t\t\t\t\t(UnlinkedInstructions $?ui))\n\t\t\t(test (not (member$ ?t $?ui)))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (ID ?first) \n\t\t\t\t\t (Pointer ?bPtr))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (ID ?t) \n\t\t\t\t\t (Type ?ty))\n\t\t\t(object (is-a LLVMType) \n\t\t\t\t\t (ID ?ty) \n\t\t\t\t\t (Pointer ?dataType))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?name (sym-cat phi. (gensym*) . ?t))\n\t\t\t(bind ?count (\/ (length$ $?elements) 2))\n\t\t\t(bind ?pointers (symbol-to-pointer-list ?elements))\n\t\t\t(make-instance ?name of PhiNode \n\t\t\t\t\t\t\t\t(Parent ?b)\n\t\t\t\t\t\t\t\t(TimeIndex 0)\n\t\t\t\t\t\t\t\t(Pointer (llvm-make-phi-node ?name ?dataType ?count \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?bPtr ?pointers))\n\t\t\t\t\t\t\t\t(IncomingValueCount ?count)\n\t\t\t\t\t\t\t\t(Operands $?elements))\n\t\t\t;we've scheduled the given original instruction into this block\n\t\t\t; although it's just a ruse\n\t\t\t(slot-insert$ ?agObj ScheduledInstructions 1 ?t)\n\t\t\t(slot-insert$ ?agObj InstructionPropagation 1 ?t ?name ?b !)\n\t\t\t(slot-insert$ ?agObj ReplacementActions 1 ?t ?name !)\n\t\t\t(slot-insert$ ?bb Contents 1 ?name)\n\t\t\t(assert (Update duration for block ?b)))\n;------------------------------------------------------------------------------\n(defrule NamePhiNodeFromCreateStatement-OriginalBlock\n\t\t\t(declare (salience -12))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNode $?)\n\t\t\t?fct <- (Create phinode targeting instruction ?t for block ?b\n\t\t\t\t\t\t\t\t consisting of $?elements)\n\t\t\t?agObj <- (object (is-a PathAggregate) \n\t\t\t\t\t\t\t\t\t(Parent ?b))\n\t\t\t?bb <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t(ID ?b) \n\t\t\t\t\t\t\t\t(Contents ?first $?rest) \n\t\t\t\t\t\t\t\t(UnlinkedInstructions $?ui))\n\t\t\t(test (not (member$ ?t ?ui)))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (ID ?first) \n\t\t\t\t\t (Pointer ?bPtr))\n\t\t\t?tObj <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (ID ?t) \n\t\t\t\t\t\t\t\t (Type ?ty) \n\t\t\t\t\t\t\t\t (Pointer ?tPtr))\n\t\t\t(object (is-a LLVMType) \n\t\t\t\t\t (ID ?ty) \n\t\t\t\t\t (Pointer ?dataType))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?name (sym-cat phi. (gensym*) . ?t))\n\t\t\t(bind ?count (\/ (length$ $?elements) 2))\n\t\t\t(bind ?pointers (symbol-to-pointer-list ?elements))\n\t\t\t(bind ?phiPointer \n\t\t\t\t\t(llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n\t\t\t(bind ?phiObj (make-instance ?name of PhiNode \n\t\t\t\t\t\t\t\t\t\t\t\t (Parent ?b)\n\t\t\t\t\t\t\t\t\t\t\t\t (TimeIndex 0)\n\t\t\t\t\t\t\t\t\t\t\t\t (Pointer ?phiPointer)\n\t\t\t\t\t\t\t\t\t\t\t\t (IncomingValueCount ?count)\n\t\t\t\t\t\t\t\t\t\t\t\t (Operands $?elements)))\n\t\t\t(llvm-replace-all-uses ?tPtr ?phiPointer)\n\t\t\t(llvm-unlink-and-delete-instruction ?tPtr)\n\t\t\t(unmake-instance ?tObj)\n\t\t\t(slot-insert$ ?agObj ScheduledInstructions 1 ?t)\n\t\t\t(slot-insert$ ?bb Contents 1 ?name)\n\t\t\t(assert (Update duration for block ?b)))\n;------------------------------------------------------------------------------\n(defrule ReindexBasicBlock \n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage PhiNodeUpdate $?)\n\t\t\t?fct <- (Update duration for block ?b)\n\t\t\t(object (is-a BasicBlock) (ID ?b) (Contents $?c))\n\t\t\t=>\n\t\t\t;this is very much procedural but I frankly don't care\n\t\t\t;anymore. \n\t\t\t(bind ?index 0)\n\t\t\t(progn$ (?t ?c)\n\t\t\t\t\t (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n\t\t\t\t\t (modify-instance ?obj (TimeIndex ?index))\n\t\t\t\t\t (bind ?index (+ ?index 1)))\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"88fe9209cc849f161c830a653113b543363f6c4a","subject":"Added the wavefront-scheduling-pre-init module to Init.clp","message":"Added the wavefront-scheduling-pre-init module to Init.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4f7e1a5c848c1db5e2b182b04968fe93c114071e","subject":"lib\/widget\/Library.clp: Rewrote to take advantage of the init features","message":"lib\/widget\/Library.clp: Rewrote to take advantage of the init features\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/lib\/widget\/Library.clp","new_file":"src\/lib\/widget\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n (import init ?ALL)\n (import cortex ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(library-files \"widget\"\n \"WidgetEvent.clp\"\n \"WidgetElement.clp\")\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/widget\/WidgetEvent.clp\")\n(batch* \"lib\/widget\/WidgetElement.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"583403609b4f500bc71cfab26d3f9d1b563d416a","subject":"Fixed bugs in ValidBlockIdentification.clp","message":"Fixed bugs in ValidBlockIdentification.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) \n (id ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) \n (id ?path) \n (values $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?path ?block => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) (parent ?r) (contents $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) (ID ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) (id ?path) (contents $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"948de1e55e15febaa1ee0d3b92933158b95b9d9b","subject":"clips:learn:template","message":"clips:learn:template\n","repos":"qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace","old_file":"clips\/learn\/user_guide\/time.clp","new_file":"clips\/learn\/user_guide\/time.clp","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"CLIPS"} {"commit":"33d2753c929db28445bbdd01aa621d4e45422f03","subject":"Added load statements to the llvm module header","message":"Added load statements to the llvm module header\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/ModuleHeader.clp","new_file":"modules\/llvm\/ModuleHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the llvm module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n; Path is modules\/llvm\/\n(defmodule llvm \n (import core defclass ?ALL)\n (import core deffunction ?ALL) \n (export defclass ?ALL)\n (export deffunction ?ALL))\n\n; DO NOT MESS WITH THE ORDER OF THESE COMMANDS\n; BAD THINGS CAN HAPPEN\n; Class loaders\n(load* \"modules\/llvm\/LLVMObject.clp\")\n(load* \"modules\/llvm\/LLVMValue.clp\")\n(load* \"modules\/llvm\/LLVMUser.clp\")\n(load* \"modules\/llvm\/Diplomat.clp\")\n\n; Function loaders\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the llvm module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n; Path is modules\/llvm\/\n(defmodule llvm \n (import core defclass ?ALL)\n (import core deffunction ?ALL) \n (export defclass ?ALL)\n (export deffunction ?ALL))\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"75435bbc3cbe8708aaf411bf20b52e22c0789eee","subject":"Fixed bugs in SelectCPVForAnalysis","message":"Fixed bugs in SelectCPVForAnalysis\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"a0416a59336e2aa313b8c074fd1465fbe89345c3","subject":"Added Init.clp as the default entry point for this optimization","message":"Added Init.clp as the default entry point for this optimization\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"Init.clp","new_file":"Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'Init.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6b98c6c0d759fe2503ef51ca6de5b35645b5f830","subject":"Changed the loader to reference the new core.clp","message":"Changed the loader to reference the new core.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/Init.clp","new_file":"lib\/durandal\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch* \"modules\/core\/core.clp\")\n(batch-load (create$ \"modules\/llvm\/ModuleHeader.clp\"\n \"modules\/rampancy\/ModuleHeader.clp\"\n \"modules\/indirect\/ModuleHeader.clp\"\n \"modules\/types\/ModuleHeader.clp\"\n \"modules\/pipeline\/ModuleHeader.clp\"\n ; Add entries to other modules here\n \"passes\/PassRegistry.clp\"\n \"modules\/main\/ModuleHeader.clp\"\n ))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t\t\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/rampancy\/ModuleHeader.clp\"\n\t\t\t \"modules\/indirect\/ModuleHeader.clp\"\n\t\t\t \"modules\/types\/ModuleHeader.clp\"\n\t\t\t \"modules\/pipeline\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t \"passes\/PassRegistry.clp\"\n\t\t\t \"modules\/main\/ModuleHeader.clp\"\n\t\t\t ))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9df72640bef5068c046d8ca513e17067f0a2cbbb","subject":"update task1 from chapter4","message":"update task1 from chapter4","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter4\/task1.clp","new_file":"ssu-ai-level-2\/chapter4\/task1.clp","new_contents":"(deffacts employees\n (employee Lelyakin 10 2 100000)\n (employee Lelyakina 11 2 100000)\n (employee Timkaev 12 3 110000)\n (employee Timkaeva 13 3 110000)\n (employee Kisurin 13 3 111000)\n (employee Oldmann 31 3 111991)\n)\n\n(defrule prem\n (employee ?name ?expierence ?children ?salary)\n\n (test (or (> ?children 2)\n (>= ?expierence 5)\n )\n )\n =>\n (assert (premia ?name (* ?salary 0.2)))\n)\n\n(defrule all_empl_prem\n (forall (employee ?name ?expierence ?children ?salary)\n (prem ?name))\n =>\n (printout t \"All employees has prem\")\n)\n\n(defrule veteran\n (employee ?name ?expierence ?children ?salary)\n\n (test (> ?expierence 20))\n =>\n (printout t \"There are veterans\" crlf)\n)\n","old_contents":"(deffacts employees\n (employee Lelyakin 10 2 100000)\n (employee Lelyakina 11 2 100000)\n (employee Timkaev 12 3 110000)\n (employee Timkaeva 13 3 110000)\n (employee Kisurin 13 3 111000)\n)\n\n(defrule prem\n (employee ?name ?expierence ?children ?salary)\n \n (test (or (?children > 2)\n (?expierence >= 5)\n )\n )\n =>\n (assert (premia ?name (* ?salary 0.2)))\n)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"1ccb7acb04f5bde8d9396b8400cebdf09025716f","subject":"Update expert-system.clp","message":"Update expert-system.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/expert-system.clp","new_file":"ssu-ai-level-2\/expert-system.clp","new_contents":"(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n )\n\n ?answer\n)\n\n(deffunction yes-or-no-p (?question)\n (bind ?response (ask-question ?question yes no \u0443 n))\n (or (eq ?response yes) (eq ?response y))\n)\n","old_contents":"(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n )\n\n ?answer\n)\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"bf0f7af19c6031cdafead6265e63de03429c2215","subject":"Realizado cambios al ejercicio 1","message":"Realizado cambios al ejercicio 1","repos":"RubenAgudo\/InteligenciaArtificial","old_file":"src\/CLIPS\/Laboratorio3\/rules.clp","new_file":"src\/CLIPS\/Laboratorio3\/rules.clp","new_contents":"(defrule R1 \n (viven-mismo-pueblo ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R2 \n (estudian-misma-facultad ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R3 \n (son-misma-cuadrilla ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R4 \n (posible-equipo ?x ?y)\n => (assert (equipo-campeonato ?x ?y))\n)\n\n(defrule R5 \n (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)\n => (assert (equipo-pala ?x ?y))\n)\n\n(defrule R6 \n (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)(es-zurda ?x)\n =>(assert (equipo-pala ?x ?y))\n)\n\n(defrule R7 \n (buen-saque ?x) (gusta-cualquier-deporte ?x)\n => (assert (gusta-jugar-pala ?x))\n)\n\n(defrule R8 \n (habitual-Anoeta ?x)(gusta-cualquier-deporte ?x)\n => (assert (gusta-jugar-pala ?x))\n)\n(defrule R9\n (equipo-pala ?x ?y)\n (equipo-pala ?w ?z)\n ?pista<-(pista-libre-Anoeta ?m)\n (test(neq ?equipo1 ?equipo2))\n => (assert (partido (equipo1 ?x ?y)(equipo2 ?w ?z) (pista ?m)) (retract ?pista)\n)","old_contents":"(defrule R1 \n (viven-mismo-pueblo ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R2 \n (estudian-misma-facultad ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R3 \n (son-misma-cuadrilla ?x ?y)\n => (assert (posible-equipo ?x ?y))\n)\n\n(defrule R4 \n (posible-equipo ?x ?y)\n => (assert (equipo-campeonato ?x ?y))\n)\n\n(defrule R5 \n (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)\n => (assert (equipo-pala ?x ?y))\n)\n\n(defrule R6 \n (equipo-campeonato ?x ?y) (gusta-jugar-pala ?x) (gusta-jugar-pala ?y)(es-zurda ?x)\n =>(assert (equipo-pala ?x ?y))\n)\n\n(defrule R7 \n (buen-saque ?x) (gusta-cualquier-deporte ?x)\n => (assert (gusta-jugar-pala ?x))\n)\n\n(defrule R8 \n (habitual-Anoeta ?x)(gusta-cualquier-deporte ?x)\n => (assert (gusta-jugar-pala ?x))\n)\n(defrule R9\n ?equipo1<- (equipo-pala ?x ?y)\n ?equipo2<-(equipo-pala ?w ?z)\n ?pista<-(pista-libre-Anoeta ?m)\n (test(neq ?equipo1 ?equipo2))\n => (assert (partido ?equipo1 ?equipo2 ?pista)) (retract ?pista)\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"4512c624e12f6a6c2f7c3aa6b48548bc8cdeab7d","subject":"-changed manners for jamochas needs","message":"-changed manners for jamochas needs\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1509 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"benchmark\/manners\/manners4.clp","new_file":"benchmark\/manners\/manners4.clp","new_contents":"(deftemplate guest\r\n (slot name (type STRING)) \r\n (slot sex (type STRING))\r\n (slot hobby (type STRING)) )\r\n \r\n(deftemplate last_seat\r\n (slot seat (type INTEGER)) )\r\n \r\n(deftemplate seating\r\n (slot seat1 (type INTEGER))\r\n (slot name1 (type STRING))\r\n (slot seat2 (type INTEGER))\r\n (slot name2 (type STRING))\r\n (slot id (type INTEGER))\r\n (slot pid (type INTEGER))\r\n (slot path_done (type BOOLEAN)) )\r\n \r\n(deftemplate context\r\n (slot name (type STRING)) )\r\n \r\n(deftemplate path\r\n (slot id (type INTEGER))\r\n (slot name (type STRING))\r\n (slot seat (type INTEGER)) )\r\n \r\n(deftemplate chosen\r\n (slot id (type INTEGER))\r\n (slot name (type STRING))\r\n (slot hobby (type STRING)) )\r\n\r\n(deftemplate count\r\n (slot c (type INTEGER)) )\r\n \r\n(defrule assign_first_seat \"assign the first seat\"\r\n ?context <- (context (name \"startup\") )\r\n (guest (name ?n))\r\n ?count <- (count (c ?cnt) )\r\n =>\r\n (assert (seating (seat1 1) (name1 ?n) (name2 ?n) (seat2 1) (id ?cnt) (pid 0) (path_done TRUE) ) )\r\n (assert (path (id ?cnt) (name ?n) (seat 1) ) )\r\n (printout t \"first seat seat1=1 name=\" ?n \" name2=\" ?n \" seat2=1 id=\" ?cnt \" pid=0 path_done TRUE\" crlf)\r\n (bind ?cntPlus1 (+ ?cnt 1) )\r\n (modify ?count (c ?cntPlus1) )\r\n (modify ?context (name \"assign_seats\") )\r\n)\r\n(defrule find_seating \"find seating for guest\"\r\n ?context <- (context (name \"assign_seats\") )\r\n (seating (seat2 ?s2) (name2 ?n2) (id ?id) (path_done TRUE) )\r\n (guest (name ?n2) (sex ?sex1) (hobby ?h1) )\r\n (guest (name ?g2) (sex ~?sex1) (hobby ?h1) )\r\n ?count <- (count (c ?cnt) )\r\n (not (path (id ?id) (name ?g2) ) )\r\n (not (chosen (id ?id) (name ?g2) (hobby ?h1) ) )\r\n=>\r\n (bind ?s2plus1 (+ ?s2 1) )\r\n (assert (seating (seat1 ?s2) (name1 ?n2) (name2 ?g2) (seat2 ?s2plus1) (id ?cnt) (pid ?id) (path_done FALSE) ) )\r\n (assert (path (id ?cnt) (name ?g2) (seat ?s2plus1) ) )\r\n (assert (chosen (id ?id) (name ?g2) (hobby ?h1) ) ) \r\n (bind ?cntPlus1 (+ ?cnt 1) )\r\n (modify ?count (c ?cntPlus1) )\r\n (modify ?context (name \"make_path\") )\r\n (printout t \"seat1=\" ?s2 \" : name1=\" ?n2 \" : seat2=\" ?s2plus1 \" : name2=\" ?g2 \" : id=\" ?cnt \" : pid=\" ?id \" : path_done=FALSE\" crlf)\r\n)\r\n(defrule path_done \"path is done\"\r\n ?context <- (context (name \"make_path\") )\r\n ?seating <- (seating (path_done FALSE) )\r\n=>\r\n (modify ?seating (path_done TRUE) )\r\n (modify ?context (name \"check_done\") )\r\n (printout t \"path is done \" crlf)\r\n)\r\n(defrule make_path\r\n ?context <- (context (name \"make_path\") )\r\n (seating (id ?id) (pid ?sPID) (path_done FALSE) )\r\n (path (id ?sPID) (name ?n1) (seat ?s) )\r\n (not (path (id ?id) (name ?n1) ) )\r\n=>\r\n (assert (path (id ?id) (name ?n1) (seat ?s) ) )\r\n (printout t \"make_path - id=\" ?id \" name=\" ?n1 \" seat=\" ?s crlf)\r\n)\r\n(defrule continue \"continue matching\"\r\n ?context <- (context (name \"check_done\") )\r\n=>\r\n (modify ?context (name \"assign_seats\") )\r\n (printout t \"assign seats again\" crlf) \r\n)\r\n(defrule are_we_done \"are we done?\"\r\n ?context <- (context (name \"check_done\") )\r\n (last_seat (seat ?lseat) )\r\n (seating (seat2 ?lseat) )\r\n=>\r\n (printout t \"Yes, we are done: Print Results!!\" crlf)\r\n (modify ?context (name \"all_done\") )\r\n)\r\n\r\n(defrule all_done \"all done with test\"\r\n ?context <- (context (name \"all_done\") )\r\n=>\r\n (modify ?context (name \"print_results\") )\r\n (printout t crlf \"rule all done: Condition context print_results\" crlf )\r\n)\r\n(defrule print_results \"print the results\"\r\n (context (name \"print_results\") )\r\n ?seating <- (seating (id ?id) (seat2 ?s2) )\r\n (last_seat (seat ?s2) )\r\n (path (id ?id) (name ?n1) (seat ?s1) )\r\n=>\r\n (printout t \"name=\" ?n1 \" seat=\" ?s1 crlf)\r\n (retract ?seating)\r\n)\r\n\r\n(assert (context (name \"startup\") ) )\r\n(assert (count (c 1) ) )\r\n\r\n\r\n(assert (guest (name \"1\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"1\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"2\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"2\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"1\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"4\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"4\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"1\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"1\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"7\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"7\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"8\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"8\") (sex \"m\") (hobby \"1\") ) )\r\n(assert (last_seat (seat 8) ) )\r\n(bind ?*start* (ms-time) )\r\n(fire)\r\n(bind ?*end* (ms-time) )\r\n(bind ?et (- ?*end* ?*start*) )\r\n(printout t \"elpasedTime=\" ?et crlf)\r\n","old_contents":"(deftemplate guest\r\n (slot name (type STRING)) \r\n (slot sex (type STRING))\r\n (slot hobby (type STRING)) )\r\n \r\n(deftemplate last_seat\r\n (slot seat (type INTEGER)) )\r\n \r\n(deftemplate seating\r\n (slot seat1 (type INTEGER))\r\n (slot name1 (type STRING))\r\n (slot name2 (type STRING))\r\n (slot seat2 (type INTEGER))\r\n (slot id (type INTEGER))\r\n (slot pid (type INTEGER))\r\n (slot path_done (type BOOLEAN)) )\r\n \r\n(deftemplate context\r\n (slot name (type STRING)) )\r\n \r\n(deftemplate path\r\n (slot id (type INTEGER))\r\n (slot name (type STRING))\r\n (slot seat (type INTEGER)) )\r\n \r\n(deftemplate chosen\r\n (slot id (type INTEGER))\r\n (slot name (type STRING))\r\n (slot hobby (type STRING)) )\r\n\r\n(deftemplate count\r\n (slot c (type INTEGER)) )\r\n \r\n(defrule assign_first_seat \"assign the first seat\"\r\n ?context <- (context (name \"startup\") )\r\n (guest (name ?n))\r\n ?count <- (count (c ?cnt) )\r\n =>\r\n (assert (seating (seat1 1) (name1 ?n) (name2 ?n) (seat2 1) (id ?cnt) (pid 0) (path_done TRUE) ) )\r\n (assert (path (id ?cnt) (name ?n) (seat 1) ) )\r\n (printout t \"first seat seat1=1 name=\" ?n \" name2=\" ?n \" seat2=1 id=\" ?cnt \" pid=0 path_done TRUE\" crlf)\r\n (bind ?cntPlus1 (+ ?cnt 1) )\r\n (modify ?count (c ?cntPlus1) )\r\n (modify ?context (name \"assign_seats\") )\r\n)\r\n(defrule find_seating \"find seating for guest\"\r\n ?context <- (context (name \"assign_seats\") )\r\n (seating (seat2 ?s2) (name2 ?n2) (id ?id) (path_done TRUE) )\r\n (guest (name ?n2) (sex ?sex1) (hobby ?h1) )\r\n (guest (name ?g2) (sex ~?sex1) (hobby ?h1) )\r\n ?count <- (count (c ?cnt) )\r\n (not (path (id ?id) (name ?g2) ) )\r\n (not (chosen (id ?id) (name ?g2) (hobby ?h1) ) )\r\n=>\r\n (bind ?s2plus1 (+ ?s2 1) )\r\n (assert (seating (seat1 ?s2) (name1 ?n2) (name2 ?g2) (seat2 ?s2plus1) (id ?cnt) (pid ?id) (path_done FALSE) ) )\r\n (assert (path (id ?cnt) (name ?g2) (seat ?s2plus1) ) )\r\n (assert (chosen (id ?id) (name ?g2) (hobby ?h1) ) ) \r\n (bind ?cntPlus1 (+ ?cnt 1) )\r\n (modify ?count (c ?cntPlus1) )\r\n (modify ?context (name \"make_path\") )\r\n (printout t \"seat1=\" ?s2 \" : name1=\" ?n2 \" : seat2=\" ?s2plus1 \" : name2=\" ?g2 \" : id=\" ?cnt \" : pid=\" ?id \" : path_done=FALSE\" crlf)\r\n)\r\n(defrule make_path\r\n ?context <- (context (name \"make_path\") )\r\n (seating (id ?id) (pid ?sPID) (path_done FALSE) )\r\n (path (id ?sPID) (name ?n1) (seat ?s) )\r\n (not (path (id ?id) (name ?n1) ) )\r\n=>\r\n (assert (path (id ?id) (name ?n1) (seat ?s) ) )\r\n (printout t \"make_path - id=\" ?id \" name=\" ?n1 \" seat=\" ?s crlf)\r\n)\r\n\r\n(defrule are_we_done \"are we done?\"\r\n ?context <- (context (name \"check_done\") )\r\n (last_seat (seat ?lseat) )\r\n (seating (seat2 ?lseat) )\r\n=>\r\n (printout t \"Yes, we are done: Print Results!!\" crlf)\r\n (modify ?context (name \"all_done\") )\r\n)\r\n(defrule path_done \"path is done\"\r\n ?context <- (context (name \"make_path\") )\r\n ?seating <- (seating (path_done FALSE) )\r\n=>\r\n (modify ?seating (path_done TRUE) )\r\n (modify ?context (name \"check_done\") )\r\n (printout t \"path is done \" crlf)\r\n)\r\n(defrule continue \"continue matching\"\r\n ?context <- (context (name \"check_done\") )\r\n=>\r\n (modify ?context (name \"assign_seats\") )\r\n (printout t \"assign seats again\" crlf) \r\n)\r\n(defrule all_done \"all done with test\"\r\n ?context <- (context (name \"all_done\") )\r\n=>\r\n (modify ?context (name \"print_results\") )\r\n (printout t crlf \"rule all done: Condition context print_results\" crlf )\r\n)\r\n(defrule print_results \"print the results\"\r\n (context (name \"print_results\") )\r\n ?seating <- (seating (id ?id) (seat2 ?s2) )\r\n (last_seat (seat ?s2) )\r\n (path (id ?id) (name ?n1) (seat ?s1) )\r\n=>\r\n (printout t \"name=\" ?n1 \" seat=\" ?s1 crlf)\r\n (retract ?seating)\r\n)\r\n\r\n(assert (context (name \"startup\") ) )\r\n(assert (count (c 1) ) )\r\n(assert (guest (name \"1\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"1\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"2\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"2\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"1\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"2\") ) )\r\n(assert (guest (name \"3\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"4\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"4\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"1\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"5\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"1\") ) )\r\n(assert (guest (name \"6\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"7\") (sex \"f\") (hobby \"3\") ) )\r\n(assert (guest (name \"7\") (sex \"f\") (hobby \"2\") ) )\r\n(assert (guest (name \"8\") (sex \"m\") (hobby \"3\") ) )\r\n(assert (guest (name \"8\") (sex \"m\") (hobby \"1\") ) )\r\n(assert (last_seat (seat 8) ) )\r\n(bind ?*start* (ms-time) )\r\n(fire)\r\n(bind ?*end* (ms-time) )\r\n(bind ?et (- ?*end* ?*start*) )\r\n(printout t \"elpasedTime=\" ?et crlf)\r\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"740a6e7e862ae75d748ffde1becdeb137c011ac2","subject":"Added WidgetElement.clp","message":"Added WidgetElement.clp\n\nThe base class of all widgets is the WidgetElement. It is a simple class that\nprovides the functionality that all widgets share.\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/lib\/widget\/WidgetElement.clp","new_file":"src\/lib\/widget\/WidgetElement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/lib\/widget\/WidgetElement.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"50ecbbd3ec4855dfe8199c467fb7e550c28b298f","subject":"Added code to Init.clp as an example","message":"Added code to Init.clp as an example\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"Init.clp","new_file":"Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/scheduler\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"71f166297cc4f7a226b41dfe853336b14e02d120","subject":"Added a tool to convert defines in gl.h to corresponding C code","message":"Added a tool to convert defines in gl.h to corresponding C code\n\nThis is not a complete tool but is in the process of being written.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/tools\/GLConstantConversion.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"98a4ea0f5891fbc1c7996cc9116a625a2133c242","subject":"Create task4.clp","message":"Create task4.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task4.clp","new_file":"ssu-ai-level-2\/chapter6\/task4.clp","new_contents":"(deffunction fx (?x ?a)\n (if (< ?x 0) then (return (\/ (abs (- ?x ?a)) (* ?x ?x))))\n (if (> ?x 0) then (return (sin (abs (+ ?x ?a)))))\n 0\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task4.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"fb849958d84bdabf7cbc11f672be4e73f9fd6bbb","subject":"fixed an issue with FinishSchedulingIntoBlock","message":"fixed an issue with FinishSchedulingIntoBlock\n\nIt turns out that I need to use (instance-address llvm ) to\ndynamically reference elements. This is due to the use of modules\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"13ee66bbd551217c7a96c36287075fd63de4de3b","subject":"Create task5.clp","message":"Create task5.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task5.clp","new_file":"ssu-ai-level-2\/chapter5\/task5.clp","new_contents":"(defrule bank\n =>\n (printout t \"p=\")\n (bind ?p (read))\n (printout t \"You need wait: \" (max (round (\/ (log 2) (log (+ 1 ?p)))) (round (+ 0.5 (\/ (log 2) (log (+ 1 ?p)))))))\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task5.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"5300d62d14320d61e8ceb61e1b9c6f7cd1fed129","subject":"Create task5.clp","message":"Create task5.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task5.clp","new_file":"ssu-ai-level-2\/chapter7\/task5.clp","new_contents":"(deffunction trim (?str)\n (bind ?str2 \"\")\n (bind ?space True)\n (bind ?n (str-length ?str))\n (bind ?i 0)\n (while (< ?i ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n\n (if (= 0 (str-compare ?c1 \" \")) then\n (if (and (?space True)) then\n (printout t \"kefal\")\n (bind ?space False)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n\n else\n\n (bind ?space True)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n (bind ?i (+ ?i 1))\n )\n ?str2\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task5.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"8b74feb7900c84096707611990179d276337217b","subject":"Added debug INFO when SV is updated.","message":"Added debug INFO when SV is updated.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/BB_interface.clp","new_file":"CLIPS\/BB_interface.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tDEFTEMPLATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deftemplate waiting\n\t(slot cmd (type STRING))\n\t(slot id (type INTEGER))\n\t(slot args (type STRING))\n\t(slot timeout\n\t\t(type INTEGER)\n\t\t(range 0 ?VARIABLE)\n\t)\n\t(slot attempts\n\t\t(type INTEGER)\n\t\t(range 1 ?VARIABLE)\n\t)\n\t(slot symbol\n\t\t(type SYMBOL)\n\t)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tBB FUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction send-command\n\t; Receives: command, symbol identifier, cmd_params and optionally\n\t;timeout and number of attempts in case it times out or fails.\n\t; Symbol identifier is useful for tracking responses through rules.\n\t(?cmd ?sym ?args $?settings)\n\t(bind ?timeout ?*defaultTimeout*)\n\t(bind ?attempts ?*defaultAttempts*)\n\t(switch (length$ $?settings)\n\t\t(case 1 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t)\n\t\t(case 2 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t\t(bind ?attempts (nth$ 2 $?settings))\n\t\t)\n\t)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(if (> ?timeout 0) then\n\t\t(setCmdTimer ?timeout ?cmd ?id)\n\t)\n\t(assert\n\t\t(waiting (cmd ?cmd) (id ?id) (args ?args) (timeout ?timeout) (attempts ?attempts) (symbol ?sym) )\n\t)\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts \" - time: \" (time) \" - params: \" ?args)\n\t(return ?id)\n)\n\n(deffunction send-response\n\t; Receives: command, id, result and params\n\t(?cmd ?id ?result ?params)\n\t(python-call SendResponse ?cmd ?id ?result ?params)\n\t(log-message INFO \"Sent response: '\" ?cmd \"' - id: \" ?id \" - result: \" ?result \"params: \" ?params)\n;\t(halt)\n)\n\n(deffunction create-shared_var\n\t; Receives: type and name\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name)\n\t(bind ?resp (python-call CreateSharedVar ?type ?name))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Created SharedVar: \" ?name)\n\telse\n\t\t(log-message WARNING \"SharedVar: '\" ?name \"' could NOT be created!\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction write-shared_var\n\t; Receives: type, name and data\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name $?data)\n\t(bind ?resp (python-call WriteSharedVar ?type ?name $?data))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Written to SharedVar: '\" ?name \"' - \" $?data)\n\telse\n\t\t(log-message WARNING \"Could NOT write to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction subscribe_to-shared_var\n\t; Receives: name and optionally subscription type and report type\n\t; Subscription type is one of: creation | writemodule | writeothers | writeany\n\t; report type is one of: content | notify\n\t(?name $?options)\n\t(bind ?resp (python-call SubscribeToSharedVar ?name $?options) )\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Subscribed to SharedVar: '\" ?name \"'\")\n\t\t(assert \n\t\t\t(BB_subscribed_to_var ?name)\n\t\t)\n\telse\n\t\t(log-message WARNING \"Could NOT subscribe to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tRULES TO HANDLE BB (PYTHON) ASSERTS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-waiting-timedout-without_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts 1) (args ?args) (timeout ?timeout&~0) (symbol ?sym) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(assert \n\t\t(BB_answer ?cmd ?sym 0 ?args)\n\t)\n\t(retract ?w ?BB)\n\t(log-message WARNING \"Command timedout w\/o attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - time: \" (time))\n)\n\n(defrule BB-waiting-timedout-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command timedout w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts \" - time: \" (time))\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(bind ?attempts (- ?attempts 1))\n\t(modify ?w (id ?id) (attempts ?attempts))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-failed-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_received ?cmd ?id 0 ?)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command failed w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - attempts: \" ?attempts \" - time: \" (time))\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(modify ?w (id ?id) (attempts (- ?attempts 1)))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-set_answer\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts ?attempts) (symbol ?sym))\n\t?BB <-(BB_received ?cmd ?id ?result ?params)\n\t(test (or (eq ?result 1) (eq ?attempts 1)))\n\t=>\n\t(retract ?w ?BB)\n\t(assert \n\t\t(BB_answer ?cmd ?sym ?result ?params)\n\t)\n\t(log-message INFO \"Answer received: '\" ?cmd \"' - id: \" ?id \" - successful: \" ?result \" - response: \" ?params)\n)\n\n(defrule BB-clear-timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?t)\n\t(log-message INFO \"Clearing timer for command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_response\n\t(declare (salience -9501))\n\t?BB <-(BB_received ?cmd ?id $?)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Clearing unhandled response from command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_answer\n\t(declare (salience -9501))\n\t?BB <-(BB_answer ?cmd ?sym ?result ?params)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Clearing answer from command: '\" ?cmd \"' - sym: \" ?sym \"' - result: \" ?result \"' - params: \" ?params)\n)\n\n\n;\tHANDLE SHARED VAR UPDATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-clear_sv_update\n\t(declare (salience -9501))\n\t?BB <-(BB_sv_updated $?)\n\t=>\n\t(retract ?BB)\n)\n\n(defrule BB-set_sv\n\t(declare (salience 9501))\n\t(not (BB_sv_updated ?name $?))\n\t?f <-(BB_set_sv_updated ?name $?data)\n\t=>\n\t(retract ?f)\n\t(assert\n\t\t(BB_sv_updated ?name $?data)\n\t)\n (log-message INFO \"SV_UPDATED: \" ?name $?data crlf)\n;\t(printout t \"SV_UPDATED: \" ?name \" \" $?data crlf)\n)\n\n(defrule BB-update_sv\n\t(declare (salience 9501))\n\t?BB <-(BB_sv_updated ?name $?)\n\t?f <-(BB_set_sv_updated ?name $?data)\n\t=>\n\t(retract ?BB ?f)\n\t(assert\n\t\t(BB_sv_updated ?name $?data)\n\t)\n (log-message INFO \"SV_UPDATED: \" ?name $?data crlf)\n;\t(printout t \"SV_UPDATED: \" ?name \" \" $?data crlf)\n)\n\n(defrule BB-unknown-command\n\t(declare (salience -9501))\n\t?BB <-(BB_cmd ?cmd ?id ?params)\n\t=>\n\t(retract ?BB)\n\t(send-response ?cmd ?id FALSE \"unknown command\")\n\t(log-message WARNING \"Unhandled command received: \" ?cmd)\n;\t(halt)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tDEFTEMPLATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deftemplate waiting\n\t(slot cmd (type STRING))\n\t(slot id (type INTEGER))\n\t(slot args (type STRING))\n\t(slot timeout\n\t\t(type INTEGER)\n\t\t(range 0 ?VARIABLE)\n\t)\n\t(slot attempts\n\t\t(type INTEGER)\n\t\t(range 1 ?VARIABLE)\n\t)\n\t(slot symbol\n\t\t(type SYMBOL)\n\t)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tBB FUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction send-command\n\t; Receives: command, symbol identifier, cmd_params and optionally\n\t;timeout and number of attempts in case it times out or fails.\n\t; Symbol identifier is useful for tracking responses through rules.\n\t(?cmd ?sym ?args $?settings)\n\t(bind ?timeout ?*defaultTimeout*)\n\t(bind ?attempts ?*defaultAttempts*)\n\t(switch (length$ $?settings)\n\t\t(case 1 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t)\n\t\t(case 2 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t\t(bind ?attempts (nth$ 2 $?settings))\n\t\t)\n\t)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(if (> ?timeout 0) then\n\t\t(setCmdTimer ?timeout ?cmd ?id)\n\t)\n\t(assert\n\t\t(waiting (cmd ?cmd) (id ?id) (args ?args) (timeout ?timeout) (attempts ?attempts) (symbol ?sym) )\n\t)\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts \" - time: \" (time) \" - params: \" ?args)\n\t(return ?id)\n)\n\n(deffunction send-response\n\t; Receives: command, id, result and params\n\t(?cmd ?id ?result ?params)\n\t(python-call SendResponse ?cmd ?id ?result ?params)\n\t(log-message INFO \"Sent response: '\" ?cmd \"' - id: \" ?id \" - result: \" ?result \"params: \" ?params)\n;\t(halt)\n)\n\n(deffunction create-shared_var\n\t; Receives: type and name\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name)\n\t(bind ?resp (python-call CreateSharedVar ?type ?name))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Created SharedVar: \" ?name)\n\telse\n\t\t(log-message WARNING \"SharedVar: '\" ?name \"' could NOT be created!\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction write-shared_var\n\t; Receives: type, name and data\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name $?data)\n\t(bind ?resp (python-call WriteSharedVar ?type ?name $?data))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Written to SharedVar: '\" ?name \"' - \" $?data)\n\telse\n\t\t(log-message WARNING \"Could NOT write to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction subscribe_to-shared_var\n\t; Receives: name and optionally subscription type and report type\n\t; Subscription type is one of: creation | writemodule | writeothers | writeany\n\t; report type is one of: content | notify\n\t(?name $?options)\n\t(bind ?resp (python-call SubscribeToSharedVar ?name $?options) )\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Subscribed to SharedVar: '\" ?name \"'\")\n\t\t(assert \n\t\t\t(BB_subscribed_to_var ?name)\n\t\t)\n\telse\n\t\t(log-message WARNING \"Could NOT subscribe to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tRULES TO HANDLE BB (PYTHON) ASSERTS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-waiting-timedout-without_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts 1) (args ?args) (timeout ?timeout&~0) (symbol ?sym) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(assert \n\t\t(BB_answer ?cmd ?sym 0 ?args)\n\t)\n\t(retract ?w ?BB)\n\t(log-message WARNING \"Command timedout w\/o attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - time: \" (time))\n)\n\n(defrule BB-waiting-timedout-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command timedout w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts \" - time: \" (time))\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(bind ?attempts (- ?attempts 1))\n\t(modify ?w (id ?id) (attempts ?attempts))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-failed-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_received ?cmd ?id 0 ?)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command failed w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - attempts: \" ?attempts \" - time: \" (time))\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(modify ?w (id ?id) (attempts (- ?attempts 1)))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-set_answer\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts ?attempts) (symbol ?sym))\n\t?BB <-(BB_received ?cmd ?id ?result ?params)\n\t(test (or (eq ?result 1) (eq ?attempts 1)))\n\t=>\n\t(retract ?w ?BB)\n\t(assert \n\t\t(BB_answer ?cmd ?sym ?result ?params)\n\t)\n\t(log-message INFO \"Answer received: '\" ?cmd \"' - id: \" ?id \" - successful: \" ?result \" - response: \" ?params)\n)\n\n(defrule BB-clear-timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?t)\n\t(log-message INFO \"Clearing timer for command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_response\n\t(declare (salience -9501))\n\t?BB <-(BB_received ?cmd ?id $?)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Clearing unhandled response from command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_answer\n\t(declare (salience -9501))\n\t?BB <-(BB_answer ?cmd ?sym ?result ?params)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Clearing answer from command: '\" ?cmd \"' - sym: \" ?sym \"' - result: \" ?result \"' - params: \" ?params)\n)\n\n\n;\tHANDLE SHARED VAR UPDATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-clear_sv_update\n\t(declare (salience -9501))\n\t?BB <-(BB_sv_updated $?)\n\t=>\n\t(retract ?BB)\n)\n\n(defrule BB-set_sv\n\t(declare (salience 9501))\n\t(not (BB_sv_updated ?name $?))\n\t?f <-(BB_set_sv_updated ?name $?data)\n\t=>\n\t(retract ?f)\n\t(assert\n\t\t(BB_sv_updated ?name $?data)\n\t)\n)\n\n(defrule BB-update_sv\n\t(declare (salience 9501))\n\t?BB <-(BB_sv_updated ?name $?)\n\t?f <-(BB_set_sv_updated ?name $?data)\n\t=>\n\t(retract ?BB ?f)\n\t(assert\n\t\t(BB_sv_updated ?name $?data)\n\t)\t\n)\n\n(defrule BB-unknown-command\n\t(declare (salience -9501))\n\t?BB <-(BB_cmd ?cmd ?id ?params)\n\t=>\n\t(retract ?BB)\n\t(send-response ?cmd ?id FALSE \"unknown command\")\n\t(log-message WARNING \"Unhandled command received: \" ?cmd)\n;\t(halt)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"c98b3e6f3e81cb8e915b001cc02d3621a9415e65","subject":"Deleted fs.clp because it is no longer necessary","message":"Deleted fs.clp because it is no longer necessary\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"lib\/sys\/fs.clp","new_file":"lib\/sys\/fs.clp","new_contents":"","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; fs.clp - Initializes the file system and handlers. This is the entry point\n; into the filesystem\n;------------------------------------------------------------------------------\n(defglobal MAIN\n ; Change the value of this global to change the name of the\n ; corresponding shell variable.\n ?*electron-fs-root* = ElectronFSRoot\n ; Use this to make sure that we fail out if we can't bootstrap\n ?*fs* = (progn (bind ?result (get-shell-variable ?*electron-fs-root*))\n (if (not ?result) then\n (printout t \"ERROR: \" ?*electron-fs-root* \" not defined - Exiting\" crlf)\n (exit)\n else\n ?result)))\n;------------------------------------------------------------------------------\n; Now that we have a base point we can really define some elegant fs points\n; Use fs as a builder of paths. I believe it's quite elegant :D\n;------------------------------------------------------------------------------\n(defgeneric fs)\n;------------------------------------------------------------------------------\n(defmethod fs () ?*fs*)\n(defmethod fs \n \"Builds a path around the electron file system from the root\"\n ((?atoms MULTIFIELD))\n (str-cat ?*fs* (expand$ ?atoms)))\n(defmethod fs \n ($?atoms) \n (fs ?atoms))\n\n;------------------------------------------------------------------------------\n; Define the filesystem now\n;------------------------------------------------------------------------------\n(defglobal MAIN\n ; dev directory - put fifos here to read and write from\n ?*\/dev* = (fs \/dev)\n ; lib directory\n ?*\/lib* = (fs \/lib)\n ; data directory\n ?*\/data* = (fs \/data)\n ; bin directory\n ?*\/bin* = (fs \/bin)\n ; etc directory\n ?*\/etc* = (fs \/etc)\n ; logic directory\n ?*\/logic* = (fs \/logic))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"415ce42b94fef0eb250f63573d11f95b098ce902","subject":"Added paths-conditional to the PassRegistry","message":"Added paths-conditional to the PassRegistry\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/PassRegistry.clp","new_file":"lib\/durandal\/passes\/PassRegistry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; NOTE: If you want to define your own place to load passes from then remember\n; that it is up to you to load it initially.\n;------------------------------------------------------------------------------\n\n;This is part of the MAIN module\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n \n \n ;([pass-valid-paths] of Pass\n ; (entry \"passes\/path\/valid-only\/PassHeader.clp\")\n ; (pass-name \"valid-paths\")\n ; (pass-description \"Generate the set of paths through user-defined valid regions in a function\")\n ; (target Function))\n ;([pass-paths] of Pass\n ; (entry \"passes\/path\/all-paths\/PassHeader.clp\")\n ; (pass-name \"paths\")\n ; (pass-description \"Generate the set of all paths through all regions in a function\")\n ; (target Function))\n\n)\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"eea5eb07fbe89cad6ddad8a79d7ccf0ff68bf21c","subject":"Added the simulator file","message":"Added the simulator file\n\nThis file will contain all of the logic for the theoretical-architecture\nemulator.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron","old_file":"Simulator.clp","new_file":"Simulator.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(defclass memory-cell\n (is-a USER)\n (slot address\n (type INTEGER)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (default-dynamic 0)))\n\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (range 0 255)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (default-dynamic 0)))\n;TODO: automate the generation of the register set\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'Simulator.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"e89f85b951a8e8e6a2667a7d29102e35dea73d9a","subject":"GLAPIConversion.clp: Added a conversation with myself about conversion","message":"GLAPIConversion.clp: Added a conversation with myself about conversion\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"3d49a1ee15f23a00bff587288fad30fd116271b8","subject":"Fixed the get-Pointer message in wavefront-scheduling\/common\/Functions.clp","message":"Fixed the get-Pointer message in wavefront-scheduling\/common\/Functions.clp\n\nIt should be get-pointer\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(deffunction types::symbol-to-pointer-list\n\t\t\t\t \"Converts a given list of symbols that represent InteropObjects and pulls the\n\t\t\t\t pointer value out of it. This function assumes order is important\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?result (create$))\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(bind ?obj (instance-address * \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (symbol-to-instance-name ?e)))\n\t\t\t\t\t\t\t(bind ?result (create$ ?result (send ?obj get-pointer))))\n\t\t\t\t (return ?result))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(deffunction types::symbol-to-pointer-list\n\t\t\t\t \"Converts a given list of symbols that represent InteropObjects and pulls the\n\t\t\t\t pointer value out of it. This function assumes order is important\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?result (create$))\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(bind ?obj (instance-address * \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (symbol-to-instance-name ?e)))\n\t\t\t\t\t\t\t(bind ?result (create$ ?result (send ?obj get-Pointer))))\n\t\t\t\t (return ?result))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4f028b3bbb06dcf1bb128b0fbc166e2dc9ce2644","subject":"Updated DeclareApplicationFunctions.clp to use generic-load","message":"Updated DeclareApplicationFunctions.clp to use generic-load\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"init\/DeclareApplicationFunctions.clp","new_file":"init\/DeclareApplicationFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareApplicationFunctions.clp - Defines a series of functions used to\n; streamline the loading of a given game\/application\/sample\/etc\n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(defgeneric init::load-application \"Loads an application\")\n;------------------------------------------------------------------------------\n(defmethod init::load-application\n \"Loads an application from the application folder with the specified name\"\n ((?root-folder-name LEXEME))\n (generic-load application ?root-folder-name Application.clp))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareApplicationFunctions.clp - Defines a series of functions used to\n; streamline the loading of a given game\/application\/sample\/etc\n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-application\n \"Loads an application from the application folder with the specified name\"\n (?root-folder-name)\n (batch* (format nil \"application\/%s\/Application.clp\" ?root-folder-name)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"3f9ef5909af3f64151afc8d1af637f504a7920f1","subject":"","message":"\n\nMove the samples away from the main code branch for refactoring.\nKHK.\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1233 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"examples\/agent\/message1.clp","new_file":"examples\/agent\/message1.clp","new_contents":"","old_contents":"(deftemplate agent-message\r\n (slot sender)\r\n (slot receivers)\r\n (multislot reply-to)\r\n (slot performative)\r\n (slot content)\r\n (slot language)\r\n (slot encoding)\r\n (slot ontology)\r\n (slot protocol)\r\n (slot conversation-id)\r\n (slot in-reply-to)\r\n (slot reply-with)\r\n (slot reply-by)\r\n (multislot user-properties)\r\n)\r\n\r\n(deftemplate agent-description\r\n (slot name)\r\n)\r\n\r\n(defrule incoming-message\r\n (agent-description\r\n (name ?receiver)\r\n )\r\n (agent-message\r\n (sender ?sender)\r\n (receivers ?receiver)\r\n (reply-to ?replyto)\r\n (performative ?performative)\r\n (content ?content)\r\n (language ?language)\r\n (encoding ?encoding)\r\n (ontology ?ontology)\r\n (protocol ?protocol)\r\n (conversation-id ?conversationid)\r\n (in-reply-to ?inreplyto)\r\n (reply-with ?replywith)\r\n (reply-by ?replyby)\r\n (user-properties ?userproperties)\r\n )\r\n =>\r\n (printout t ?receiver \" received a message\" crlf)\r\n (agent-send-message ?sender ?replyto ?performative ?content ?language ?encoding ?ontology ?protocol ?conversationid)\r\n)\r\n(assert (agent-description (name \"you\") ) )\r\n(assert (agent-message (sender \"me\")(receivers \"you\")(reply-to \"peter\" \"paul\" \"marry\")(performative \"yes\")(content \"hello\")(langauge \"en\")(encoding \"utf8\")(ontology \"none\")(protocol \"1\")(conversationid \"100\") ) )\r\n\r\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"48b8a35920e2691462170530495962f1c6b49c9f","subject":"Added pixel creation operations in rectangle.clp","message":"Added pixel creation operations in rectangle.clp\n","repos":"DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery\/rectangle.clp","new_file":"lib\/chicanery\/rectangle.clp","new_contents":"(defgeneric defrectangle)\n(defgeneric quickrect)\n(defgeneric defpixel)\n(defgeneric pixel:nxn)\n(defgeneric pixel:1x1)\n\n(defclass Rectangle\n (is-a Pointer)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot bx\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Rectangle get-points () \n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n\n(defmethod defrectangle \n \"Creates a new rectangle object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (make-instance ?name of Rectangle \n (x ?x) \n (y ?y)\n (bx ?bx)\n (by ?by)\n (pointer (quickrect ?x ?y ?bx ?by))))\n(defmethod defrectangle\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (defrectangle (gensym*) ?x ?y ?bx ?by))\n\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(defmethod defpixel\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?factor INTEGER))\n (defrectangle ?name ?x ?y (+ ?x ?factor) (+ ?y ?factor)))\n\n(defmethod pixel:nxn\n ((?x INTEGER)\n (?y INTEGER)\n (?n INTEGER))\n (quickrect ?x ?y (+ ?x ?n) (+ ?y ?n)))\n\n(defmethod pixel:nxn\n ((?n INTEGER))\n (pixel:nxn 0 0 ?n))\n\n(defmethod pixel:1x1\n ((?x INTEGER)\n (?y INTEGER))\n (pixel:nxn ?x ?y 1))\n\n(defmethod pixel:1x1 () \n (pixel:1x1 0 0))\n\n(defglobal MAIN \n ?*rect:single-pixel* = (send (defrectangle rect:single-pixel 0 0 1 1) get-pointer))\n","old_contents":"(defgeneric defrectangle)\n(defgeneric quickrect)\n\n(defclass Rectangle\n (is-a Pointer)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot bx\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Rectangle get-points () \n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n\n(defmethod defrectangle \n \"Creates a new rectangle object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (make-instance ?name of Rectangle \n (x ?x) \n (y ?y)\n (bx ?bx)\n (by ?by)\n (pointer (quickrect ?x ?y ?bx ?by))))\n(defmethod defrectangle\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (defrectangle (gensym*) ?x ?y ?bx ?by))\n\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(defglobal MAIN \n ?*rect:single-pixel* = (send (defrectangle rect:single-pixel 0 0 1 1) get-pointer))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"cec3fe66865f81001389c320004f5478c8a6c5df","subject":"Fixed bugs in GLAPIConversion.clp","message":"Fixed bugs in GLAPIConversion.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t (return ?index))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"5fadb62bc039debc4948747a2865e6c65b6b4e7f","subject":"Added the Object class","message":"Added the Object class\n\nThis is the base class of all objects in the project\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/Object.clp","new_file":"modules\/core\/Object.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Base class of all objects \n;------------------------------------------------------------------------------\n(defclass core::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visiblity public) (access initialize-only))\n (slot class (type SYMBOL) (visiblity public) (access initialize-only)))\n\n(defmessage-handler core::Object init around \n\t\t\t\t\t\t \"Initializes the object, setting the id and class of the \n\t\t\t\t\t\t object\" ()\n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;we want to set this information as the last thing before \n\t\t\t\t\t\t ;we return\n\t\t\t\t\t\t (bind ?self:id (instance-name-to-symbol \n\t\t\t\t\t\t\t\t\t\t\t\t(instance-name ?self)))\n\t\t\t\t\t\t (bind ?self:class (class ?self)))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/core\/Object.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0d4ddc8388237a7f507d1a24a0b4b5394382fba9","subject":"Formatting PassRegistry","message":"Formatting PassRegistry\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/PassRegistry.clp","new_file":"lib\/durandal\/passes\/PassRegistry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012-2015, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ([loop-region-merging] of Pass\n (entry-point \"passes\/loop-region-merging\/PassHeader.clp\")\n (pass-name loop-region-merging)\n (pass-description \"Merges the loops and regions of a given function into a single logical CFG.\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes loop-region-merging)\n (required loops regions))\n ([dependency-analysis] of Pass\n (entry-point \"passes\/dependency-analysis\/PassHeader.clp\")\n (pass-name dependency-analysis)\n (pass-description \"Performs dependency analysis between instructions in a function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes dependency-analysis)\n (required loops regions))\n ([wavefront-scheduling] of Pass\n (entry-point \"passes\/wavefront-scheduling\/PassHeader.clp\")\n (pass-name wavefront-scheduling)\n (pass-description \"Performs wavefront scheduling on a target function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes wavefront-scheduling)\n (required loops regions))\n ;Add more passes here\n )\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ([loop-region-merging] of Pass\n (entry-point \"passes\/loop-region-merging\/PassHeader.clp\")\n (pass-name loop-region-merging)\n (pass-description \"Merges the loops and regions of a given function into a single logical CFG.\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes loop-region-merging)\n (required loops regions))\n ([dependency-analysis] of Pass\n (entry-point \"passes\/dependency-analysis\/PassHeader.clp\")\n (pass-name dependency-analysis)\n (pass-description \"Performs dependency analysis between instructions in a function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes dependency-analysis)\n (required loops regions))\n ([wavefront-scheduling] of Pass\n (entry-point \"passes\/wavefront-scheduling\/PassHeader.clp\")\n (pass-name wavefront-scheduling)\n (pass-description \"Performs wavefront scheduling on a target function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes wavefront-scheduling)\n (required loops regions))\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9770907c0f7cd69c18276a84ea6ec473462e748e","subject":"added sample for slot predicate constraints.","message":"added sample for slot predicate constraints.\n\nkhk.\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1098 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/rulecompilertest.clp","new_file":"samples\/rulecompilertest.clp","new_contents":"\n(deftemplate wurst (slot name) (slot spitzname) (slot farbe) )\n(deftemplate salat (slot name) (slot farbe) )\n(deftemplate getraenk (slot name) (slot farbe) )\n\n(assert (wurst (name \"bratwurst\")(spitzname \"bratwosch\")(farbe \"weiss\") ))\n(assert (wurst (name \"weisswurst\")(spitzname \"weisswurst\")(farbe \"weiss\") ))\n(assert (wurst (name \"wienerwurst\")(spitzname \"wiener\")(farbe \"rot\") ))\n(assert (wurst (name \"gemuesewurst\")(spitzname \"gemuesewurst\")(farbe \"gruen\") ))\n(assert (wurst (name \"kartoffelsalat\")(farbe \"pink\") ))\n\n(assert (salat (name \"kartoffelsalat\")(farbe \"weiss\") ))\n\n(assert (getraenk (name \"wasser\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"cola\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"kartoffelsalat\") (farbe \"schwarz\") ))\n\n\n\n(defrule ababab\n\t(salat (farbe ?farbe))\n\t?x <- (wurst (farbe ?farbe))\n=>\n\t(printout t (get-fact-id ?x) crlf )\n)\n(fire)\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (spitzname ?y))\n\t=> (printout t ?x crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n(defrule megarule1\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t=> (printout t \"Es gibt sowohl einen Salat, als auch eine Wurst, die \" ?farbe \"ist.\" crlf)\n)\n\n\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) )\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t(salat (name ?salatname))\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n\n\n(defrule zero\n => (printout t \"boombam\" crlf)\n)\n\n(defrule one\n\t(wurst (name ?x))\n\t=> (printout t \"rule with one condition fired \" ?x crlf)\n)\n\n(defrule two\n\t(wurst (name \"bratwurst\"))\n\t(wurst (farbe \"weiss\"))\n\t=> (printout t \"rule with two conditions fired \" crlf)\n)\n\n(defrule three\n\t(wurst (name \"wienerwurst\"))\n\t=> (printout t \"rule with one condition fired - wienerwurst\" crlf)\n)\n\n(defrule four\n\t?x <- (wurst (name \"wienerwurst\"))\n\t=> \n\t(printout t \"rule with one binding fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule five\n\t?x <- (wurst (name \"wienerwurst\") (gewicht ?y:&(> ?y 111))\n\t=> \n\t(printout t \"rule with one predicate constraint fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule six\n\t?x <- (wurst (gewicht ?y:&(> ?y ?z))\n\t(salat (name \"kartoffelsalat\") (gewicht ?z))\n\t=> \n\t(printout t \"rule with one predicate constraint and an internal join fired\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(fire)","old_contents":"\n(deftemplate wurst (slot name) (slot spitzname) (slot farbe) )\n(deftemplate salat (slot name) (slot farbe) )\n(deftemplate getraenk (slot name) (slot farbe) )\n\n(assert (wurst (name \"bratwurst\")(spitzname \"bratwosch\")(farbe \"weiss\") ))\n(assert (wurst (name \"weisswurst\")(spitzname \"weisswurst\")(farbe \"weiss\") ))\n(assert (wurst (name \"wienerwurst\")(spitzname \"wiener\")(farbe \"rot\") ))\n(assert (wurst (name \"gemuesewurst\")(spitzname \"gemuesewurst\")(farbe \"gruen\") ))\n(assert (wurst (name \"kartoffelsalat\")(farbe \"pink\") ))\n\n(assert (salat (name \"kartoffelsalat\")(farbe \"weiss\") ))\n\n(assert (getraenk (name \"wasser\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"cola\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"kartoffelsalat\") (farbe \"schwarz\") ))\n\n\n\n(defrule ababab\n\t(salat (farbe ?farbe))\n\t?x <- (wurst (farbe ?farbe))\n=>\n\t(printout t (get-fact-id ?x) crlf )\n)\n(fire)\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (spitzname ?y))\n\t=> (printout t ?x crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n(defrule megarule1\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t=> (printout t \"Es gibt sowohl einen Salat, als auch eine Wurst, die \" ?farbe \"ist.\" crlf)\n)\n\n\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) )\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t(salat (name ?salatname))\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n\n(defrule two\n\t(wurst (name \"bratwurst\"))\n\t(wurst (farbe \"weiss\"))\n\t=> (printout t \"rule with two conditions fired \" crlf)\n)\n\n(defrule zero\n => (printout t \"boombam\" crlf)\n)\n\n(defrule one\n\t(wurst (name ?x))\n\t=> (printout t \"rule with one condition fired \" ?x crlf)\n)\n\n(defrule three\n\t(wurst (name \"wienerwurst\"))\n\t=> (printout t \"rule with one condition fired - wienerwurst\" crlf)\n)\n\n;(defrule four\n;\t?x <- (wurst (name \"wienerwurst\"))\n;\t=> \n;\t(printout t \"rule with one binding fired - wienerwurst\" crlf)\n;\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n;)\n\n\n(fire)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"a7bc83c3a22d7c2c767abc9c84bb410a6f549e22","subject":"Cleaned up painter.clp","message":"Cleaned up painter.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery\/pointer.clp)\n(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n(load* \/lib\/chicanery\/rectangle.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n\n(defglobal MAIN\n\t ?*system-initialized* = FALSE)\n\n(deffacts query-operation\n\t (query input)\n\t (defmenu menu1 cut copy paste)\n\t (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n\t (declare (salience 10000))\n\t (initial-fact)\n\t =>\n\t (if (not ?*system-initialized*) then\n\t (eresized 0)\n\t (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n\t (declare (salience 9999))\n\t ?f <- (defmenu ?a $?b)\n\t =>\n\t (retract ?f)\n\t (defmenu ?a ?b))\n\n(defrule on-resized\n\t (declare (salience 1000))\n\t ?f <- (event resized new ?value)\n\t =>\n\t (if (and ?value (< (getwindow) 0)) then\n\t (printout werror \"ERROR: couldn't reattach to window\" crlf)\n\t (exit)\n\t else\n\t (retract ?f)))\n\n(defrule query-input \n\t ?f <- (query input)\n\t =>\n\t (retract ?f)\n\t (mouse\/query)\n\t (assert (input mouse\n\t\t\tbuttons: (translate\/mouse\/buttons)\n\t\t\tposition: (mouse\/position)\n\t\t\ttime-stamp: (mouse\/timestamp))\n\t\t (input keyboard\n\t\t\tbutton: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n\t (declare (salience -1))\n\t ?f <- (input mouse\n\t\t buttons: $?\n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n\t ?f <- (input mouse \n\t\t buttons: button3 \n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t ; Display a menu\n\t (printout t (send [menu1] show-menu 3) crlf)\n\t (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n\t ?f <- (input mouse \n\t\t buttons: button2\n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t ; Display a menu\n\t (printout t (send [menu2] show-menu 2) crlf)\n\t (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n\t (declare (salience 1))\n\t ?f <- (input keyboard \n\t\t button: ESC)\n\t =>\n\t (retract ?f)\n\t (exit))\n\n(defrule process-keyboard-inputs:nil\n\t (declare (salience 1))\n\t ?f <- (input keyboard button: NIL)\n\t =>\n\t (retract ?f)\n\t (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n\t ?f <- (input keyboard\n\t\t button: ?b)\n\t =>\n\t (retract ?f)\n\t (printout t \"Pressed \" ?b crlf)\n\t (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n\t ?f <- (query keyboard)\n\t ?f2 <- (query mouse)\n\t =>\n\t (retract ?f ?f2)\n\t (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"8b9fa67bd5d9277d6eba465db88a83da9bee90be","subject":"Modified the ordering of how files were loaded to fix a bug in glapi conv","message":"Modified the ordering of how files were loaded to fix a bug in glapi conv\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"logic\/tools\/conv\/gl\/glapi\/Entry.clp","new_file":"logic\/tools\/conv\/gl\/glapi\/Entry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads the logic folder for glapi\n;------------------------------------------------------------------------------\n(logic-files \"tools\/conv\/gl\/glapi\"\n \"GLAPIArgumentConversion.clp\"\n \"GLAPIConversion.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads the logic folder for glapi\n;------------------------------------------------------------------------------\n(logic-files \"tools\/conv\/gl\/glapi\"\n \"GLAPIConversion.clp\"\n \"GLAPIArgumentConversion.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"af22f4b2a3dabdc47e31a27bbd52c3af3e449d92","subject":"Add logic to fix tool changer bug.","message":"Add logic to fix tool changer bug.\n\nSigned-off-by: Matt Shaver <1fa2ef4755a9226cb9a0a4840bd89b158ac71391@mattshaver.com>\n","repos":"araisrobo\/machinekit,bobvanderlinden\/machinekit,cdsteinkuehler\/MachineKit,cnc-club\/linuxcnc,narogon\/linuxcnc,narogon\/linuxcnc,aschiffler\/linuxcnc,Cid427\/machinekit,bmwiedemann\/linuxcnc-mirror,bmwiedemann\/linuxcnc-mirror,unseenlaser\/linuxcnc,cdsteinkuehler\/linuxcnc,bobvanderlinden\/machinekit,aschiffler\/linuxcnc,narogon\/linuxcnc,ArcEye\/MK-Qt5,ArcEye\/machinekit-testing,unseenlaser\/linuxcnc,ArcEye\/MK-Qt5,Cid427\/machinekit,RunningLight\/machinekit,ArcEye\/MK-Qt5,mhaberler\/machinekit,EqAfrica\/machinekit,mhaberler\/machinekit,ikcalB\/linuxcnc-mirror,unseenlaser\/machinekit,bmwiedemann\/linuxcnc-mirror,unseenlaser\/machinekit,kinsamanka\/machinekit,cdsteinkuehler\/MachineKit,bobvanderlinden\/machinekit,unseenlaser\/machinekit,unseenlaser\/linuxcnc,strahlex\/machinekit,ArcEye\/machinekit-testing,araisrobo\/machinekit,RunningLight\/machinekit,mhaberler\/machinekit,unseenlaser\/machinekit,Cid427\/machinekit,strahlex\/machinekit,kinsamanka\/machinekit,cdsteinkuehler\/linuxcnc,unseenlaser\/machinekit,Cid427\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,araisrobo\/linuxcnc,araisrobo\/machinekit,cdsteinkuehler\/MachineKit,cnc-club\/linuxcnc,kinsamanka\/machinekit,ArcEye\/MK-Qt5,aschiffler\/linuxcnc,mhaberler\/machinekit,ikcalB\/linuxcnc-mirror,cdsteinkuehler\/linuxcnc,cnc-club\/linuxcnc,jaguarcat79\/ILC-with-LinuxCNC,ikcalB\/linuxcnc-mirror,ArcEye\/machinekit-testing,EqAfrica\/machinekit,EqAfrica\/machinekit,RunningLight\/machinekit,RunningLight\/machinekit,cdsteinkuehler\/MachineKit,aschiffler\/linuxcnc,ianmcmahon\/linuxcnc-mirror,ikcalB\/linuxcnc-mirror,cdsteinkuehler\/MachineKit,araisrobo\/machinekit,cdsteinkuehler\/linuxcnc,cdsteinkuehler\/MachineKit,Cid427\/machinekit,araisrobo\/machinekit,Cid427\/machinekit,EqAfrica\/machinekit,unseenlaser\/linuxcnc,ikcalB\/linuxcnc-mirror,kinsamanka\/machinekit,unseenlaser\/machinekit,EqAfrica\/machinekit,RunningLight\/machinekit,unseenlaser\/machinekit,ianmcmahon\/linuxcnc-mirror,cnc-club\/linuxcnc,kinsamanka\/machinekit,araisrobo\/machinekit,RunningLight\/machinekit,bobvanderlinden\/machinekit,strahlex\/machinekit,mhaberler\/machinekit,kinsamanka\/machinekit,bobvanderlinden\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,EqAfrica\/machinekit,araisrobo\/machinekit,bmwiedemann\/linuxcnc-mirror,cnc-club\/linuxcnc,ArcEye\/machinekit-testing,narogon\/linuxcnc,cnc-club\/linuxcnc,ianmcmahon\/linuxcnc-mirror,bmwiedemann\/linuxcnc-mirror,RunningLight\/machinekit,bmwiedemann\/linuxcnc-mirror,ArcEye\/MK-Qt5,strahlex\/machinekit,mhaberler\/machinekit,narogon\/linuxcnc,ikcalB\/linuxcnc-mirror,ianmcmahon\/linuxcnc-mirror,ianmcmahon\/linuxcnc-mirror,ArcEye\/MK-Qt5,unseenlaser\/machinekit,cdsteinkuehler\/linuxcnc,ianmcmahon\/linuxcnc-mirror,kinsamanka\/machinekit,RunningLight\/machinekit,Cid427\/machinekit,EqAfrica\/machinekit,araisrobo\/machinekit,strahlex\/machinekit,strahlex\/machinekit,cdsteinkuehler\/linuxcnc,mhaberler\/machinekit,ArcEye\/machinekit-testing,araisrobo\/linuxcnc,kinsamanka\/machinekit,aschiffler\/linuxcnc,jaguarcat79\/ILC-with-LinuxCNC,araisrobo\/linuxcnc,jaguarcat79\/ILC-with-LinuxCNC,ArcEye\/MK-Qt5,strahlex\/machinekit,ArcEye\/machinekit-testing,araisrobo\/linuxcnc,ikcalB\/linuxcnc-mirror,bobvanderlinden\/machinekit,araisrobo\/machinekit,ianmcmahon\/linuxcnc-mirror,ArcEye\/MK-Qt5,ArcEye\/machinekit-testing,EqAfrica\/machinekit,bobvanderlinden\/machinekit,cnc-club\/linuxcnc,Cid427\/machinekit,bobvanderlinden\/machinekit,araisrobo\/linuxcnc,mhaberler\/machinekit,bmwiedemann\/linuxcnc-mirror,unseenlaser\/linuxcnc,ArcEye\/machinekit-testing","old_file":"configs\/smithy\/924.clp","new_file":"configs\/smithy\/924.clp","new_contents":"_FILES_CLASSICLADDER\n_FILE-monostables.csv\n1,1\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-monostables.csv\n_FILE-general.txt\nPERIODIC_REFRESH=1\nSIZE_NBR_RUNGS=100\nSIZE_NBR_BITS=20\nSIZE_NBR_WORDS=20\nSIZE_NBR_TIMERS=10\nSIZE_NBR_MONOSTABLES=10\nSIZE_NBR_COUNTERS=10\nSIZE_NBR_TIMERS_IEC=10\nSIZE_NBR_PHYS_INPUTS=15\nSIZE_NBR_PHYS_OUTPUTS=15\nSIZE_NBR_ARITHM_EXPR=100\nSIZE_NBR_SECTIONS=10\nSIZE_NBR_SYMBOLS=160\n_\/FILE-general.txt\n_FILE-rung_1.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=3\n#NEXTRUNG=-1\n9-0-0\/0 , 1-0-50\/0 , 9-0-0\/0 , 2-0-0\/0 , 9-0-0\/0 , 2-0-0\/3 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/1\n1-0-50\/0 , 9-0-0\/0 , 1-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/0\n9-0-0\/0 , 4-0-60\/1 , 9-0-0\/0 , 9-1-0\/0 , 99-0-0\/0 , 11-0-60\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/2\n1-0-50\/0 , 9-0-0\/0 , 1-0-0\/3 , 0-1-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n9-0-0\/0 , 4-0-60\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 52-0-60\/0\n9-0-0\/0 , 3-0-50\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 53-0-60\/0\n_\/FILE-rung_1.csv\n_FILE-sections.csv\n#VER=1.0\n#NAME000=Prog1\n000,0,-1,2,1,0\n_\/FILE-sections.csv\n_FILE-modbusioconf.csv\n#VER=1.0\n_\/FILE-modbusioconf.csv\n_FILE-arithmetic_expressions.csv\n#VER=2.0\n0000,(@270\/0@-1)&3=@200\/1@\n0001,@270\/0@=0\n0004,@200\/1@=1\n0005,@200\/1@=0\n0006,@200\/1@=2\n0007,@200\/1@=3\n_\/FILE-arithmetic_expressions.csv\n_FILE-com_params.txt\nMODBUS_MASTER_SERIAL_PORT=\nMODBUS_MASTER_SERIAL_SPEED=9600\nMODBUS_MASTER_SERIAL_DATABITS=8\nMODBUS_MASTER_SERIAL_STOPBITS=1\nMODBUS_MASTER_SERIAL_PARITY=0\nMODBUS_ELEMENT_OFFSET=0\nMODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0\nMODBUS_MASTER_TIME_INTER_FRAME=100\nMODBUS_MASTER_TIME_OUT_RECEIPT=500\nMODBUS_MASTER_TIME_AFTER_TRANSMIT=0\nMODBUS_DEBUG_LEVEL=0\nMODBUS_MAP_COIL_READ=0\nMODBUS_MAP_COIL_WRITE=0\nMODBUS_MAP_INPUT=0\nMODBUS_MAP_HOLDING=0\nMODBUS_MAP_REGISTER_READ=0\nMODBUS_MAP_REGISTER_WRITE=0\n_\/FILE-com_params.txt\n_FILE-counters.csv\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n_\/FILE-counters.csv\n_FILE-timers.csv\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-timers.csv\n_FILE-sequential.csv\n#VER=1.0\n_\/FILE-sequential.csv\n_FILE-ioconf.csv\n#VER=1.0\n_\/FILE-ioconf.csv\n_FILE-rung_3.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=2\n#NEXTRUNG=1\n9-0-0\/0 , 1-0-50\/1 , 1-0-50\/2 , 1-0-50\/3 , 1-0-50\/4 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/2\n9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 20-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/3\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n1-0-50\/5 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/3\n_\/FILE-rung_3.csv\n_FILE-timers_iec.csv\n1,15,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n_\/FILE-timers_iec.csv\n_FILE-symbols.csv\n#VER=1.0\n%Q1,TPFWD,\n%Q2,TPREV,\n%Q0,TCACK,\n%B0,TPINPOS,\n%I0,TCREQ,\n%I1,T1,\n%I2,T2,\n%I3,T3,\n%I4,T4,\n%IW0,PREPNO,\n%W1,TPOS,\n%B1,TPUP,\n%B2,TPROT,\n%B3,T0,\n%I5,TP,\n%I6,%I6,\n%I7,%I7,\n%I8,%I8,\n%I9,%I9,\n%I10,%I10,\n%I11,%I11,\n%I12,%I12,\n%I13,%I13,\n%I14,%I14,\n%Q3,TQ,\n%Q4,%Q4,\n%Q5,%Q5,\n%Q6,%Q6,\n%Q7,%Q7,\n%Q8,%Q8,\n%Q9,%Q9,\n%Q10,%Q10,\n%Q11,%Q11,\n%Q12,%Q12,\n%Q13,%Q13,\n%Q14,%Q14,\n%B4,%B4,\n%B5,%B5,\n%B6,%B6,\n%B7,%B7,\n%B8,%B8,\n%B9,%B9,\n%B10,%B10,\n%B11,%B11,\n%B12,%B12,\n%B13,%B13,\n%B14,%B14,\n%B15,%B15,\n%B16,%B16,\n%B17,%B17,\n%B18,%B18,\n%B19,%B19,\n%W0,%W0,\n%W2,%W2,\n%W3,%W3,\n%W4,%W4,\n%W5,%W5,\n%W6,%W6,\n%W7,%W7,\n%W8,%W8,\n%W9,%W9,\n%W10,%W10,\n%W11,%W11,\n%W12,%W12,\n%W13,%W13,\n%W14,%W14,\n%W15,%W15,\n%W16,%W16,\n%W17,%W17,\n%W18,%W18,\n%W19,%W19,\n%IW1,%IW1,\n%IW2,%IW2,\n%IW3,%IW3,\n%IW4,%IW4,\n%IW5,%IW5,\n%IW6,%IW6,\n%IW7,%IW7,\n%IW8,%IW8,\n%IW9,%IW9,\n%QW0,%QW0,\n%QW1,%QW1,\n%QW2,%QW2,\n%QW3,%QW3,\n%QW4,%QW4,\n%QW5,%QW5,\n%QW6,%QW6,\n%QW7,%QW7,\n%QW8,%QW8,\n%QW9,%QW9,\n%IF0,%IF0,\n%IF1,%IF1,\n%IF2,%IF2,\n%IF3,%IF3,\n%IF4,%IF4,\n%IF5,%IF5,\n%IF6,%IF6,\n%IF7,%IF7,\n%IF8,%IF8,\n%IF9,%IF9,\n%QF0,%QF0,\n%QF1,%QF1,\n%QF2,%QF2,\n%QF3,%QF3,\n%QF4,%QF4,\n%QF5,%QF5,\n%QF6,%QF6,\n%QF7,%QF7,\n%QF8,%QF8,\n%QF9,%QF9,\n%T0,%T0,Old Timer\n%T1,%T1,Old Timer\n%T2,%T2,Old Timer\n%T3,%T3,Old Timer\n%T4,%T4,Old Timer\n%T5,%T5,Old Timer\n%T6,%T6,Old Timer\n%T7,%T7,Old Timer\n%T8,%T8,Old Timer\n%T9,%T9,Old Timer\n%TM0,%TM0,New Timer\n%TM1,%TM1,New Timer\n%TM2,%TM2,New Timer\n%TM3,%TM3,New Timer\n%TM4,%TM4,New Timer\n%TM5,%TM5,New Timer\n%TM6,%TM6,New Timer\n%TM7,%TM7,New Timer\n%TM8,%TM8,New Timer\n%TM9,%TM9,New Timer\n%M0,%M0,One-shot\n%M1,%M1,One-shot\n%M2,%M2,One-shot\n%M3,%M3,One-shot\n%M4,%M4,One-shot\n%M5,%M5,One-shot\n%M6,%M6,One-shot\n%M7,%M7,One-shot\n%M8,%M8,One-shot\n%M9,%M9,One-shot\n%C0,%C0,Counter\n%C1,%C1,Counter\n%C2,%C2,Counter\n%C3,%C3,Counter\n%C4,%C4,Counter\n%C5,%C5,Counter\n%C6,%C6,Counter\n%C7,%C7,Counter\n%C8,%C8,Counter\n%C9,%C9,Counter\n%E0,%E0,Error Flag Bit\n%E1,%E1,Error Flag Bit\n%E2,%E2,Error Flag Bit\n%E3,%E3,Error Flag Bit\n%E4,%E4,Error Flag Bit\n%E5,%E5,Error Flag Bit\n%E6,%E6,Error Flag Bit\n%E7,%E7,Error Flag Bit\n%E8,%E8,Error Flag Bit\n%E9,%E9,Error Flag Bit\n_\/FILE-symbols.csv\n_FILE-rung_2.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=-1\n#NEXTRUNG=3\n9-0-0\/0 , 2-0-50\/1 , 1-0-50\/2 , 1-0-50\/3 , 1-0-50\/4 , 2-0-0\/3 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/5\n9-0-0\/0 , 2-0-50\/2 , 1-0-50\/1 , 1-0-50\/3 , 1-0-50\/4 , 2-0-0\/3 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/4\n9-0-0\/0 , 2-0-50\/3 , 1-0-50\/1 , 1-0-50\/2 , 1-0-50\/4 , 2-0-0\/3 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/6\n9-0-0\/0 , 2-0-50\/4 , 1-0-50\/1 , 1-0-50\/2 , 1-0-50\/3 , 2-0-0\/3 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/7\n9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 20-0-0\/0 , 9-0-0\/0 , 2-0-0\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/0\n9-0-0\/0 , 9-0-50\/0 , 1-0-0\/3 , 9-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/1\n_\/FILE-rung_2.csv\n_\/FILES_CLASSICLADDER\n","old_contents":"_FILES_CLASSICLADDER\n_FILE-timers.csv\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-timers.csv\n_FILE-rung_1.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=3\n#NEXTRUNG=-1\n9-0-0\/0 , 1-0-50\/0 , 9-0-0\/0 , 2-0-0\/0 , 9-0-0\/0 , 2-0-0\/3 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/1\n1-0-50\/0 , 9-0-0\/0 , 1-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/0\n9-0-0\/0 , 4-0-60\/1 , 9-0-0\/0 , 9-1-0\/0 , 99-0-0\/0 , 11-0-60\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/2\n1-0-50\/0 , 9-0-0\/0 , 1-0-0\/3 , 0-1-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n9-0-0\/0 , 4-0-60\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 52-0-60\/0\n9-0-0\/0 , 3-0-50\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 53-0-60\/0\n_\/FILE-rung_1.csv\n_FILE-symbols.csv\n#VER=1.0\n%Q1,TPFWD,\n%Q2,TPREV,\n%Q0,TCACK,\n%B0,TPINPOS,\n%I0,TCREQ,\n%I1,T1,\n%I2,T2,\n%I3,T3,\n%I4,T4,\n%IW0,PREPNO,\n%W1,TPOS,\n%B1,TPUP,\n%B2,TPROT,\n%B3,T0,\n%I5,TP,\n%I6,%I6,\n%I7,%I7,\n%I8,%I8,\n%I9,%I9,\n%I10,%I10,\n%I11,%I11,\n%I12,%I12,\n%I13,%I13,\n%I14,%I14,\n%Q3,TQ,\n%Q4,%Q4,\n%Q5,%Q5,\n%Q6,%Q6,\n%Q7,%Q7,\n%Q8,%Q8,\n%Q9,%Q9,\n%Q10,%Q10,\n%Q11,%Q11,\n%Q12,%Q12,\n%Q13,%Q13,\n%Q14,%Q14,\n%B4,%B4,\n%B5,%B5,\n%B6,%B6,\n%B7,%B7,\n%B8,%B8,\n%B9,%B9,\n%B10,%B10,\n%B11,%B11,\n%B12,%B12,\n%B13,%B13,\n%B14,%B14,\n%B15,%B15,\n%B16,%B16,\n%B17,%B17,\n%B18,%B18,\n%B19,%B19,\n%W0,%W0,\n%W2,%W2,\n%W3,%W3,\n%W4,%W4,\n%W5,%W5,\n%W6,%W6,\n%W7,%W7,\n%W8,%W8,\n%W9,%W9,\n%W10,%W10,\n%W11,%W11,\n%W12,%W12,\n%W13,%W13,\n%W14,%W14,\n%W15,%W15,\n%W16,%W16,\n%W17,%W17,\n%W18,%W18,\n%W19,%W19,\n%IW1,%IW1,\n%IW2,%IW2,\n%IW3,%IW3,\n%IW4,%IW4,\n%IW5,%IW5,\n%IW6,%IW6,\n%IW7,%IW7,\n%IW8,%IW8,\n%IW9,%IW9,\n%QW0,%QW0,\n%QW1,%QW1,\n%QW2,%QW2,\n%QW3,%QW3,\n%QW4,%QW4,\n%QW5,%QW5,\n%QW6,%QW6,\n%QW7,%QW7,\n%QW8,%QW8,\n%QW9,%QW9,\n%IF0,%IF0,\n%IF1,%IF1,\n%IF2,%IF2,\n%IF3,%IF3,\n%IF4,%IF4,\n%IF5,%IF5,\n%IF6,%IF6,\n%IF7,%IF7,\n%IF8,%IF8,\n%IF9,%IF9,\n%QF0,%QF0,\n%QF1,%QF1,\n%QF2,%QF2,\n%QF3,%QF3,\n%QF4,%QF4,\n%QF5,%QF5,\n%QF6,%QF6,\n%QF7,%QF7,\n%QF8,%QF8,\n%QF9,%QF9,\n%T0,%T0,Old Timer\n%T1,%T1,Old Timer\n%T2,%T2,Old Timer\n%T3,%T3,Old Timer\n%T4,%T4,Old Timer\n%T5,%T5,Old Timer\n%T6,%T6,Old Timer\n%T7,%T7,Old Timer\n%T8,%T8,Old Timer\n%T9,%T9,Old Timer\n%TM0,%TM0,New Timer\n%TM1,%TM1,New Timer\n%TM2,%TM2,New Timer\n%TM3,%TM3,New Timer\n%TM4,%TM4,New Timer\n%TM5,%TM5,New Timer\n%TM6,%TM6,New Timer\n%TM7,%TM7,New Timer\n%TM8,%TM8,New Timer\n%TM9,%TM9,New Timer\n%M0,%M0,One-shot\n%M1,%M1,One-shot\n%M2,%M2,One-shot\n%M3,%M3,One-shot\n%M4,%M4,One-shot\n%M5,%M5,One-shot\n%M6,%M6,One-shot\n%M7,%M7,One-shot\n%M8,%M8,One-shot\n%M9,%M9,One-shot\n%C0,%C0,Counter\n%C1,%C1,Counter\n%C2,%C2,Counter\n%C3,%C3,Counter\n%C4,%C4,Counter\n%C5,%C5,Counter\n%C6,%C6,Counter\n%C7,%C7,Counter\n%C8,%C8,Counter\n%C9,%C9,Counter\n%E0,%E0,Error Flag Bit\n%E1,%E1,Error Flag Bit\n%E2,%E2,Error Flag Bit\n%E3,%E3,Error Flag Bit\n%E4,%E4,Error Flag Bit\n%E5,%E5,Error Flag Bit\n%E6,%E6,Error Flag Bit\n%E7,%E7,Error Flag Bit\n%E8,%E8,Error Flag Bit\n%E9,%E9,Error Flag Bit\n_\/FILE-symbols.csv\n_FILE-counters.csv\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n_\/FILE-counters.csv\n_FILE-rung_2.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=-1\n#NEXTRUNG=3\n9-0-0\/0 , 2-0-50\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/5\n9-0-0\/0 , 2-0-50\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/4\n9-0-0\/0 , 2-0-50\/3 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/6\n9-0-0\/0 , 2-0-50\/4 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/7\n9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 20-0-0\/0 , 9-0-0\/0 , 2-0-0\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/0\n9-0-0\/0 , 9-0-50\/0 , 1-0-0\/3 , 9-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/1\n_\/FILE-rung_2.csv\n_FILE-com_params.txt\nMODBUS_MASTER_SERIAL_PORT=\nMODBUS_MASTER_SERIAL_SPEED=9600\nMODBUS_MASTER_SERIAL_DATABITS=8\nMODBUS_MASTER_SERIAL_STOPBITS=1\nMODBUS_MASTER_SERIAL_PARITY=0\nMODBUS_ELEMENT_OFFSET=0\nMODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0\nMODBUS_MASTER_TIME_INTER_FRAME=100\nMODBUS_MASTER_TIME_OUT_RECEIPT=500\nMODBUS_MASTER_TIME_AFTER_TRANSMIT=0\nMODBUS_DEBUG_LEVEL=0\nMODBUS_MAP_COIL_READ=0\nMODBUS_MAP_COIL_WRITE=0\nMODBUS_MAP_INPUT=0\nMODBUS_MAP_HOLDING=0\nMODBUS_MAP_REGISTER_READ=0\nMODBUS_MAP_REGISTER_WRITE=0\n_\/FILE-com_params.txt\n_FILE-sections.csv\n#VER=1.0\n#NAME000=Prog1\n000,0,-1,2,1,0\n_\/FILE-sections.csv\n_FILE-monostables.csv\n1,1\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-monostables.csv\n_FILE-modbusioconf.csv\n#VER=1.0\n_\/FILE-modbusioconf.csv\n_FILE-ioconf.csv\n#VER=1.0\n_\/FILE-ioconf.csv\n_FILE-arithmetic_expressions.csv\n#VER=2.0\n0000,(@270\/0@-1)&3=@200\/1@\n0001,@270\/0@=0\n0004,@200\/1@=1\n0005,@200\/1@=0\n0006,@200\/1@=2\n0007,@200\/1@=3\n_\/FILE-arithmetic_expressions.csv\n_FILE-sequential.csv\n#VER=1.0\n_\/FILE-sequential.csv\n_FILE-rung_3.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=2\n#NEXTRUNG=1\n9-0-0\/0 , 1-0-50\/1 , 1-0-50\/2 , 1-0-50\/3 , 1-0-50\/4 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/2\n9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 20-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/3\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n1-0-50\/5 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/3\n_\/FILE-rung_3.csv\n_FILE-timers_iec.csv\n1,15,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n_\/FILE-timers_iec.csv\n_FILE-general.txt\nPERIODIC_REFRESH=1\nSIZE_NBR_RUNGS=100\nSIZE_NBR_BITS=20\nSIZE_NBR_WORDS=20\nSIZE_NBR_TIMERS=10\nSIZE_NBR_MONOSTABLES=10\nSIZE_NBR_COUNTERS=10\nSIZE_NBR_TIMERS_IEC=10\nSIZE_NBR_PHYS_INPUTS=15\nSIZE_NBR_PHYS_OUTPUTS=15\nSIZE_NBR_ARITHM_EXPR=100\nSIZE_NBR_SECTIONS=10\nSIZE_NBR_SYMBOLS=160\n_\/FILE-general.txt\n_\/FILES_CLASSICLADDER\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"1905ab21cfd86c61a5e8b64c3cae5714c8e042d2","subject":"advester","message":"advester\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"adveser.clp","new_file":"adveser.clp","new_contents":"(reset)\n\n(defrule go-rule-1\n =>\n (printout t \"What sort of environment is a trainee dealing with on the job? \" crlf)\n (bind ?e (read))\n (assert (environment ?e))\n (printout t \"What sort of job is the trainee do? \" crlf)\n (bind ?e (read))\n (assert (job ?e))\n (printout t \"Is the feedback required or not? (yes \/ no)\" crlf)\n (bind ?e (read))\n (assert (feedback ?e))\n (run)\n)\n\n\n\n(defrule rule_1\n (environment papers | manuals | documents | textbooks)\n =>\n (assert (stimulus-situation verbal))\n)\n\n(defrule rule_2\n (environment pictures | illustrations | photographs | diagrams)\n =>\n (assert (stimulus-situation visual))\n)\n\n\n(defrule rule_3\n (environment machines | buildings | tools)\n =>\n (assert (stimulus-situation 'physical objects'))\n)\n\n\n(defrule rule_4\n (environment numbers | formulas | cumputer programs)\n =>\n (assert (stimulus-situation symbolic))\n)\n\n\n(defrule rule_5\n (job lecturing | advising | counselling)\n =>\n (assert (stimulus-response oral))\n)\n\n\n(defrule rule_6\n (job building | repairing | troubleshooting)\n =>\n (assert (stimulus-response 'hands on'))\n)\n\n\n(defrule rule_7\n (job typing | writing | drawing)\n =>\n (assert (stimulus-response documented))\n)\n\n\n(defrule rule_8\n (job evlauating | reasoning | investigating)\n =>\n (assert (stimulus-response analytical))\n)\n\n(defrule rule_9\n (and (stimulus-situation 'physical objects')\n (stimulus-response 'hands on')\n (feedback yes)\n )\n =>\n (assert (medium workshop))\n)\n\n\n(defrule rule_10\n (and (stimulus-situation symbolic)\n (stimulus-response analytical)\n (feedback yes)\n )\n =>\n (assert (medium 'lecture-tutorial'))\n)\n\n\n(defrule rule_11\n (and (stimulus-situation visual)\n (stimulus-response oral)\n (feedback no)\n )\n =>\n (assert (medium 'lecture-tutorial'))\n)\n\n\n(defrule rule_12\n (and (stimulus-situation visual)\n (stimulus-response analytical)\n (feedback yes)\n )\n =>\n (assert (medium 'lecture-tutorial'))\n)\n\n\n(defrule rule_13\n (and (stimulus-situation visual)\n (stimulus-response oral)\n (feedback yes)\n )\n =>\n (assert (medium 'role-play exercises'))\n)\n\n\n(defrule rule_14\n (and (stimulus-situation verbal)\n (stimulus-response documented)\n (feedback yes)\n )\n =>\n (assert (medium videocassette))\n)","old_contents":"","returncode":1,"stderr":"error: pathspec 'adveser.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"5c3f85ae47afd52bd00cc47212e590f4d8255dd0","subject":"RunConstantConverter.clp: Updated the script to use the new layout","message":"RunConstantConverter.clp: Updated the script to use the new layout\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/AdventureEngine","old_file":"RunConstantConverter.clp","new_file":"RunConstantConverter.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunConverter.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"LoadEngine.clp\")\n(load-application \"tools\/conv\/gl\/constant\")\n(reset)\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\"))\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunConverter.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"lib\/cortex\/Library.clp\")\n(batch* \"tools\/conv\/gl\/constant\/ConstantConversionEntry.clp\")\n(reset)\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\"))\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"bd88067ededa839f5d3cb6d5803ff78e75e27ba8","subject":"Removed a return call from the is-root-panel handler","message":"Removed a return call from the is-root-panel handler\n\nIt isn't necessary and only serves to add a bit of overhead for no real benefit\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron","old_file":"System\/Runtime\/Panel.clp","new_file":"System\/Runtime\/Panel.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Panel.clp - Represents a container of widgets and tiles\n;------------------------------------------------------------------------------\n(defclass Runtime::Panel \n \"A component that holds other widgets and tiles\"\n (is-a Component)\n (role concrete)\n (pattern-match reactive)\n (multislot child-components \n (type INSTANCE))\n (message-handler is-root-panel primary))\n;------------------------------------------------------------------------------\n(defmessage-handler Runtime::Panel is-root-panel primary\n \"Checks to see if the target panel is the root panel\"\n ()\n (eq ?self:parent nil))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Panel.clp - Represents a container of widgets and tiles\n;------------------------------------------------------------------------------\n(defclass Runtime::Panel \n \"A component that holds other widgets and tiles\"\n (is-a Component)\n (role concrete)\n (pattern-match reactive)\n (multislot child-components \n (type INSTANCE))\n (message-handler is-root-panel primary))\n;------------------------------------------------------------------------------\n(defmessage-handler Runtime::Panel is-root-panel primary\n \"Checks to see if the target panel is the root panel\"\n ()\n (return (eq ?self:parent nil)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"8d60af39a1ea960e3a4fb8b33535de2995e06479","subject":"Simplified the facts asserted in ProducersPropagaion.clp","message":"Simplified the facts asserted in ProducersPropagaion.clp\n\nThis should speed up the matching of rules in the network.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/ProducersPropagation.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/ProducersPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateBlockProducers\n\t\t\t(object (is-a BasicBlock) (parent ?r) \n\t\t\t\t\t (Produces $?produces))\n\t\t\t=>\n\t\t\t(assert (Give ?r the following produced items $?produces)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentExists\n\t\t\t?fct <- (Give ?r the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(exists (object (is-a Region) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Give ?p the following produced items $?produced))\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentDoesntExist\n\t\t\t?fct <- (Give ?r the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(not (exists (object (is-a Region) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::IdentifyNonLocalDependencies\n\t\t\t?i0 <- (object (is-a Instruction) (parent ?p) (Operands $? ?op $?))\n\t\t\t(object (is-a ParentedObject) (id ?op) (parent ~?p))\n\t\t\t;(test (not (member$ ?op (send ?i0 get-NonLocalDependencies))))\n\t\t\t=>\n\t\t\t;since we don't copy the set of producers at the start anymore we\n\t\t\t;need this operation as well\n\t\t\t(slot-insert$ ?i0 Producers 1 ?op)\n\t\t\t(slot-insert$ ?i0 NonLocalDependencies 1 ?op))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateBlockProducers\n\t\t\t(object (is-a BasicBlock) (id ?b) (parent ?r) \n\t\t\t\t\t (Produces $?produces))\n\t\t\t=>\n\t\t\t(assert (Give ?r from ?b the following produced items $?produces)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentExists\n\t\t\t?fct <- (Give ?r from ? the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(exists (object (is-a Region) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Give ?p from ?r the following produced items $?produced))\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::PropagateRegionProducers-ParentDoesntExist\n\t\t\t?fct <- (Give ?r from ? the following produced items $?produced)\n\t\t\t?region <- (object (is-a Region) (id ?r) (parent ?p))\n\t\t\t(not (exists (object (is-a Region) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(slot-insert$ ?region Produces 1 ?produced))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-modification-propagation::IdentifyNonLocalDependencies\n\t\t\t?i0 <- (object (is-a Instruction) (parent ?p) (id ?t0) \n\t\t\t\t\t\t\t\t(Operands $? ?op $?))\n\t\t\t(object (is-a ParentedObject) (id ?op) (parent ~?p))\n\t\t\t;(test (not (member$ ?op (send ?i0 get-NonLocalDependencies))))\n\t\t\t=>\n\t\t\t;since we don't copy the set of producers at the start anymore we\n\t\t\t;need this operation as well\n\t\t\t(slot-insert$ ?i0 Producers 1 ?op)\n\t\t\t(slot-insert$ ?i0 NonLocalDependencies 1 ?op))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ff709613a767e1a3590f12fd3d69b3cb5f288ad6","subject":"Fix typo in encoding-0.clp","message":"Fix typo in encoding-0.clp\n","repos":"tortinator\/asprilo","old_file":"mppd\/encoding-0.clp","new_file":"mppd\/encoding-0.clp","new_contents":"% = MPPD DOMAIN: CLINGCON ENCODING =================================================================\n\n% Move actions\n#include \".\/action-MPP.clp\".\n\n% Order fulfillment (Goal condition)\n#include \".\/goal-D-0.clp\".\n\n% Highway constraints\n#include \"..\/control\/highways.clp\".\n\n% Output conversion\n#include \".\/output-MPPD.lp\".\n","old_contents":"% = MPPD DOMAIN: CLINGCON ENCODING =================================================================\n\n% Move actions\n#include \".\/action-MPP.clp\".\n\n% Order fulfillment (Goal condition)\n#include \".\/goal-D-0.clp\n\n% Highway constraints\n#include \"..\/control\/highways.clp\".\n\n% Output conversion\n#include \".\/output-MPPD.lp\".\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"d67102d73d8523d7f710a7c156ae91c42e84237f","subject":"adding an example for testing the fact extension for temporal facts peter","message":"adding an example for testing the fact extension for temporal facts\npeter\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@422 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/temporal_test1.clp","new_file":"samples\/temporal_test1.clp","new_contents":"(deftemplate transaction\r\n (slot accountId (type STRING))\r\n (slot buyPrice (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n (slot currentPrice (type DOUBLE))\r\n (slot cusip (type INTEGER))\r\n (slot exchange (type STRING))\r\n (slot industryGroupID (type INTEGER))\r\n (slot industryID (type INTEGER))\r\n (slot issuer (type STRING))\r\n (slot lastPrice (type DOUBLE))\r\n (slot purchaseDate (type STRING))\r\n (slot sectorID (type INTEGER))\r\n (slot shares (type DOUBLE))\r\n (slot subIndustryID (type INTEGER))\r\n (slot total (type DOUBLE))\r\n)\r\n(deftemplate account\r\n (slot accountId (type STRING))\r\n (slot cash (type DOUBLE))\r\n (slot fixedIncome (type DOUBLE))\r\n (slot stocks (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n)\r\n(defrule joinrule1\r\n (transaction\r\n (accountId ?accid)\r\n (countryCode \"US\")\r\n (total ?tl&:(< ?tl 10000.00))\r\n )\r\n (account\r\n (accountId ?accid)\r\n (cash ?c&:(> ?c 1000000))\r\n )\r\n=>\r\n (printout t \"joinrule1 was fired\" crlf)\r\n)\r\n\r\n(assert-temporal (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(expiration-time 111111)(source \"http:\/\/this.com\/\")(service-type \"http\")(validity 20) ) )\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/temporal_test1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"1e6861e98b50f7a6240d2f0884b23d5643d6d0ea","subject":"changed the sequence of the asserts slightly to debug why the rules won't fire after the refactoring. peter","message":"changed the sequence of the asserts slightly to debug why the rules won't fire after the refactoring.\npeter\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@519 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/join_sample15.clp","new_file":"samples\/join_sample15.clp","new_contents":"(deftemplate transaction\r\n (slot accountId (type STRING))\r\n (slot buyPrice (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n (slot currentPrice (type DOUBLE))\r\n (slot cusip (type INTEGER))\r\n (slot exchange (type STRING))\r\n (slot industryGroupID (type INTEGER))\r\n (slot industryID (type INTEGER))\r\n (slot issuer (type STRING))\r\n (slot lastPrice (type DOUBLE))\r\n (slot purchaseDate (type STRING))\r\n (slot sectorID (type INTEGER))\r\n (slot shares (type DOUBLE))\r\n (slot subIndustryID (type INTEGER))\r\n (slot total (type DOUBLE))\r\n)\r\n(deftemplate account\r\n (slot accountId (type STRING))\r\n (slot cash (type DOUBLE))\r\n (slot fixedIncome (type DOUBLE))\r\n (slot stocks (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n)\r\n(deftemplate rating\r\n (slot cusip (type INTEGER))\r\n (slot issuer (type STRING))\r\n)\r\n(defrule joinrule2\r\n (transaction\r\n (accountId ?accid)\r\n (countryCode \"US\")\r\n (issuer ?iss)\r\n )\r\n (rating\r\n (issuer ?iss)\r\n )\r\n (account\r\n (accountId ?accid)\r\n )\r\n=>\r\n (printout t \"joinrule2 was fired\" )\r\n)\r\n(assert (rating (cusip 10101025)(issuer \"MSFT\") ) )\r\n(assert (rating (cusip 10101020)(issuer \"IBM\") ) )\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101015)(issuer \"MSFT\") ) )\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101010)(issuer \"IBM\") ) )\r\n(assert (account (accountId \"acc1\")(cash 1200000) ) )\r\n","old_contents":"(deftemplate transaction\r\n (slot accountId (type STRING))\r\n (slot buyPrice (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n (slot currentPrice (type DOUBLE))\r\n (slot cusip (type INTEGER))\r\n (slot exchange (type STRING))\r\n (slot industryGroupID (type INTEGER))\r\n (slot industryID (type INTEGER))\r\n (slot issuer (type STRING))\r\n (slot lastPrice (type DOUBLE))\r\n (slot purchaseDate (type STRING))\r\n (slot sectorID (type INTEGER))\r\n (slot shares (type DOUBLE))\r\n (slot subIndustryID (type INTEGER))\r\n (slot total (type DOUBLE))\r\n)\r\n(deftemplate account\r\n (slot accountId (type STRING))\r\n (slot cash (type DOUBLE))\r\n (slot fixedIncome (type DOUBLE))\r\n (slot stocks (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n)\r\n(deftemplate rating\r\n (slot cusip (type INTEGER))\r\n (slot issuer (type STRING))\r\n)\r\n(defrule joinrule2\r\n (transaction\r\n (accountId ?accid)\r\n (countryCode \"US\")\r\n (issuer ?iss)\r\n )\r\n (rating\r\n (issuer ?iss)\r\n )\r\n (account\r\n (accountId ?accid)\r\n )\r\n=>\r\n (printout t \"joinrule2 was fired\" )\r\n)\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101015)(issuer \"MSFT\") ) )\r\n(assert (rating (cusip 10101025)(issuer \"MSFT\") ) )\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101010)(issuer \"IBM\") ) )\r\n(assert (rating (cusip 10101020)(issuer \"IBM\") ) )\r\n(assert (account (accountId \"acc1\")(cash 1200000) ) )\r\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"de76a9992744e767dd3535cdd2f43971e4696723","subject":"- fixed a bug in the init.clp","message":"- fixed a bug in the init.clp\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@872 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"apps\/jamochaagent\/init.clp","new_file":"apps\/jamochaagent\/init.clp","new_contents":"\n(deftemplate agent-description\n (slot name (type STRING))\n (slot local (type BOOLEAN))\n)\n\n(deftemplate agent-ontology\n (slot name (type STRING))\n (slot definition (type STRING))\n)\n\n(deftemplate agent-performative\n (slot performative (type STRING))\n (slot handlerfunction (type STRING))\n)\n\n(deftemplate agent-message\n\t(slot sender (type STRING))\n\t(multislot receivers)\n\t(multislot reply-to)\n\t(slot performative (type STRING))\n\t(slot content (type STRING))\n\t(slot language (type STRING))\n\t(slot encoding (type STRING))\n\t(slot ontology (type STRING))\n\t(slot protocol (type STRING))\n\t(slot conversation-id (type STRING))\n\t(slot in-reply-to (type STRING))\n\t(slot reply-with (type STRING))\n\t(slot reply-by (type DATETIME))\n\t(multislot user-properties)\n)\n\n\n(defrule incoming-message \n\t(agent-description\n\t\t(name ?receiver)\n\t\t(local TRUE)\n\t) \n\t?message <- (agent-message\n\t\t(sender ?sender)\n\t\t(receivers ?receivers)\n\t\t(reply-to ?replyto)\n\t\t(performative ?performative)\n\t\t(content ?content)\n\t\t(language ?language)\n\t\t(encoding ?encoding)\n\t\t(ontology ?ontology)\n\t\t(protocol ?protocol)\n\t\t(conversation-id ?conversationid)\n\t\t(in-reply-to ?inreplyto)\n\t\t(reply-with ?replywith)\n\t\t(reply-by ?replyby)\n\t\t(user-properties ?userproperties)\n\t)\n\t(agent-performative \n\t (performative ?performative)\n\t (handlerfunction ?handler)\n\t)\n\t(test (member$ ?receiver ?receivers))\n\t=> \n\t(printout t ?receiver \" received a message with performative \" ?performative crlf)\t\n\t(assert (agent-description (name ?sender)(local FALSE)))\n\t(apply ?handler (member ?message getFactId))\n)\n\n(batch apps\/jamochaagent\/performatives\/fipasl.clp)","old_contents":"\n(deftemplate agent-description\n (slot name (type STRING))\n (slot local (type BOOLEAN))\n)\n\n(deftemplate agent-ontology\n (slot name (type STRING))\n (slot definition (type STRING))\n)\n\n(deftemplate agent-performative\n (slot performative (type STRING))\n (slot handlerfunction (type STRING))\n)\n\n(deftemplate agent-message\n\t(slot sender)\n\t(multislot receivers)\n\t(multislot reply-to)\n\t(slot performative)\n\t(slot content)\n\t(slot language)\n\t(slot encoding)\n\t(slot ontology)\n\t(slot protocol)\n\t(slot conversation-id)\n\t(slot in-reply-to)\n\t(slot reply-with)\n\t(slot reply-by)\n\t(multislot user-properties)\n)\n\n\n(defrule incoming-message \n\t(agent-description\n\t\t(name ?receiver)\n\t\t(local TRUE)\n\t) \n\t?message <- (agent-message\n\t\t(sender ?sender)\n\t\t(receivers ?receivers)\n\t\t(reply-to ?replyto)\n\t\t(performative ?performative)\n\t\t(content ?content)\n\t\t(language ?language)\n\t\t(encoding ?encoding)\n\t\t(ontology ?ontology)\n\t\t(protocol ?protocol)\n\t\t(conversation-id ?conversationid)\n\t\t(in-reply-to ?inreplyto)\n\t\t(reply-with ?replywith)\n\t\t(reply-by ?replyby)\n\t\t(user-properties ?userproperties)\n\t)\n\t(agent-performative \n\t (performative ?performative)\n\t (handlerfunction ?handler)\n\t)\n\t(test (member$ ?receiver ?receivers))\n\t=> \n\t(printout t ?receiver \" received a message with performative \" ?performative crlf)\t\n\t(assert (agent-description (name ?sender)(local FALSE)))\n\t(apply ?handler (member ?message getFactId))\n)\n\n(batch ontologies\/fipasl.clp)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"e38a407e1fcaf1e6726d808185e3ddc6678c26a6","subject":"Added RunGLAPIConverter.clp","message":"Added RunGLAPIConverter.clp\n\nThis file automates the process of running the GLAPIConverter expert system on\na given file.\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/RunGLAPIConverter.clp","new_file":"src\/tools\/conv\/gl\/RunGLAPIConverter.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunGLAPIConversion.clp - Runs the GLAPIConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n(batch* GLAPIConversionEntry.clp)\n(reset)\n;Input format is the same as the constant conversion expert system\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\"))\n(run)\n(exit)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/tools\/conv\/gl\/RunGLAPIConverter.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"10610778f22ce5737ba3bab3c1bc3bc49dfd8118","subject":"Added the hydra pass header.","message":"Added the hydra pass header.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/hydra\/PassHeader.clp","new_file":"lib\/durandal\/passes\/hydra\/PassHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHeader.clp - Header file\/entry point into the hydra pass\n;------------------------------------------------------------------------------\n\n(defmodule hydra\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import indirect ?ALL)\n (import pipeline ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/passes\/hydra\/PassHeader.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"73fbf78856f7851b46ff735497c59ec8e65a4700","subject":"Fixed a typo in PassHandler's terminate-pass rule","message":"Fixed a typo in PassHandler's terminate-pass rule\n\nI mis-spelled unmake-instance. This has been fixed.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n\t\t\t?fct <- (message (to pipeline) \n\t\t\t\t\t\t\t\t (action pass-description) \n\t\t\t\t\t\t\t\t (arguments $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of PassDescriptor (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n\t\t\t?obj <- (object (is-a PassDescriptor) (passes ?first $?rest))\n\t\t\t=>\n\t\t\t(assert (message (from pipeline) (to ?first) (action initial-fact)))\n\t\t\t(modify-instance ?obj (passes $?rest))\n\t\t\t;remove what is currently on the focus stack\n\t\t\t(pop-focus)\n\t\t\t(focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n\t\t\t?obj <- (object (is-a PassDescriptor) (passes))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj)\n\t\t\t(pop-focus))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n\t\t\t?fct <- (message (to pipeline) \n\t\t\t\t\t\t\t\t (action pass-description) \n\t\t\t\t\t\t\t\t (arguments $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of PassDescriptor (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n\t\t\t?obj <- (object (is-a PassDescriptor) (passes ?first $?rest))\n\t\t\t=>\n\t\t\t(assert (message (from pipeline) (to ?first) (action initial-fact)))\n\t\t\t(modify-instance ?obj (passes $?rest))\n\t\t\t;remove what is currently on the focus stack\n\t\t\t(pop-focus)\n\t\t\t(focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n\t\t\t?obj <- (object (is-a PassDescriptor) (passes))\n\t\t\t=>\n\t\t\t(unmake-instanec ?obj)\n\t\t\t(pop-focus))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"8753346ceaeddfa34af27d2e4e78b1bdb73affe7","subject":"Reverted log-message function to previous version and documented some other functions.","message":"Reverted log-message function to previous version and documented some other functions.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/utils.clp","new_file":"CLIPS\/utils.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym (time) (\/ ?time 1000.0)))\n)\n\n(defrule clear_timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ? ?time ?duration)\n\t(test (> (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t(?level ?msg1 $?msg2)\n\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" $?msg2 crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" $?msg2 crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym (time) (\/ ?time 1000.0)))\n)\n\n(defrule clear_timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ? ?time ?duration)\n\t(test (> (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"c21cffdb5cc5dcdc6c9bb2dad273d0b8e4fb1b88","subject":"Added an include header to make it faster to load everything in the core","message":"Added an include header to make it faster to load everything in the core\n\nIt must be batched!\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"lib\/sys\/core\/include.clp","new_file":"lib\/sys\/core\/include.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(load* (fs \/lib\/sys\/core\/message.clp))\n(load* (fs \/lib\/sys\/core\/strings.clp))\n(load* (fs \/lib\/sys\/core\/extensions.clp))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/sys\/core\/include.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"3dbc48f299a46d882796792998006adbc6d3aac7","subject":"Added the optimize message-handler to the LLVMModule class","message":"Added the optimize message-handler to the LLVMModule class\n\nThis is a wrapper over the optimize command to make it easier to use.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/llvm\/LLVMModule.clp","new_file":"lib\/durandal\/modules\/llvm\/LLVMModule.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMModule.clp - Module Type\n;------------------------------------------------------------------------------\n(defclass llvm::LLVMModule\n (is-a Object InteropObject ParentedObject)\n (slot inline-asm (type STRING))\n (slot triple (type STRING))\n (slot data-layout (type STRING))\n (slot module-identifier (type STRING))\n (slot endianness (type SYMBOL) (allowed-symbols any little big))\n (slot pointer-size (type SYMBOL) (allowed-symbols any pointer32 pointer64)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::LLVMModule optimize (?optLevel $?passes) \n (optimize ?self:pointer ?optLevel ?passes))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMModule.clp - Module Type\n;------------------------------------------------------------------------------\n(defclass llvm::LLVMModule\n (is-a Object InteropObject ParentedObject)\n (slot inline-asm (type STRING))\n (slot triple (type STRING))\n (slot data-layout (type STRING))\n (slot module-identifier (type STRING))\n (slot endianness (type SYMBOL) (allowed-symbols any little big))\n (slot pointer-size (type SYMBOL) (allowed-symbols any pointer32 pointer64)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c55d24e030873bdec8e55de07691516d40375d77","subject":"another jdbc mini sample added","message":"another jdbc mini sample added\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@701 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/jdbclink2.clp","new_file":"samples\/jdbclink2.clp","new_contents":"(deftemplate templ (slot a) (slot b) (slot c) )\n(assert (jdbclink (JDBCdriver \"com.mysql.jdbc.Driver\") (ConnectionName \"h\") (TableName \"test\") (TemplateName \"templ\") (Username \"jamocha\") (Password \"geheim\") (JDBCurl \"jdbc:mysql:\/\/134.130.113.67:65306\/jamocha\")))\n(jdbclink 2 \"import\" \"foo\")","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/jdbclink2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"cc4cfbfa5763e73e05e100c6a476a88cc03859f9","subject":"Modified painter.clp to use the new chicanery lib","message":"Modified painter.clp to use the new chicanery lib\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery\/pointer.clp)\n(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n(load* \/lib\/chicanery\/rectangle.clp)\n(load* \/lib\/chicanery\/color.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"1668b09e8dd45bb5441cc9a00638e28d44c3d175","subject":"- merged the new multislot test to main branch","message":"- merged the new multislot test to main branch\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@669 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/multislot_test7.clp","new_file":"samples\/multislot_test7.clp","new_contents":"(deftemplate customer\r\n (slot first)\r\n (slot middle)\r\n (slot last)\r\n (slot title)\r\n (multislot addresses)\r\n)\r\n(defrule rule0\r\n (customer\r\n (first \"john\")\r\n )\r\n=>\r\n (printout t \"rule0 was fired\" )\r\n)\r\n(assert (customer (first \"john\")(last \"do\")(addresses 1 4 5) ) )\r\n(fire)\r\n(bind ?var1 1)\r\n(bind ?var2 4)\r\n(assert (customer (first \"john\")(last \"do\")(addresses ?var1 ?var2) ) )\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/multislot_test7.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"db0fed7c34eb15187c05421d0a15262ba26ec3bb","subject":"Updated Init.clp of loop-region-merging to fix the module names","message":"Updated Init.clp of loop-region-merging to fix the module names\n\nThe modules were marked as loop-region-building-* instead of\nloop-region-merging-*.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/Init.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Contains the defmodules that make up the process of\n; loop-region-merging.\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-build\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-expand\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-claim\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-arbitrate\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-flatlist-resolve\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-construction\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-population\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-determinant-indirect-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-update\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-fixup-rename\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-merging-cleanup-merger\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging::modify-pass-description\n\t\t\t\"Modifies the target pass description to load the target subpasses\"\n\t\t\t?fct <- (message (to loop-region-merging) (action initial-fact))\n\t\t\t?obj <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (passes \n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-build\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-expand\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-claim\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-arbitrate\n\t\t\t\t\t\t\t\t\t loop-region-merging-flatlist-resolve\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-construction\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-population\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-determinant-indirect-resolution\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-update\n\t\t\t\t\t\t\t\t\t loop-region-merging-fixup-rename\n\t\t\t\t\t\t\t\t\t loop-region-merging-cleanup-merger\n\t\t\t\t\t\t\t\t\t $?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Contains the defmodules that make up the process of\n; loop-region-merging.\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-flatlist-build\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-flatlist-expand\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-flatlist-claim\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-flatlist-arbitrate\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-flatlist-resolve\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-determinant-construction\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-determinant-population\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-determinant-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-determinant-indirect-resolution\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-fixup\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-fixup-update\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-fixup-rename\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule loop-region-building-cleanup-merger\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging::modify-pass-description\n\t\t\t\"Modifies the target pass description to load the target subpasses\"\n\t\t\t?fct <- (message (to loop-region-merging) (action initial-fact))\n\t\t\t?obj <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (passes \n\t\t\t\t\t\t\t\t\t loop-region-building-flatlist-build\n\t\t\t\t\t\t\t\t\t loop-region-building-flatlist-expand\n\t\t\t\t\t\t\t\t\t loop-region-building-flatlist-claim\n\t\t\t\t\t\t\t\t\t loop-region-building-flatlist-arbitrate\n\t\t\t\t\t\t\t\t\t loop-region-building-flatlist-resolve\n\t\t\t\t\t\t\t\t\t loop-region-building-determinant-construction\n\t\t\t\t\t\t\t\t\t loop-region-building-determinant-population\n\t\t\t\t\t\t\t\t\t loop-region-building-determinant-resolution\n\t\t\t\t\t\t\t\t\t loop-region-building-determinant-indirect-resolution\n\t\t\t\t\t\t\t\t\t loop-region-building-fixup\n\t\t\t\t\t\t\t\t\t loop-region-building-fixup-update\n\t\t\t\t\t\t\t\t\t loop-region-building-fixup-rename\n\t\t\t\t\t\t\t\t\t loop-region-building-cleanup-merger\n\t\t\t\t\t\t\t\t\t $?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4bf70e1f3293a9e5acf8d1d86b0f0fc923ef8b17","subject":"Added set_delete, changed salience and timer_sent.","message":"Added set_delete, changed salience and timer_sent.\n\n-> Added set_delete function and rule to make facts be deleted after some time.\n-> Modified salience to -9000 and 9000 for utils' rules.\n-> Modified fact 'timer_sent' to have only a symbol.\n-> Deleted rule which were supposed to delete timer_sent facts when timer was not created,\n as it wouldn't have work anyway, and shouldn't be activated anyway.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/utils.clp","new_file":"CLIPS\/utils.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym) )\n)\n\n(defrule clear_timers\n\t(declare (salience -9000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer_sent\n\t(declare (salience 9000))\n\t(BB_timer ?sym)\n\t?t <-(timer_sent ?sym)\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(test (fact-existp ?fact))\n\t=>\n\t(retract ?f ?fact)\n)\n\n(defrule set_delete-delete_delete_flag\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(not (test (fact-existp ?fact)))\n\t=>\n\t(retract ?f)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym (time) (\/ ?time 1000.0)))\n)\n\n(defrule clear_timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ? ?time ?duration)\n\t(test (>= (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ?sym ?time ?duration)\n\t(test (< (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n\t(assert (timer_sent ?sym ?time ?duration))\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t=>\n\t(retract ?f ?fact)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"7e63ed11ca414f68ccefbcb2c8a7b9f65ab580bd","subject":"Added the cpuinfo expert system","message":"Added the cpuinfo expert system\n\nIt parses and prints the contents of \/proc\/cpuinfo on linux as CLIPS\nobjects. Unfortunately, it only runs on Linux since its the machine I\nwrote it on.\n","repos":"DrItanium\/neutron,DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"logic\/proc\/cpuinfo.clp","new_file":"logic\/proc\/cpuinfo.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(if (neq (operating-system) Linux) then\n (printout werror \"ERROR: This only works on linux\" crlf)\n (exit -1))\n\n(load* (fs \/sys\/core\/message.clp))\n(load* (fs \/sys\/core\/strings.clp))\n(defclass processor\n (is-a USER)\n (slot processor)\n (slot vendor_id)\n (slot cpu-family)\n (slot model)\n (slot model-name)\n (slot stepping)\n (slot microcode)\n (slot cpu-MHz)\n (slot cache-size)\n (slot physical-id)\n (slot siblings)\n (slot core-id)\n (slot cpu-cores)\n (slot apicid)\n (slot initial-apicid)\n (slot fpu)\n (slot fpu_exception)\n (slot cpuid-level)\n (slot wp)\n (multislot flags)\n (slot bogomips)\n (slot clflush-size)\n (slot cache_alignment)\n (slot address-sizes)\n (slot power-management))\n\n(defrule open-file\n (initial-fact)\n =>\n (if (open \/proc\/cpuinfo \/proc\/cpuinfo \"r\") then\n (assert (message (action \/proc\/cpuinfo)\n (contents (readline \/proc\/cpuinfo))))\n else\n (printout werror \"ERROR: Couldn't open \/proc\/cpuinfo!\" crlf)\n (exit -1)))\n\n(defrule build-up:\/proc\/cpuinfo\n ?f <- (message (action \/proc\/cpuinfo)\n (contents $?lines))\n =>\n (bind ?v (readline \/proc\/cpuinfo))\n (if (eq ?v EOF) then \n (close \/proc\/cpuinfo)\n (modify ?f (action build-entries))\n else\n (modify ?f (contents $?lines ?v))))\n\n(defrule build-processor-entry\n ?f <- (message (action build-entries)\n (contents $?contents \"\" $?rest))\n (test (not (member$ \"\" $?contents)))\n =>\n (modify ?f (contents $?rest))\n (duplicate ?f \n (action processor-entry)\n (from (instance-name (make-instance of processor)))\n (contents $?contents)))\n\n(defrule finish-building-entries\n ?f <- (message (action build-entries)\n (contents))\n =>\n (retract ?f))\n\n(defrule create-processor-entries\n ?f <- (message (action processor-entry)\n (from ?uid)\n (contents ?line $?rest))\n =>\n (modify ?f (contents $?rest))\n (duplicate ?f (action remove-colon)\n (contents ?line)))\n\n(defrule finish-processor-decomposition\n ?f <- (message (action processor-entry)\n (contents))\n =>\n (retract ?f))\n\n(defrule remove-colon\n ?f <- (message (action remove-colon)\n (contents ?line))\n (test (contains \":\" ?line))\n =>\n (bind ?ind (str-index \":\" ?line))\n (modify ?f (action mangle-name)\n (contents (sub-string 1 (- ?ind 1) ?line)\n (sub-string (+ ?ind 1) (str-length ?line) ?line))))\n\n(defrule mangle-name\n ?f <- (message (action mangle-name)\n (contents ?name ?contents))\n =>\n (bind ?ename (explode$ ?name))\n (if (multifieldp ?ename) then\n (bind ?bname (nth$ 1 ?ename))\n (progn$ (?z (rest$ ?ename))\n (bind ?bname (format nil \"%s-%s\" ?bname ?z)))\n (modify ?f (action parse-entry)\n (contents (sym-cat ?bname) ?contents))\n else\n (modify ?f (action parse-entry)\n (contents (sym-cat ?ename) ?contents))))\n\n(defrule parse-entry\n ?f <- (message (action parse-entry)\n (contents ?name $?contents))\n =>\n (modify ?f (action ?name)\n (to populate)\n (contents $?contents)))\n\n(defrule populate-object:flags\n (declare (salience 1))\n ?f <- (message (to populate)\n (from ?name)\n (action flags)\n (contents ?line))\n ?proc <- (object (is-a processor)\n (name ?name))\n =>\n (retract ?f)\n (send ?proc put-flags (explode$ ?line)))\n\n(defrule populate-object:model-name\n (declare (salience 1))\n ?f <- (message (to populate)\n (from ?name)\n (action model-name)\n (contents ?line))\n ?proc <- (object (is-a processor)\n (name ?name))\n =>\n (retract ?f)\n (send ?proc put-model-name (sub-string 2 (str-length ?line) ?line)))\n\n(defrule populate-object:generic\n ?f <- (message (to populate)\n (from ?name)\n (action ?field)\n (contents ?value&~\"\"))\n ?proc <- (object (is-a processor)\n (name ?name))\n =>\n (retract ?f)\n (send ?proc (sym-cat put- ?field) (string-to-field ?value)))\n\n(defrule populate-object:empty\n ?f <- (message (to populate)\n (from ?name)\n (action ?field)\n (contents \"\"))\n ?proc <- (object (is-a processor)\n (name ?name))\n =>\n (retract ?f)\n (send ?proc (sym-cat put- ?field) nil))\n\n(defrule print-processor\n (declare (salience -1))\n ?f <- (object (is-a processor))\n =>\n (printout t \"(\")\n (send ?f print)\n (printout t \")\" crlf))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'logic\/proc\/cpuinfo.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"1545f923182defbfd8a67248354671d6f6cf4cb6","subject":"mux now passes messages","message":"mux now passes messages\n","repos":"DrItanium\/phoenix,DrItanium\/phoenix","old_file":"src\/polymer\/microcode\/mux.clp","new_file":"src\/polymer\/microcode\/mux.clp","new_contents":"(deftemplate message\n (slot from)\n (slot to)\n (slot action)\n (multislot values))\n(defrule parse-mouse-input\n ?f <- (mouse ?buttons&:(!= ?buttons 4) ?x ?y ?msec)\n =>\n (retract ?f)\n (format t \"mouse: %d %d %d %d%n\" ?buttons ?x ?y ?msec))\n\n(defrule parse-mouse-input:quit\n ?f <- (mouse ?buttons&:(= ?buttons 4) ?x ?y ?msec)\n =>\n (retract ?f)\n (format t \"exiting%n\")\n (exit))\n\n(defrule send-message-on\n ?f <- (message (from ?from)\n (to ?to&~mux)\n (action ?action)\n (values $?values))\n =>\n (retract ?f)\n (format ?to \"(message (from %s) (to %s) (action %s) (values %s))\"\n ?from ?to ?action (implode$ ?values)))\n","old_contents":"(defrule parse-mouse-input\n ?f <- (mouse ?buttons&:(!= ?buttons 4) ?x ?y ?msec)\n =>\n (retract ?f)\n (format t \"mouse: %d %d %d %d%n\" ?buttons ?x ?y ?msec))\n\n(defrule parse-mouse-input:quit\n ?f <- (mouse ?buttons&:(= ?buttons 4) ?x ?y ?msec)\n =>\n (retract ?f)\n (format t \"exiting%n\")\n (exit))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"fe7083ac8c152285994cbce9f207bb3a328b31b2","subject":"Modified the Pass class to register and load the target pass on init","message":"Modified the Pass class to register and load the target pass on init\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fc108e5a8cc1b7d044e6902c3d6cfc4d1241b5c5","subject":"Added the reset-run-exit chunk","message":"Added the reset-run-exit chunk\n","repos":"DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"sys\/chunks\/reset-run-exit.clp","new_file":"sys\/chunks\/reset-run-exit.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; reset-run-exit.clp - Calls reset, run, and then exits. This is useful for \n; expert systems that are meant to run and then exit\n; \n; Obviously, this prevent shell access.\n;------------------------------------------------------------------------------\n(reset)\n(run)\n(exit)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'sys\/chunks\/reset-run-exit.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"82e834991e4d2ef44e2850b2ec613be242d3676f","subject":"bugfix","message":"bugfix\n","repos":"tortinator\/asprilo","old_file":"quantities.clp","new_file":"quantities.clp","new_contents":"#include . \n\n&dom{N..N} = ordered(O,A,0) :- init(object(order,O), value(line,(A,N))).\n&dom{0..ordered(O,A,0)} = ordered(O,A,T) :- ordered(O,A), time(T).\n&dom{N..N} = shelved(S,A,0) :- init(object(product,A), value(on, (S,N))).\n&dom{0..shelved(S,A,0)} = shelved(S,A,T) :- shelved(S,A), time(T).\n\n&dom{0..ordered(O,A,0)} = process(A,O,S,T) :- ordered(O,A), shelved(S,A), time(T).\n\n{ process(A,O,S,T) : ordered(O,A), shelved(S,A) } 1 :- time(T). % process one article at a time at one processing station (via order)\n\n:- process(_,O,_,T), target(O,P), not serves(_,P,T).\n:- process(A,O,S,T), target(O,P), serves(R,P,T), not carries(R,S,T).\n:- process(A,O,S,T), &sum{ shelved(S,A,T-1); -process(A,O,S,T) } < 0.\n\n:- process(A,O,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), &sum{ process(A,O,S,T) } = 0.\n\n:- not process(A,_,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } != 0, time(T).\n:- not process(A,O,_,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } != 0, time(T). % >>> REPORT MAX!!! <<<\n:- not process(A,O,S,T), shelved(S,A), ordered(O,A), &sum{ process(A,O,S,T) } != 0, time(T).\n\n\n\n\n\n\n\n%*\n:- shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } < 0, time(T).\n:- ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } < 0, time(T).\n*%\n","old_contents":"#include . \n\n&dom{N..N} = ordered(O,A,0) :- init(object(order,O), value(line,(A,N))).\n&dom{0..ordered(O,A,0)} = ordered(O,A,T) :- time(T).\n&dom{N..N} = shelved(S,A,0) :- init(object(product,A), value(on, (S,N))).\n&dom{0..shelved(S,A,0)} = shelved(S,A,T) :- time(T).\n\n&dom{0..N} = process(A,O,S,T) :- ordered(O,A,number(N)), shelved(S,A), time(T).\n\n{ process(A,O,S,T) : ordered(O,A), shelved(S,A) } 1 :- time(T). % process one article at a time at one processing station (via order)\n\n:- process(_,O,_,T), target(O,P), not serves(_,P,T).\n:- process(A,O,S,T), target(O,P), serves(R,P,T), not carries(R,S,T).\n:- process(A,O,S,T), &sum{ shelved(S,A,T-1); -process(A,O,S,T) } < 0.\n\n:- process(A,O,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), &sum{ process(A,O,S,T) } = 0.\n\n:- not process(A,_,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } != 0, time(T).\n:- not process(A,O,_,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } != 0, time(T). % >>> REPORT MAX!!! <<<\n:- not process(A,O,S,T), shelved(S,A), ordered(O,A), &sum{ process(A,O,S,T) } != 0, time(T).\n\n\n\n\n\n\n\n%*\n:- shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } < 0, time(T).\n:- ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } < 0, time(T).\n*%\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9c9b6665250fe859232e1718bbcc1992a77580c8","subject":"src\/lib\/cortex\/core\/Loader.clp: Added a batch* operation for Message.clp","message":"src\/lib\/cortex\/core\/Loader.clp: Added a batch* operation for Message.clp\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/lib\/cortex\/core\/Loader.clp","new_file":"src\/lib\/cortex\/core\/Loader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads all files in the core folder\n;------------------------------------------------------------------------------\n(batch* \"src\/lib\/cortex\/core\/Object.clp\")\n(batch* \"src\/lib\/cortex\/core\/Message.clp\")\n(batch* \"src\/lib\/cortex\/core\/ObjectConversionFunctions.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads all files in the core folder\n;------------------------------------------------------------------------------\n(batch* \"core\/Object.clp\")\n(batch* \"core\/ObjectConversionFunctions.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"38bd9f154edab3d94fc798f53bbcacba5546b38d","subject":"Added LLVMType.clp","message":"Added LLVMType.clp\n\nIt contains all of the LLVMType classes.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/LLVMType.clp","new_file":"modules\/llvm\/LLVMType.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass llvm::LLVMType (is-a llvm::LLVMObject)\n (slot IsVoidType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsHalfType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFloatType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDoubleType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsX86FP80Type (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFP128Type (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsPPCFP128Type (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFloatingPointType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsX86MMXType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFPOrFPVectorType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsLabelType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMetadataType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsIntegerType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsIntOrIntVectorType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFunctionType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsStructType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsArrayType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsPointerType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsVectorType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsEmptyType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsPrimitiveType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDerivedType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsFirstClassType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsSingleValueType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsAggregateType (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsSized (type SYMBOL) (allowed-values FALSE TRUE))\n (slot PrimitiveSizeInBits (type NUMBER) (range 0 ?VARIABLE))\n (slot ScalarSizeInBits (type NUMBER) (range 0 ?VARIABLE))\n (slot FPMantissaWidth (type NUMBER) (range 0 ?VARIABLE))\n (slot ScalarType (allowed-classes LLVMType))\n (multislot Subtypes)\n (multislot TypeMakeup (type SYMBOL))\n (slot IsFunctionVarArg (type SYMBOL) (allowed-values FALSE TRUE))\n (slot QuickType (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::IntegerType (is-a llvm::LLVMType)\n (slot BitWidth (type NUMBER) (range 0 ?VARIABLE))\n (slot BitMask (type NUMBER))\n (slot SignBit (type NUMBER))\n (slot IsPowerOf2ByteWidth (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::FunctionType (is-a llvm::LLVMType)\n (slot IsVarArg (type SYMBOL) (allowed-values FALSE TRUE))\n (slot ReturnType (allowed-classes LLVMType))\n (multislot Parameters))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::FunctionType get-num-params primary \n ()\n (length$ ?self:Parameters))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::FunctionType get-param-type primary \n (?index)\n (nth$ ?index ?self:Parameters))\n;------------------------------------------------------------------------------\n(defclass llvm::CompositeType (is-a llvm::LLVMType)\n (multislot Indicies))\n;------------------------------------------------------------------------------\n(defclass llvm::StructType (is-a llvm::CompositeType)\n (slot Name (type SYMBOL))\n (slot IsPacked (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsLiteral (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsOpaque (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsSized (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasName (type SYMBOL) (allowed-values FALSE TRUE))\n (multislot Body))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::StructType set-body primary \n (?element ?isPacked)\n (bind ?self:IsPacked ?isPacked)\n (bind ?self:Body ?element))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::StructType get-num-elements \n ()\n (length$ ?self:Body))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::StructType get-element-type \n (?n)\n (nth$ ?n ?self:Body))\n;------------------------------------------------------------------------------\n(defclass llvm::SequentialType (is-a llvm::CompositeType)\n (slot ElementType (allowed-classes LLVMType)))\n;------------------------------------------------------------------------------\n(defclass llvm::VectorType (is-a llvm::SequentialType)\n (slot BitWidth (type NUMBER) (range 0 ?VARIABLE))\n (slot NumElements (type NUMBER) (range 0 ?VARIABLE)))\n;------------------------------------------------------------------------------\n(defclass llvm::PointerType (is-a llvm::SequentialType)\n (slot AddressSpace (type NUMBER) (range 0 ?VARIABLE)))\n;------------------------------------------------------------------------------\n(defclass llvm::ArrayType (is-a llvm::SequentialType)\n (slot NumElements (type NUMBER) (range 0 ?VARIABLE)))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/llvm\/LLVMType.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"a7816cf55d3ef51e726ad71bbd4dd4cbeadb6009","subject":"Added the possibility to cancel timers.","message":"Added the possibility to cancel timers.\n\n-> When a BB_timer fact is received and the use deleted the timer_sent fact, then the BB_timer is deleted as well\n in a rule with salience of 10000, never reaching the planning rules.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/utils.clp","new_file":"CLIPS\/utils.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction str-replace\n\t(?str ?old ?new)\n\t(bind ?len (str-length ?old))\n\t(bind ?pos (str-index ?old ?str))\n\t(while (neq ?pos FALSE) do\n\t\t(bind ?str_len (str-length ?str))\n\t\t(bind ?str\n\t\t\t(str-cat\n\t\t\t\t(sub-string 1 (- ?pos 1) ?str)\n\t\t\t\t?new\n\t\t\t\t(sub-string (+ ?pos ?len) ?str_len ?str)\n\t\t\t)\n\t\t)\n\t\t(bind ?pos (str-index ?old ?str))\n\t)\n\t(return ?str)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym) )\n)\n\n(defrule clear_timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer_sent\n\t(declare (salience 10000))\n\t(BB_timer ?sym)\n\t?t <-(timer_sent ?sym)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer\n\t(declare (salience 10000))\n\t?t <-(BB_timer ?sym)\n\t(not (timer_sent ?sym))\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction stop\n\t()\n\t(log-message WARNING \"Stop function called. EXECUTION HALTED.\")\n\t(python-call stop)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(test (fact-existp ?fact))\n\t=>\n\t(retract ?f ?fact)\n)\n\n(defrule set_delete-delete_delete_flag\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(not (test (fact-existp ?fact)))\n\t=>\n\t(retract ?f)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction str-replace\n\t(?str ?old ?new)\n\t(bind ?len (str-length ?old))\n\t(bind ?pos (str-index ?old ?str))\n\t(while (neq ?pos FALSE) do\n\t\t(bind ?str_len (str-length ?str))\n\t\t(bind ?str\n\t\t\t(str-cat\n\t\t\t\t(sub-string 1 (- ?pos 1) ?str)\n\t\t\t\t?new\n\t\t\t\t(sub-string (+ ?pos ?len) ?str_len ?str)\n\t\t\t)\n\t\t)\n\t\t(bind ?pos (str-index ?old ?str))\n\t)\n\t(return ?str)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym) )\n)\n\n(defrule clear_timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer_sent\n\t(declare (salience 10000))\n\t(BB_timer ?sym)\n\t?t <-(timer_sent ?sym)\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction stop\n\t()\n\t(log-message WARNING \"Stop function called. EXECUTION HALTED.\")\n\t(python-call stop)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(test (fact-existp ?fact))\n\t=>\n\t(retract ?f ?fact)\n)\n\n(defrule set_delete-delete_delete_flag\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(not (test (fact-existp ?fact)))\n\t=>\n\t(retract ?f)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"abc904ab5bd8b894fc3f87977dde0dbdb3badf1f","subject":"Fixed type name issues in WavefrontScheduling.clp","message":"Fixed type name issues in WavefrontScheduling.clp\n\nIt turns out that the names of these classes have to have the corresponding\nmodule name tacked onto it because that becomes part of the actual instance\nname. Failure to keep this information will result in a type not found error\nhalting execution.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?tmp (if (not (str-index types:: ?cpv)) then\n (sym-cat types:: ?cpv)\n else\n ?cpv))\n (bind ?cpvName (symbol-to-instance-name ?tmp))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?tmp))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n ;TODO: Figure out why some symbols are not being properly\n ; identified and some are.\n (bind ?tmp (if (not (str-index types:: ?z)) then\n (sym-cat types:: ?z)\n else\n ?z))\n (bind ?obj (instance-name (symbol-to-instance-name ?tmp)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?tmp))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0072a88ca41b6cbbcdce65795c39c54ed697e889","subject":"Added a comment denoting the code that causes the PassManager to fail","message":"Added a comment denoting the code that causes the PassManager to fail\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/InteropObject.clp","new_file":"lib\/durandal\/modules\/core\/InteropObject.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; InteropObject.clp - An interface that exposes a pointer address. It does not\n; inherit from Object\n;------------------------------------------------------------------------------\n(defclass core::InteropObject \n \"Interface to an item outside of the CLIPS environment\"\n (is-a USER)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (visibility public)))\n\n;uncomment this code and watch the LLVM PassManager fail with a general\n;protection fault\n\n;(defmessage-handler core::InteropObject init around () \n;\t\t\t\t\t\t (call-next-handler)\n;\t\t\t\t\t\t (if (and (numberp ?self:pointer)\n;\t\t\t\t\t\t\t\t\t (not (= 0 ?self:pointer))) then\n;\t\t\t\t\t\t\t (bind ?self:pointer (to-pointer ?self:pointer))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; InteropObject.clp - An interface that exposes a pointer address. It does not\n; inherit from Object\n;------------------------------------------------------------------------------\n(defclass core::InteropObject \n \"Interface to an item outside of the CLIPS environment\"\n (is-a USER)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (visibility public)))\n\n;(defmessage-handler core::InteropObject init around () \n;\t\t\t\t\t\t (call-next-handler)\n;\t\t\t\t\t\t (if (and (numberp ?self:pointer)\n;\t\t\t\t\t\t\t\t\t (not (= 0 ?self:pointer))) then\n;\t\t\t\t\t\t\t (bind ?self:pointer (to-pointer ?self:pointer))))\n\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"16b3a23e7c34dcf80246a65b8c354216483608bb","subject":"Added header-span definition support","message":"Added header-span definition support\n\nThe idea behind these spans is that the distance between each header represents\na set of GLAPI and #define calls. The idea is to only define header spans that\ndo not overlap onto other header spans. This makes each span represent a unique\npart of the file. Currently, I do not have a way to detecting overlapping spans\nbut I am working on it.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans\n \"Defines spans between headers\"\n (file-line (type header)\n (parent ?parent)\n (index ?i))\n (file-line (type header)\n (parent ?parent)\n (index ?i2&:(< ?i2 ?i)))\n =>\n (bind ?difference (- ?i ?i2))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (difference ?difference)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"06cb6dd4598dd057f4cfd5d98158c8c82daf32e2","subject":"Started porting the rules in WavefrontScheduling.clp","message":"Started porting the rules in WavefrontScheduling.clp\n\nI finished the wavefront-schedule-inject and wavefront-scheduling-strip\nmodules. I rewrote some of the more complex rules to copy block sets over if it\nturns out that the multifield being stored into is empty. This makes some of\nthe rules constant in the best case and linear in the worst case now (this does\nnot include CLIPS' internal overhead though)\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ;get the Mrs. Hitler birth certificate\n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (argument ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule SelectValidCPVs \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule FindValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule RetractValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule IgnorePHIInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreCallInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreTerminatorInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction) (ID ?inst) (Parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg) (Parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) (ID ?inst) (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule TagValidCPVs\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) (ID ?inst) (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractDrainedGetCPVFacts\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (not (member$ ?cpvID \n (send ?agObj \n get-ImpossibleCompensationPathVectors))))\n =>\n (retract ?fct)\n (if (not (member$ ?inst (send ?agObj get-InstructionList))) then \n (slot-insert$ ?agObj InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?agObj get-InstructionList))) then\n (slot-insert$ ?agObj InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld \n (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (slot-insert$ ?agObj CompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule CPVIsImpossible\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (member$ ?cpvID (send ?agObj \n get-ImpossibleCompensationPathVectors)))\n =>\n ;add the non-local dependencies\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule MakeCPV \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector) (Parent ?inst))))\n (object (is-a Instruction) (Class ?class) (ID ?inst) (Parent ?pv) \n (DestinationRegisters ?reg) (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) (ID ?pv) (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?name (gensym*))\n (slot-insert$ ?pa CompensationPathVectors 1 ?name)\n (make-instance ?name of CompensationPathVector (Parent ?inst) \n (Paths $?paths) (OriginalBlock ?pv))\n (if (not (member$ ?inst (send ?pa get-InstructionList))) then \n (slot-insert$ ?pa InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?pa get-InstructionList))) then\n (slot-insert$ ?pa InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?pa get-ScheduledInstructions))) \n then (slot-insert$ ?pa ScheduledInstructions 1 ?nld))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule SetifyInstructionList\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?pa <- (object (is-a PathAggregate) (InstructionList $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (InstructionList $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule GenerateInitialSliceFactsForElementsOnTheWavefront \n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n (object (is-a PathAggregate) (Parent ?e) \n (CompensationPathVectors $?cpv))\n (test (> (length$ ?cpv) 0))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule GenerateFactForSlicesFromCPV\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) (ID ?i) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptySlicesCreationFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule QueryCanCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $? ?e $?))\n ;(test (member$ ?e ?z))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule QueryCantCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $?z))\n (test (not (member$ ?e ?z)))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule TryConstructNewSlice\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) (ID ?path) (Contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance (gensym*) of Slice (Parent ?b) (TargetPath ?path)\n (TargetBlock ?e) (Contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule SliceAlreadyExists\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveSliceAnalysisFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n (object (is-a Wavefront) (Contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID) \n (CompensationPathVectors $?cpvIDs))\n (test (> (length$ ?cpvIDs) 0))\n =>\n (modify-instance ?agObj (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule SetifyTargetCompensationPathVectors\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (TargetCompensationPathVectors $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule SelectCPVForAnalysis\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze0 $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ;(not (exists (Schedule ?e for ?r)))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (TargetCompensationPathVectors $?cpvs))\n (test (> (length$ ?cpvs) 0))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj (TargetCompensationPathVectors))\n (bind ?result (create$))\n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (progn$ (?p (send (symbol-to-instance-name ?cpv) get-Paths))\n (if ?det then \n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?det \n (or ?det \n (member$ ?e \n (send ?o2 get-Contents))))))\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n (assert (Analyze block ?e for ?r using cpvs $?result)))\n;------------------------------------------------------------------------------\n(defrule SegmentCPVsApart\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ?e for ?r using cpvs ?cpv $?cpvs)\n (object (is-a BasicBlock) (ID ?e))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n =>\n ;(printout t \"Analyze instruction \" ?i \" { associated cpv \" ?cpv \n ; \" } for \" ?e crlf)\n (retract ?fct)\n (assert (Analyze block ?e for ?r using cpvs $?cpvs)\n (Analyze instruction ?i { associated cpv ?cpv } for ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractCPVSegmentationFact\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ? for ? using cpvs)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) (Parent ?a))))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ; \" because a CPV wasn't tied to the instruction\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) (Parent ?a) (ID ?id))\n (test (not (member$ ?id $?cpvs)))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ;\" because the corresponding CPV wasn't registered with the path\"\n ;\" aggregate\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVIsImpossibleToScheduleIntoTargetBlock\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;(printout t ?i \" is impossible to schedule into \" ?e crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"Schedule = \" ?sched crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n\n(defrule TargetCPVCantBeScheduledIntoTargetBlockYet\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?paObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld) \n (NonLocalDependencies $?nld) (Parent ?parent))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;(printout t \"Can't schedule \" ?i \" into \" ?e \" right now!\" crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Scheduled = \" ?sched crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"From = \" ?parent crlf)\n ;(printout t \"CPVS = \" ?cpvs crlf)\n ;(facts)\n (retract ?fct)\n (assert (Cant schedule ?cpv for ?e now)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVNeedsToBeSliceAnalyzed\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n (object (is-a PathAggregate) (Parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (Parent ?b) \n (LocalDependencies $?ld))\n (test (subsetp ?ld ?sched))\n (object (is-a CompensationPathVector) (ID ?cpv) (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (foreach ?z ?paths\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (if (member$ ?e (send ?obj get-Contents)) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule CreateSliceSegments\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) (Parent ?b) (TargetBlock ?e) (TargetPath ?path)\n (ID ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (Analyze slice ?s for ?e and cpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule RetractSliceSegmenterFact\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule FAILURE-MISSING-SLICE \n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-Contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (exit))\n\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-SingleSingle\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n ?f1 <- (Analyze slice ?s1&~?s0 for ?e and cpv ?cpv)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule ConvertSingleSliceRule\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n =>\n (retract ?f0)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0)))\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-MultiMulti\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze in ?e using cpv ?cpv and slices $?q)\n ?f1 <- (Analyze in ?e using cpv ?cpv and slices $?z)\n (test (neq ?f0 ?f1)) \n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices $?z $?q)))\n;------------------------------------------------------------------------------\n(defrule SetifyAnalyzeSlicesFact\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c ?b $?d)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule ERROR-ANALYSIS-FAILURE\n (declare (salience -900))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n (Analyze instruction ?i for ?blkID)\n ?inst <- (object (is-a Instruction) (ID ?i))\n (object (is-a PathAggregate) (Parent ?blkID) \n (ScheduledInstructions $?si))\n ?cpv <- (object (is-a CompensationPathVector) (Parent ?i))\n =>\n (printout t \"ERROR: ANALYZE INSTRUCTION \" ?i \" WASN'T MATCHED!!!\" crlf\n \"SCHEDULED INSTRUCTIONS: \" $?si crlf)\n (send ?inst print)\n (printout t crlf)\n (send ?cpv print)\n (exit))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?)\n (exists (Cant schedule ?cpv for ?e ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n ; (printout t \"Failed Instruction \" ?i \" because producer is lower \"\n ; \"than block \" ?e \" on the wavefront\" crlf)\n (retract ?fct)\n (bind ?ind (member ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-CallBarrier\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled - \"\n ; \"Call Barrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i)\n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled into \" ?e \n ; \" - MemoryBarrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n ?instruction <- (object (is-a LoadInstruction|StoreInstruction) \n (ID ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier FALSE) (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n ;(printout t \"Removed \" ?i \" from being scheduled into \" \n ;\t\t\t\t\t ?e \" because \" ?element \" - ModifiesSameMemory\" crlf)\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?cpv) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i) \n (Parent ?q) (DestinationRegisters ?dr))\n (object (ID ?element) (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled from block \" ?q \n ;\t\t\t\t\t \" unknown reference\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?ss)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleInstructionThisIteration\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices)\n =>\n (retract ?fct)\n (assert (Can schedule ?cpv for ?e)))\n;------------------------------------------------------------------------------\n(defrule AddCPVToSuccessList\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Can schedule ?cpvID for ?blkID)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj MovableCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule FailCPVForNow\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID now)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj StalledCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule RemoveCPVFromService\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID ever)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n ?cpvObj <- (object (is-a CompensationPathVector) (ID ?cpvID) \n (Parent ?i))\n =>\n (retract ?fct)\n (slot-insert$ ?cpvObj Failures 1 ?blkID)\n (slot-insert$ ?agObj ImpossibleCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule PonderMovementIteration\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?)\n (object (is-a Wavefront) (ID ?r) (Contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) (Parent ?e) (ID ?pa)\n (StalledCompensationPathVectors $?scpv))\n (test (> (length$ $?scpv) 0))\n =>\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule AnotherMovementIsRequired\n (Stage WavefrontSchedule $?)\n ?ponder <- (Substage Ponder $?rest)\n ?f <- (Another Movement Required)\n =>\n ;this returns a tuple\n (retract ?ponder ?f)\n (assert (Substage GenerateAnalyze0 \n GenerateAnalyze \n Analyze \n SliceAnalyze \n MergeInit \n Merge \n MergeUpdate\n ReopenBlocks \n Ponder \n $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishSchedulingIntoBlock\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?rest)\n =>\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule MergePotentiallyValidBlocks\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n ?pv0 <- (PotentiallyValid blocks for ?e are $?t)\n ?pv1 <- (PotentiallyValid blocks for ?e are $?q)\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv0 ?pv1)\n ;make sure that we get matches again!\n (assert (PotentiallyValid blocks for ?e are $?q)))\n;------------------------------------------------------------------------------\n(defrule MergeMemoryPotentiallyValidBlocks\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n ?pv0 <- (MemoryPotentiallyValid blocks for ?e are $?t)\n ?pv1 <- (MemoryPotentiallyValid blocks for ?e are $?q)\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv0 ?pv1)\n ;make sure that we get matches again!\n (assert (MemoryPotentiallyValid blocks for ?e are $?q)))\n;------------------------------------------------------------------------------\n(defrule MergeCompletelyInvalid\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n ?pv0 <- (CompletelyInvalid blocks for ?e are $?t)\n ?pv1 <- (CompletelyInvalid blocks for ?e are $?q)\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv0 ?pv1)\n (assert (CompletelyInvalid blocks for ?e are $?q)))\n;------------------------------------------------------------------------------\n(defrule RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n (CompletelyInvalid blocks for ?e are $?t)\n ?pv1 <- (PotentiallyValid blocks for ?e are $?q)\n (test (subsetp ?q ?t))\n =>\n (retract ?pv1))\n;------------------------------------------------------------------------------\n(defrule StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n ?f0 <- (PotentiallyValid blocks for ?e are $?before ?car $?rest)\n (CompletelyInvalid blocks for ?e are $? ?car $?)\n =>\n (retract ?f0)\n (assert (PotentiallyValid blocks for ?e are $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptyPotentiallyValid\n (declare (salience -100))\n (Stage WavefrontSchedule $?)\n (Substage Strip $?)\n ?f0 <- (PotentiallyValid blocks for ? are)\n =>\n (retract ?f0))\n;------------------------------------------------------------------------------\n(defrule InjectPotentiallyValidBlocks-Complete\n (Stage WavefrontSchedule $?)\n (Substage Inject $?)\n ?fct <- (PotentiallyValid blocks for ?e are $?blocks)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvs $?pv)\n (bind ?newIndex (+ (length$ ?pv) 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule InjectCompletelyInvalidBlocks-Complete\n (Stage WavefrontSchedule $?)\n (Substage Inject $?)\n ?fct <- (CompletelyInvalid blocks for ?e are $?blocks)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis)))\n;------------------------------------------------------------------------------\n(defrule InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Inject $?)\n ?f0 <- (CompletelyInvalid blocks for ?e are $?b0)\n ?f1 <- (PotentiallyValid blocks for ?e are $?b1)\n ?pa <- (object (is-a PathAggregate) (Parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (bind ?i0 (+ 1 (length$ ?ci)))\n (bind ?i1 (+ 1 (length$ ?pv)))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1))))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule InjectMemoryBarrierBlocks \n (Stage WavefrontSchedule $?)\n (Substage Inject $?)\n ;get the Mrs. Hitler birth certificate\n ?fct <- (Element ?t has a MemoryBarrier for ?e)\n ?pa <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (if (not (member$ ?t (send ?pa get-MemoryBarriers))) then\n (slot-insert$ ?pa MemoryBarriers 1 ?t)))\n;------------------------------------------------------------------------------\n(defrule InjectCallBarrierBlocks \n (Stage WavefrontSchedule $?)\n (Substage Inject $?)\n ;get the Mrs. Hitler birth certificate\n ?fct <- (Element ?t has a CallBarrier for ?e)\n ?pa <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (if (not (member$ ?t (send ?pa get-CallBarriers))) then\n (slot-insert$ ?pa CallBarriers 1 ?t)))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule SelectValidCPVs \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule FindValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule RetractValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule IgnorePHIInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreCallInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreTerminatorInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction) (ID ?inst) (Parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg) (Parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) (ID ?inst) (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule TagValidCPVs\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) (ID ?inst) (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractDrainedGetCPVFacts\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (not (member$ ?cpvID \n (send ?agObj \n get-ImpossibleCompensationPathVectors))))\n =>\n (retract ?fct)\n (if (not (member$ ?inst (send ?agObj get-InstructionList))) then \n (slot-insert$ ?agObj InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?agObj get-InstructionList))) then\n (slot-insert$ ?agObj InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld \n (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (slot-insert$ ?agObj CompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule CPVIsImpossible\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (member$ ?cpvID (send ?agObj \n get-ImpossibleCompensationPathVectors)))\n =>\n ;add the non-local dependencies\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule MakeCPV \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector) (Parent ?inst))))\n (object (is-a Instruction) (Class ?class) (ID ?inst) (Parent ?pv) \n (DestinationRegisters ?reg) (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) (ID ?pv) (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?name (gensym*))\n (slot-insert$ ?pa CompensationPathVectors 1 ?name)\n (make-instance ?name of CompensationPathVector (Parent ?inst) \n (Paths $?paths) (OriginalBlock ?pv))\n (if (not (member$ ?inst (send ?pa get-InstructionList))) then \n (slot-insert$ ?pa InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?pa get-InstructionList))) then\n (slot-insert$ ?pa InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?pa get-ScheduledInstructions))) \n then (slot-insert$ ?pa ScheduledInstructions 1 ?nld))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule SetifyInstructionList\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?pa <- (object (is-a PathAggregate) (InstructionList $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (InstructionList $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule GenerateInitialSliceFactsForElementsOnTheWavefront \n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n (object (is-a PathAggregate) (Parent ?e) \n (CompensationPathVectors $?cpv))\n (test (> (length$ ?cpv) 0))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule GenerateFactForSlicesFromCPV\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) (ID ?i) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptySlicesCreationFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule QueryCanCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $? ?e $?))\n ;(test (member$ ?e ?z))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule QueryCantCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $?z))\n (test (not (member$ ?e ?z)))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule TryConstructNewSlice\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) (ID ?path) (Contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance (gensym*) of Slice (Parent ?b) (TargetPath ?path)\n (TargetBlock ?e) (Contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule SliceAlreadyExists\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveSliceAnalysisFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n (object (is-a Wavefront) (Contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID) \n (CompensationPathVectors $?cpvIDs))\n (test (> (length$ ?cpvIDs) 0))\n =>\n (modify-instance ?agObj (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule SetifyTargetCompensationPathVectors\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (TargetCompensationPathVectors $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule SelectCPVForAnalysis\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze0 $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ;(not (exists (Schedule ?e for ?r)))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (TargetCompensationPathVectors $?cpvs))\n (test (> (length$ ?cpvs) 0))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj (TargetCompensationPathVectors))\n (bind ?result (create$))\n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (progn$ (?p (send (symbol-to-instance-name ?cpv) get-Paths))\n (if ?det then \n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?det \n (or ?det \n (member$ ?e \n (send ?o2 get-Contents))))))\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n (assert (Analyze block ?e for ?r using cpvs $?result)))\n;------------------------------------------------------------------------------\n(defrule SegmentCPVsApart\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ?e for ?r using cpvs ?cpv $?cpvs)\n (object (is-a BasicBlock) (ID ?e))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n =>\n ;(printout t \"Analyze instruction \" ?i \" { associated cpv \" ?cpv \n ; \" } for \" ?e crlf)\n (retract ?fct)\n (assert (Analyze block ?e for ?r using cpvs $?cpvs)\n (Analyze instruction ?i { associated cpv ?cpv } for ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractCPVSegmentationFact\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ? for ? using cpvs)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) (Parent ?a))))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ; \" because a CPV wasn't tied to the instruction\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) (Parent ?a) (ID ?id))\n (test (not (member$ ?id $?cpvs)))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ;\" because the corresponding CPV wasn't registered with the path\"\n ;\" aggregate\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVIsImpossibleToScheduleIntoTargetBlock\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;(printout t ?i \" is impossible to schedule into \" ?e crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"Schedule = \" ?sched crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n\n(defrule TargetCPVCantBeScheduledIntoTargetBlockYet\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?paObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld) \n (NonLocalDependencies $?nld) (Parent ?parent))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;(printout t \"Can't schedule \" ?i \" into \" ?e \" right now!\" crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Scheduled = \" ?sched crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"From = \" ?parent crlf)\n ;(printout t \"CPVS = \" ?cpvs crlf)\n ;(facts)\n (retract ?fct)\n (assert (Cant schedule ?cpv for ?e now)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVNeedsToBeSliceAnalyzed\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n (object (is-a PathAggregate) (Parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (Parent ?b) \n (LocalDependencies $?ld))\n (test (subsetp ?ld ?sched))\n (object (is-a CompensationPathVector) (ID ?cpv) (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (foreach ?z ?paths\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (if (member$ ?e (send ?obj get-Contents)) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule CreateSliceSegments\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) (Parent ?b) (TargetBlock ?e) (TargetPath ?path)\n (ID ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (Analyze slice ?s for ?e and cpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule RetractSliceSegmenterFact\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule FAILURE-MISSING-SLICE \n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-Contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (exit))\n\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-SingleSingle\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n ?f1 <- (Analyze slice ?s1&~?s0 for ?e and cpv ?cpv)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule ConvertSingleSliceRule\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n =>\n (retract ?f0)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0)))\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-MultiMulti\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze in ?e using cpv ?cpv and slices $?q)\n ?f1 <- (Analyze in ?e using cpv ?cpv and slices $?z)\n (test (neq ?f0 ?f1)) \n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices $?z $?q)))\n;------------------------------------------------------------------------------\n(defrule SetifyAnalyzeSlicesFact\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c ?b $?d)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule ERROR-ANALYSIS-FAILURE\n (declare (salience -900))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n (Analyze instruction ?i for ?blkID)\n ?inst <- (object (is-a Instruction) (ID ?i))\n (object (is-a PathAggregate) (Parent ?blkID) \n (ScheduledInstructions $?si))\n ?cpv <- (object (is-a CompensationPathVector) (Parent ?i))\n =>\n (printout t \"ERROR: ANALYZE INSTRUCTION \" ?i \" WASN'T MATCHED!!!\" crlf\n \"SCHEDULED INSTRUCTIONS: \" $?si crlf)\n (send ?inst print)\n (printout t crlf)\n (send ?cpv print)\n (exit))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?)\n (exists (Cant schedule ?cpv for ?e ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n ; (printout t \"Failed Instruction \" ?i \" because producer is lower \"\n ; \"than block \" ?e \" on the wavefront\" crlf)\n (retract ?fct)\n (bind ?ind (member ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-CallBarrier\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled - \"\n ; \"Call Barrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i)\n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled into \" ?e \n ; \" - MemoryBarrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n ?instruction <- (object (is-a LoadInstruction|StoreInstruction) \n (ID ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier FALSE) (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n ;(printout t \"Removed \" ?i \" from being scheduled into \" \n ;\t\t\t\t\t ?e \" because \" ?element \" - ModifiesSameMemory\" crlf)\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?cpv) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i) \n (Parent ?q) (DestinationRegisters ?dr))\n (object (ID ?element) (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled from block \" ?q \n ;\t\t\t\t\t \" unknown reference\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?ss)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleInstructionThisIteration\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices)\n =>\n (retract ?fct)\n (assert (Can schedule ?cpv for ?e)))\n;------------------------------------------------------------------------------\n(defrule AddCPVToSuccessList\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Can schedule ?cpvID for ?blkID)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj MovableCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule FailCPVForNow\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID now)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj StalledCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule RemoveCPVFromService\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID ever)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n ?cpvObj <- (object (is-a CompensationPathVector) (ID ?cpvID) \n (Parent ?i))\n =>\n (retract ?fct)\n (slot-insert$ ?cpvObj Failures 1 ?blkID)\n (slot-insert$ ?agObj ImpossibleCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule PonderMovementIteration\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?)\n (object (is-a Wavefront) (ID ?r) (Contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) (Parent ?e) (ID ?pa)\n (StalledCompensationPathVectors $?scpv))\n (test (> (length$ $?scpv) 0))\n =>\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule AnotherMovementIsRequired\n (Stage WavefrontSchedule $?)\n ?ponder <- (Substage Ponder $?rest)\n ?f <- (Another Movement Required)\n =>\n ;this returns a tuple\n (retract ?ponder ?f)\n (assert (Substage GenerateAnalyze0 \n GenerateAnalyze \n Analyze \n SliceAnalyze \n MergeInit \n Merge \n MergeUpdate\n ReopenBlocks \n Ponder \n $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishSchedulingIntoBlock\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?rest)\n =>\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"89b26a06b9138bf2ecb6dde46001dc05e0cc4d6b","subject":"Fixed the init around message handler in InteropObject","message":"Fixed the init around message handler in InteropObject\n\nThe around message handler will not call to-pointer if it turns out that a\npointer already exists or the number stored is zero. This prevents us from\nworking with the null pointer.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/InteropObject.clp","new_file":"lib\/durandal\/modules\/core\/InteropObject.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; InteropObject.clp - An interface that exposes a pointer address. It does not\n; inherit from Object\n;------------------------------------------------------------------------------\n(defclass core::InteropObject \n \"Interface to an item outside of the CLIPS environment\"\n (is-a USER)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (visibility public)))\n\n(defmessage-handler core::InteropObject init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t (if (and (numberp ?self:pointer)\n\t\t\t\t\t\t\t\t\t (not (= 0 ?self:pointer))) then\n\t\t\t\t\t\t\t (bind ?self:pointer (to-pointer ?self:pointer))))\n\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; InteropObject.clp - An interface that exposes a pointer address. It does not\n; inherit from Object\n;------------------------------------------------------------------------------\n(defclass core::InteropObject \n \"Interface to an item outside of the CLIPS environment\"\n (is-a USER)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (visibility public)))\n\n(defmessage-handler core::InteropObject init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t (if (numberp ?self:pointer) then\n\t\t\t\t\t\t\t (bind ?self:pointer (to-pointer ?self:pointer))))\n\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"05fcdd4cec08a4cf3a4261202672c4442ae92ae0","subject":"init\/DeclareLibraryFunctions.clp: Added a library-files function","message":"init\/DeclareLibraryFunctions.clp: Added a library-files function\n\nThis function is meant to make it really easy to define the library files to\nload for a given library without having to remember complex paths\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/init\/DeclareLibraryFunctions.clp","new_file":"src\/init\/DeclareLibraryFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLibraryFunctions.clp - Defines a series of functions used to\n; streamline the loading of libraries in the adventure engine\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-library \n \"Loads an adventure engine library from the root of the src folder\"\n (?name)\n (batch* (format nil \"lib\/%s\/Library.clp\" ?name)))\n;------------------------------------------------------------------------------\n(deffunction init::library-files \n \"Loads the files that make up the target library\"\n (?offset $?names)\n (bind ?coreOffset (format nil \"lib\/%s\/%s\" ?offset \"%s\"))\n (progn$ (?a $?names)\n (batch* (format nil ?coreOffset ?a))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLibraryFunctions.clp - Defines a series of functions used to\n; streamline the loading of libraries in the adventure engine\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(deffunction load-library \n \"Loads an adventure engine library from the root of the src folder\"\n (?name)\n (batch* (format nil \"lib\/%s\/Library.clp\" ?name)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"80d4938e6330efd8b529779c9742cf387d488638","subject":"Fixed a bug with the assembler","message":"Fixed a bug with the assembler\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"Assembler.clp","new_file":"Assembler.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(defglobal MAIN ; human readable form\n ?*symbol-label-instruction* = label\n ?*symbol-terminate-instruction* = terminate\n ?*symbol-nop-instruction* = nop\n ?*symbol-add-instruction* = add\n ?*symbol-subtract-instruction* = sub\n ?*symbol-multiply-instruction* = mul\n ?*symbol-divide-instruction* = div\n ?*symbol-right-shift-instruction* = right-shift\n ?*symbol-left-shift-instruction* = left-shift\n ?*symbol-equal-instruction* = eq\n ?*symbol-not-equal-instruction* = neq\n ?*symbol-less-than-instruction* = lt\n ?*symbol-greater-than-instruction* = gt\n ?*symbol-and-instruction* = and\n ?*symbol-or-instruction* = or\n ?*symbol-not-instruction* = not\n ?*symbol-branch-instruction* = branch\n ?*symbol-load-instruction* = load\n ?*symbol-store-instruction* = store\n ?*symbol-set-instruction* = set\n ?*symbol-interrupt-instruction* = interrupt)\n;-------------------------------------------------------------------------------\n(deftemplate input-line\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot original-input\n (type STRING)\n (default ?NONE))\n (multislot raw-input))\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;-------------------------------------------------------------------------------\n(deftemplate instruction\n (slot tag \n (type SYMBOL))\n (slot arg-count\n (type INTEGER))\n (slot is-macro ; is it a convienience instruction\/operation?\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)))\n;-------------------------------------------------------------------------------\n(deffacts argument-conversion-counts\n (instruction (tag ?*symbol-terminate-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-nop-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-add-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-subtract-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-multiply-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-divide-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-right-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-left-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-less-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-greater-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-and-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-or-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-branch-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-load-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-store-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-set-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-interrupt-instruction*)\n (arg-count 1))\n (instruction (tag ?*symbol-label-instruction*)\n (arg-count 1)\n (is-macro TRUE)))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n;-------------------------------------------------------------------------------\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n;-------------------------------------------------------------------------------\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n;-------------------------------------------------------------------------------\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 1)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (original-input ?input)\n (raw-input (explode$ ?input))))\n else\n (assert (translate-input))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n(defrule invalid-line-found\n (declare (salience 2))\n (input-line (line-number ?i)\n (original-input ?line)\n (raw-input $?input))\n (test (> (length$ $?input) 4))\n =>\n (printout werror \"ERROR: line \" ?i \" is invalid\" crlf\n \" \" ?line crlf)\n (halt))\n\n(defrule is-invalid-instruction\n (declare (salience 2)) \n (input-line (raw-input ?op $?)\n (line-number ?l)\n (original-input ?input))\n (not (exists (instruction (tag ?op))))\n =>\n (printout werror \n (format nil \"ERROR: Instruction %s on line %d is invalid%n\" ?op ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n(defrule invalid-argument-count-for-operation\n (declare (salience 2))\n (input-line (raw-input ?operation $?rest)\n (line-number ?l)\n (original-input ?input))\n (instruction (tag ?operation)\n (arg-count ?ac&:(!= ?ac (length$ $?rest))))\n =>\n (printout werror \n (format nil \"ERROR: Invalid number of arguments for %s on line %d%n\"\n ?operation ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n\n(defrule process-input-line\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation $?rest)\n (line-number ?l))\n (instruction (tag ?operation)\n (arg-count =(length$ $?rest)))\n\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (arguments $?rest))))\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n;-------------------------------------------------------------------------------\n(reset) ; load the instruction information for our purposes\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(defglobal MAIN ; human readable form\n ?*symbol-label-instruction* = label\n ?*symbol-terminate-instruction* = terminate\n ?*symbol-nop-instruction* = nop\n ?*symbol-add-instruction* = add\n ?*symbol-subtract-instruction* = sub\n ?*symbol-multiply-instruction* = mul\n ?*symbol-divide-instruction* = div\n ?*symbol-right-shift-instruction* = right-shift\n ?*symbol-left-shift-instruction* = left-shift\n ?*symbol-equal-instruction* = eq\n ?*symbol-not-equal-instruction* = neq\n ?*symbol-less-than-instruction* = lt\n ?*symbol-greater-than-instruction* = gt\n ?*symbol-and-instruction* = and\n ?*symbol-or-instruction* = or\n ?*symbol-not-instruction* = not\n ?*symbol-branch-instruction* = branch\n ?*symbol-load-instruction* = load\n ?*symbol-store-instruction* = store\n ?*symbol-set-instruction* = set\n ?*symbol-interrupt-instruction* = interrupt)\n;-------------------------------------------------------------------------------\n(deftemplate input-line\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot original-input\n (type STRING)\n (default ?NONE))\n (multislot raw-input))\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;-------------------------------------------------------------------------------\n(deftemplate instruction\n (slot tag \n (type SYMBOL))\n (slot arg-count\n (type INTEGER))\n (slot is-macro ; is it a convienience instruction\/operation?\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)))\n;-------------------------------------------------------------------------------\n(deffacts argument-conversion-counts\n (instruction (tag ?*symbol-terminate-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-nop-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-add-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-subtract-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-multiply-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-divide-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-right-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-left-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-less-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-greater-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-and-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-or-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-branch-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-load-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-store-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-set-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-interrupt-instruction*)\n (arg-count 1))\n (instruction (tag ?*symbol-label-instruction*)\n (arg-count 1)\n (is-macro TRUE)))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n;-------------------------------------------------------------------------------\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n;-------------------------------------------------------------------------------\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n;-------------------------------------------------------------------------------\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 1)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (original-input ?input)\n (raw-input (explode$ ?input))))\n else\n (assert (translate-input))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n(defrule invalid-line-found\n (declare (salience 2))\n (input-line (line-number ?i)\n (original-input ?line)\n (raw-input $?input))\n (test (or (> (length$ $?input) 4)))\n =>\n (printout werror \"ERROR: line \" ?i \" is invalid\" crlf\n \" \" ?line crlf)\n (halt))\n\n(defrule is-invalid-instruction\n (declare (salience 2)) \n (input-line (raw-input ?op $?)\n (line-number ?l)\n (original-input ?input))\n (not (exists (instruction (tag ?op))))\n =>\n (printout werror \n (format nil \"ERROR: Instruction %s on line %d is invalid%n\" ?op ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n(defrule invalid-argument-count-for-operation\n (declare (salience 2))\n (input-line (raw-input ?operation $?rest)\n (line-number ?l)\n (original-input ?input))\n (instruction (tag ?operation)\n (arg-count ?ac&:(!= ?ac (length$ $?rest))))\n =>\n (printout werror \n (format nil \"ERROR: Invalid number of arguments for %s on line %d%n\"\n ?operation ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n\n(defrule process-input-line\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation $?rest)\n (line-number ?l))\n (instruction (tag ?operation)\n (arg-count =(length$ $?rest)))\n\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (arguments $?rest))))\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n;-------------------------------------------------------------------------------\n(reset) ; load the instruction information for our purposes\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"0d5d46ce7e53fd126a4f2ba57695905b4a16b65f","subject":"Added LoadEngine.clp","message":"Added LoadEngine.clp\n\nThis file loads the standard engine library.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/LoadEngine.clp","new_file":"src\/LoadEngine.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"lib\/cortex\/Library.clp\")\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/LoadEngine.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"5de3cef1e9419af70066c503e52db008c0ac1c7b","subject":"Added the license to chicanery.clp","message":"Added the license to chicanery.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery.clp","new_file":"lib\/chicanery.clp","new_contents":";------------------------------------------------------------------------------\n;electron-platform\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?mask INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?mask)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (create-accessor read))\n (multislot buttons \n (create-accessor read))\n (slot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler mouse clear primary\n ()\n (bind ?self:position (create$))\n (bind ?self:buttons (create$))\n (bind ?self:timestamp 0))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons (translate\/mouse\/buttons))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (slot-direct-delete$ keys 1 ?self:length)\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:length 1)\n ?key)\n (bind ?self:length (+ ?self:length 1))\n else\n (bind ?self:keys ?key)\n (bind ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-entries))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n(defmethod translate-menu-id\n \"Handles the case when -1 is passed\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n (return NIL))\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n; system initialization features\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n; on-resized handling\n\n(defgeneric on-resized)\n\n(defrule on-resized\n \"library defined rule which calls the on-resized method\"\n (declare (salience 10000))\n ?f <- (event resized new ?value)\n =>\n (retract ?f)\n (on-resized ?value))\n\n","old_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?mask INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?mask)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (create-accessor read))\n (multislot buttons \n (create-accessor read))\n (slot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler mouse clear primary\n ()\n (bind ?self:position (create$))\n (bind ?self:buttons (create$))\n (bind ?self:timestamp 0))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons (translate\/mouse\/buttons))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (slot-direct-delete$ keys 1 ?self:length)\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:length 1)\n ?key)\n (bind ?self:length (+ ?self:length 1))\n else\n (bind ?self:keys ?key)\n (bind ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-entries))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n(defmethod translate-menu-id\n \"Handles the case when -1 is passed\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n (return NIL))\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n; system initialization features\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n; on-resized handling\n\n(defgeneric on-resized)\n\n(defrule on-resized\n \"library defined rule which calls the on-resized method\"\n (declare (salience 10000))\n ?f <- (event resized new ?value)\n =>\n (retract ?f)\n (on-resized ?value))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"b7fd87a5ead4e1873f1ab56ff26710f093bc7349","subject":"Create task8.clp","message":"Create task8.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task8.clp","new_file":"ssu-ai-level-2\/chapter6\/task8.clp","new_contents":"(deffunction summ-iter (?n)\n (if (= ?n 1) then (return 1))\n (+ (\/ 1 (* ?n ?n)) (summ-iter (- ?n 1)))\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task8.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"82d72f5f296f0ae8e468c8918dc16c77a10757f3","subject":"Deleted the player concept for the time being","message":"Deleted the player concept for the time being\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"player.clp","new_file":"player.clp","new_contents":"","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The state data relating to the player\n;------------------------------------------------------------------------------\n(defmodule player\n (import prompt defclass input-state)\n (export defclass item))\n(defclass player::item\n (is-a USER)\n (slot title\n (type LEXEME)\n (storage local)\n (default ?NONE))\n (slot description\n (type STRING)\n (storage local)\n (default ?NONE)))\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2b5a790909688c5dd909eef7ecdb80f5876dd755","subject":"update BeerEX.clp","message":"update BeerEX.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-preferred-color\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer pale, amber, brown or dark beer? \ud83c\udf7a\")\n (relation-asserted preferred-color)\n (valid-answers pale amber brown dark))))\n\n(defrule determine-preferred-fermentation\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink top, bottom or wild fermented beer?\")\n (relation-asserted preferred-fermentation)\n (valid-answers top bottom wild))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha)? \ud83e\udd5b\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-alcohol\n (declare (salience ?*very-high-priority*))\n (driver no)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, mild, high or very high alcoholic drinks? \ud83c\udf79\")\n (relation-asserted preferred-alcohol)\n (valid-answers low mild high \"very high\"))))\n\n(defrule determine-whether-he-should-smoke-a-cigar\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to smoke a cigar? If yes, is the cigar claro, maduro or oscuro? \ud83d\udeac\")\n (relation-asserted which-cigar)\n (valid-answers claro maduro oscuro no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-whether-he-needs-to-pair-beer-with-a-meal\n (start)\n =>\n (assert (UI-state (display \"Do you need to pair beer with a meal?\")\n (relation-asserted pair-beer-with-a-meal)\n (valid-answers yes no)))\n (set-strategy depth))\n\n(defrule determine-food-style\n (pair-beer-with-a-meal yes)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (pair-beer-with-a-meal yes)\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entree, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entree cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (pair-beer-with-a-meal yes)\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entree or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entree dessert other))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage), semi-soft (Colby, Fontina, Havarti, Monterey Jack), firm\/hard \"\n \"(Gouda, Cheddar, Emmenthaler, Gruy\u00e8re, Parmesan), blue (Roquefort, Gorgonzola), \"\n \"natural-rind (Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, Lancashire) \"\n \"or washed-rind (Epoisses, Livarot, Taleggio)? \ud83e\uddc0\"))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-whether-he-should-eat-Mascarpone-with-fruit\n (which-fresh-cheese Mascarpone)\n =>\n (assert (UI-state (display \"Do you have to eat Mascarpone with fruit?\")\n (relation-asserted mascarpone-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-sof)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Emmenthaler, Gruy\u00e8re, Parmesan or other? \ud83e\uddc0\")\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Emmenthaler Gruy\u00e8re Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entree\n\n(defrule determine-which-entree-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), fish, meat, vegetables, fats \"\n \"or other?\"))\n (relation-asserted which-entree-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entree-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds) or other?\"))\n (relation-asserted which-entree-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entree-vegan\n (main-meal-for-vegan entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds), or other?\"))\n (relation-asserted which-entree-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-vegetables\n (or (which-entree-omnivorous vegetables)\n (which-entree-vegetarian vegetables)\n (which-entree-vegan vegetables))\n =>\n (assert (UI-state (display (str-cat \"Does the vegetables are root (parsnips, carrots), grilled (peppers, onions, \"\n \"mushrooms) or other?\"))\n (relation-asserted which-vegetables)\n (valid-answers root grilled other))))\n\n(defrule determine-which-fish\n (which-entree-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Does the fish is shellfish (clams, scallops, lobster, crab), bluefish (salmon, \"\n \"trout, tuna) or other? \ud83e\udd90 \ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-which-fats\n (which-entree-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Does the fats are vegetable (avocados, olive oil, peanut butter, nuts \"\n \"and seeds) or animal (duck\/pork fat, dairy)?\"))\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-meat\n (which-entree-omnivorous meat)\n =>\n (assert (UI-state (display (str-cat \"Does the meat is rich meats (beef strip loin, lamb), game birds (duck, quail, \"\n \"quinoa), braised meats (beef short-rib, pork shoulder), pork or other?\"))\n (relation-asserted which-meat)\n (valid-answers \"rich meats\" \"game birds\" \"braised meats\" pork other))))\n\n(defrule determine-which-pork\n (which-meat pork)\n =>\n (assert (UI-state (display \"Does the pork is prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Does the sausage is capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-dessert\n (or (which-entree-omnivorous dessert)\n (which-entree-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Does the dessert is creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Does the chocolate is white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n\n\n\n;(defrule determine-predominant-dish-taste\n; (start)\n; =>\n; (assert (UI-state (display \"Which is the predominant taste of the dish?\")\n; (relation-asserted predominant-dish-taste)\n; (valid-answers sweet acid spice umami \"not tasted yet\"))))\n\n;(defrule determine-dish-cooking-method\n; (start)\n; =>\n; (assert (UI-state (display (str-cat \"Does the dish cooking method is dry-heat (broiling, grilling, roasting, baking, \"\n; \"saut\u00e9ing, pan-frying, deep-frying), moist-heat (poaching, simmering, boiling, \"\n; \"steaming) or it is a combination of both (braising, stewing)?\"))\n; (relation-asserted dish-cooking-method)\n; (valid-answers dry-heat moist-heat combination \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (help \"help\")\n (why \"why\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-preferred-color\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer pale, amber, brown or dark beer? \ud83c\udf7a\")\n (relation-asserted preferred-color)\n (valid-answers pale amber brown dark))))\n\n(defrule determine-preferred-fermentation\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink top, bottom or wild fermented beer?\")\n (relation-asserted preferred-fermentation)\n (valid-answers top bottom wild))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha)? \ud83e\udd5b\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-alcohol\n (declare (salience ?*very-high-priority*))\n (driver no)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, mild, high or very high alcoholic drinks? \ud83c\udf79\")\n (relation-asserted preferred-alcohol)\n (valid-answers low mild high \"very high\"))))\n\n(defrule determine-whether-he-should-smoke-a-cigar\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to smoke a cigar? If yes, is the cigar claro, maduro or oscuro? \ud83d\udeac\")\n (relation-asserted which-cigar)\n (valid-answers claro maduro oscuro no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-whether-he-needs-to-pair-beer-with-a-meal\n (start)\n =>\n (assert (UI-state (display \"Do you need to pair beer with a meal?\")\n (relation-asserted pair-beer-with-a-meal)\n (valid-answers yes no)))\n (set-strategy depth))\n\n(defrule determine-food-style\n (pair-beer-with-a-meal yes)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (pair-beer-with-a-meal yes)\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entree, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entree cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (pair-beer-with-a-meal yes)\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entree or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entree dessert other))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage), semi-soft (Colby, Fontina, Havarti, Monterey Jack), firm\/hard \"\n \"(Gouda, Cheddar, Emmenthaler, Gruy\u00e8re, Parmesan), blue (Roquefort, Gorgonzola), \"\n \"natural-rind (Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, Lancashire) \"\n \"or washed-rind (Epoisses, Livarot, Taleggio)? \ud83e\uddc0\"))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-whether-he-should-eat-Mascarpone-with-fruit\n (which-fresh-cheese Mascarpone)\n =>\n (assert (UI-state (display \"Do you have to eat Mascarpone with fruit?\")\n (relation-asserted mascarpone-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-sof)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Emmenthaler, Gruy\u00e8re, Parmesan or other? \ud83e\uddc0\")\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Emmenthaler Gruy\u00e8re Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entree\n\n(defrule determine-which-entree-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), fish, meat, vegetables, fats \"\n \"or other?\"))\n (relation-asserted which-entree-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entree-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds) or other?\"))\n (relation-asserted which-entree-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entree-vegan\n (main-meal-for-vegan entree)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entree grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds), or other?\"))\n (relation-asserted which-entree-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-vegetables\n (or (which-entree-omnivorous vegetables)\n (which-entree-vegetarian vegetables)\n (which-entree-vegan vegetables))\n =>\n (assert (UI-state (display (str-cat \"Does the vegetables are root (parsnips, carrots), grilled (peppers, onions, \"\n \"mushrooms) or other?\"))\n (relation-asserted which-vegetables)\n (valid-answers root grilled other))))\n\n(defrule determine-which-fish\n (which-entree-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Does the fish is shellfish (clams, scallops, lobster, crab), bluefish (salmon, \"\n \"trout, tuna) or other? \ud83e\udd90 \ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-which-fats\n (which-entree-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Does the fats are vegetable (avocados, olive oil, peanut butter, nuts \"\n \"and seeds) or animal (duck\/pork fat, dairy)?\"))\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-meat\n (which-entree-omnivorous meat)\n =>\n (assert (UI-state (display (str-cat \"Does the meat is rich meats (beef strip loin, lamb), game birds (duck, quail, \"\n \"quinoa), braised meats (beef short-rib, pork shoulder), pork or other?\"))\n (relation-asserted which-meat)\n (valid-answers \"rich meats\" \"game birds\" \"braised meats\" pork other))))\n\n(defrule determine-which-pork\n (which-meat pork)\n =>\n (assert (UI-state (display \"Does the pork is prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Does the sausage is capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-dessert\n (or (which-entree-omnivorous dessert)\n (which-entree-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Does the dessert is creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Does the chocolate is white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n\n\n\n;(defrule determine-predominant-dish-taste\n; (start)\n; =>\n; (assert (UI-state (display \"Which is the predominant taste of the dish?\")\n; (relation-asserted predominant-dish-taste)\n; (valid-answers sweet acid spice umami \"not tasted yet\"))))\n\n;(defrule determine-dish-cooking-method\n; (start)\n; =>\n; (assert (UI-state (display (str-cat \"Does the dish cooking method is dry-heat (broiling, grilling, roasting, baking, \"\n; \"saut\u00e9ing, pan-frying, deep-frying), moist-heat (poaching, simmering, boiling, \"\n; \"steaming) or it is a combination of both (braising, stewing)?\"))\n; (relation-asserted dish-cooking-method)\n; (valid-answers dry-heat moist-heat combination \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"d3ca6b6632a6e5b0b7f17f6c2f0d73914849da05","subject":"src\/tools\/conv\/gl\/Types\/FileRelated.clp: Removed the message template","message":"src\/tools\/conv\/gl\/Types\/FileRelated.clp: Removed the message template\n\nThis has been done because cortex already defines one.\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/conv\/gl\/Types\/FileRelated.clp","new_file":"src\/tools\/conv\/gl\/Types\/FileRelated.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FileRelated.clp - Defines file related objects and templates\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a Object)\n (slot file-id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:file-id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:file-id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a Object)\n (slot index)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::heading-span\n \"Defines a span between two different headings\"\n (is-a Object)\n (slot header-name)\n (slot from)\n (slot to)\n (multislot contents))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FileRelated.clp - Defines file related objects and templates\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a Object)\n (slot file-id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:file-id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:file-id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a Object)\n (slot index)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::heading-span\n \"Defines a span between two different headings\"\n (is-a Object)\n (slot header-name)\n (slot from)\n (slot to)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c76cd9ef5879dd3c76da740cc7d8b931c3117385","subject":"Fixed a bug in define-header-spans","message":"Fixed a bug in define-header-spans\n\nI had marked the type of the file-line to be header when it should be heading.\nThis has been fixed.\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans\n \"Defines spans between headers\"\n (file-line (type heading)\n (parent ?parent)\n (index ?i))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(< ?i2 ?i)))\n =>\n (bind ?difference (- ?i ?i2))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans\n \"Defines spans between headers\"\n (file-line (type header)\n (parent ?parent)\n (index ?i))\n (file-line (type header)\n (parent ?parent)\n (index ?i2&:(< ?i2 ?i)))\n =>\n (bind ?difference (- ?i ?i2))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"b233c6fdc48323d8f301d7253d4701e4f511d8f9","subject":"Fixed an error in merge-three-line-headers","message":"Fixed an error in merge-three-line-headers\n\nI forgot to rename the contents variable to c in the right hand side of the\nrule. This has been corrected\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?contents *\/)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"6786a06259327f161ec0cf351e030c305eb7083b","subject":"update beerex.clp","message":"update beerex.clp","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beerex.clp","new_file":"clips\/beerex.clp","new_contents":"\n;;;===============================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===============================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (range -1.0 1.0)\n (default 1.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clips\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?attribute1 ?attribute2)\n (< (fact-slot-value ?attribute1 certainty) (fact-slot-value ?attribute2 certainty)))\n\n(deffunction combine-certainty-factors (?x ?y)\n (if (and (> ?x 0) (> ?y 0))\n then (bind ?c (- (+ ?x ?y) (* ?x ?y)))\n else (if (and (< ?x 0) (< ?y 0))\n then (bind ?c (+ (+ ?x ?y) (* ?x ?y)))\n else (bind ?c (\/ (+ ?x ?y ) (- 1 (min (abs ?x) (abs ?y)))))))\n ?c)\n\n(deffunction get-explanation ()\n (bind ?explanation (format nil \"%s %n%n\" \"*... for the following reasons:*\"))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-scenario)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-preference)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-main-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-specific-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n ?explanation)\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clips\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clips\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (combine-certainty-factors ?certainty1 ?certainty2))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule clean-working-memory-and-print-results\n (declare (salience ?*low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (bind ?beers \"\")\n (bind ?attributes (sort sort-certainties (find-all-facts ((?a attribute)) (eq ?a:name beer))))\n (progn$ (?a ?attributes)\n (if (< (member$ ?a ?attributes) 5)\n then (bind ?beers (str-cat ?beers (format nil \"%s with certainty %2d%% %n\" (fact-slot-value ?a value)\n (* (fact-slot-value ?a certainty) 100)))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n%s %n%s\" \"*\u2705 Done. I have selected these beer styles for you...*\"\n ?beers (get-explanation))))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (do-for-all-facts ((?a attribute)) TRUE (retract ?a))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq (get-strategy) random)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"random-question\" ?rule) FALSE)\n then (refresh ?rule))))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))\n","old_contents":"\n;;;==========================================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink with a meal.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===========================================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (range -1.0 1.0)\n (default 1.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clips\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?attribute1 ?attribute2)\n (< (fact-slot-value ?attribute1 certainty) (fact-slot-value ?attribute2 certainty)))\n\n(deffunction combine-certainty-factors (?x ?y)\n (if (and (> ?x 0) (> ?y 0))\n then (bind ?c (- (+ ?x ?y) (* ?x ?y)))\n else (if (and (< ?x 0) (< ?y 0))\n then (bind ?c (+ (+ ?x ?y) (* ?x ?y)))\n else (bind ?c (\/ (+ ?x ?y ) (- 1 (min (abs ?x) (abs ?y)))))))\n ?c)\n\n(deffunction get-explanation ()\n (bind ?explanation (format nil \"%s %n%n\" \"*... for the following reasons:*\"))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-scenario)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-preference)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-main-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-specific-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n ?explanation)\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clips\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clips\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (combine-certainty-factors ?certainty1 ?certainty2))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule clean-working-memory-and-print-results\n (declare (salience ?*low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (bind ?beers \"\")\n (bind ?attributes (sort sort-certainties (find-all-facts ((?a attribute)) (eq ?a:name beer))))\n (progn$ (?a ?attributes)\n (if (< (member$ ?a ?attributes) 5)\n then (bind ?beers (str-cat ?beers (format nil \"%s with certainty %2d%% %n\" (fact-slot-value ?a value)\n (* (fact-slot-value ?a certainty) 100)))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n%s %n%s\" \"*\u2705 Done. I have selected these beer styles for you...*\"\n ?beers (get-explanation))))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (do-for-all-facts ((?a attribute)) TRUE (retract ?a))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq (get-strategy) random)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"random-question\" ?rule) FALSE)\n then (refresh ?rule))))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"472aef300229d7f6843c7857e20b2c57ab4187b9","subject":"update BeerEX.bot.py","message":"update BeerEX.bot.py\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/gui-interaction.clp","new_file":"clips\/gui-interaction.clp","new_contents":"\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?fact <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?fact (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id)\n ?fact2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?fact <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?fact)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id ?response)\n ?fact2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?fact1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?fact2 <- (UI-state (id ?nid))\n =>\n (modify ?fact1 (sequence ?b ?id ?e))\n (retract ?fact2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?fact2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?fact1)\n (if (neq ?response ?expected)\n then (modify ?fact2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?fact <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?fact))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?fact <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?fact))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?fact1 <- (prev ?id)\n ?fact2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?pid))\n (do-for-fact ((?f ?relation)) (neq ?relation start) (retract ?f))\n (do-for-all-facts ((?u UI-state) (?s state-list)) (not (member$ ?u:id ?s:sequence)) (retract ?u))\n (halt))\n","old_contents":"\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?fact <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?fact (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id)\n ?fact2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?fact <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?fact)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id ?response)\n ?fact2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?fact1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?fact2 <- (UI-state (id ?nid))\n =>\n (modify ?fact1 (sequence ?b ?id ?e))\n (retract ?fact2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?fact1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?fact2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?fact1)\n (if (neq ?response ?expected)\n then (modify ?fact2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?fact <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?fact))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?fact <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?fact))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?fact1 <- (prev ?id)\n ?fact2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?fact1)\n (modify ?fact2 (current ?pid))\n (do-for-fact ((?f ?relation)) (neq ?relation start) (retract ?f))\n (halt))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"97e7d165e65695b918cc0b9885c6a0f98218ca7d","subject":"update beer-questions.clp","message":"update beer-questions.clp","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n \"Classic topping pizzas pair well with crisp and clean beers.\"\n \"Meat topping pizzas pair well with hoppy and bitter beers.\"\n \"Vegetables.\"\n \"Cheese topping pizzas pair well with fruity and spicy beers.\"))\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and\n \"have a very creamy taste and soft texture.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \")\n (why (str-cat \" Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \")\n (why (str-cat \" Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm-hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \")\n (why (str-cat \" Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \")\n (why (str-cat \" Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \")\n (why \" Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \"))\n (why (str-cat \" Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \")\n (why (str-cat \" Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entree-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Fish_ pair well with the bitterness of the \"\n \"English-Style Bitter and the sweetness of the \"\n \"English-Style Pale Ale.\")\n (str-cat \" _Meat_ pairs well with Scottish-Style Ales.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" With _fats_ strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entree-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entree-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \ud83c\udf76\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n \"Classic topping pizzas pair well with crisp and clean beers.\"\n \"Meat topping pizzas pair well with hoppy and bitter beers.\"\n \"Vegetables.\"\n \"Cheese topping pizzas pair well with fruity and spicy beers.\"))\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and\n \"have a very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \ud83e\uddc0\")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \ud83e\uddc0\")\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entr\u00e9e-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83d\udc1f\ud83e\udd90 _Fish_ pair well with the bitterness of the \"\n \"English-Style Bitter and the sweetness of the \"\n \"English-Style Pale Ale.\")\n (str-cat \"\ud83e\udd69\ud83c\udf56 _Meat_ pairs well with Scottish-Style Ales.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd5c With _fats_ strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entr\u00e9e-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd51 _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entr\u00e9e-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd51 _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \ud83e\udd91\ud83d\udc19\ud83e\udd90\ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \ud83e\udd91\ud83d\udc19\")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \ud83e\udd90\")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"1d2efcf4df5ab962592b8c43b59a8cd41d9c3bf1","subject":"Completely rewritten.","message":"Completely rewritten.\n\n","repos":"ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror","old_file":"src\/examples\/jess\/JadeAgent.clp","new_file":"src\/examples\/jess\/JadeAgent.clp","new_contents":"; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n;(send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","old_contents":"; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact (myname \n(send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (myname ?n)\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n;(reset) Not use reset \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"a9820159f680c3133965ea935d2d3158d1144ba0","subject":"src\/lib\/widget\/Library.clp: Updated the started on date","message":"src\/lib\/widget\/Library.clp: Updated the started on date\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"src\/lib\/widget\/Library.clp","new_file":"src\/lib\/widget\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"f5de0edf28be1f6e4e450ae92638e00bd8cd6a09","subject":"Added a third supertype to the llvm::Function class in clips","message":"Added a third supertype to the llvm::Function class in clips\n\nThis third supertype is the List type so that we can store the blocks that make\nup the target function.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/llvm\/LLVMFunction.clp","new_file":"lib\/durandal\/modules\/llvm\/LLVMFunction.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMFunction.clp - Represents the LLVM Function class\n;------------------------------------------------------------------------------\n(defclass llvm::Function\n (is-a GlobalValue Diplomat List)\n (slot ReturnType)\n (slot FunctionType)\n (slot IsVarArg (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IntrinsicID)\n (slot IsIntrinsic (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CallingConvention \n (type SYMBOL)\n (allowed-values Unknown intel-ocl-bi spir-kernel spir-func\n HiPE mblaze-svol mblaze-intr ptx-device ptx-kernel x86-thiscall\n msp430-intr arm-aapcs-vfp arm-aapcs arm-apcs x86-fastcall x86-stdcall\n GHC Cold Fast C))\n (slot HasGC (type SYMBOL) (allowed-values FALSE TRUE))\n (slot GC)\n (slot DoesNotAccessMemory (type SYMBOL) (allowed-values FALSE TRUE))\n (slot OnlyReadsMemory (type SYMBOL) (allowed-values FALSE TRUE))\n (slot DoesNotReturn (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUWTable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot NeedsUnwindTableEntry (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasStructRetAttr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDefTriviallyDead (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CallsFunctionThatReturnsTwice \n (type SYMBOL) \n (allowed-values FALSE TRUE)) \n (slot EntryBlock)\n (multislot Arguments))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-GC after \n (?str)\n (llvm-function-set-gc ?self:pointer ?str))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function clear-GC primary \n ()\n (llvm-function-clear-gc ?self:pointer)\n (bind ?self:GC \"\"))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function delete-body primary \n ()\n (llvm-function-delete-body ?self:pointer)\n (bind ?self:contents (create$)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function remove-from-parent primary\n ()\n (llvm-function-remove-from-parent ?self:pointer)\n (bind ?self:parent nil))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function erase-from-parent primary\n ()\n (llvm-function-erase-from-parent ?self:pointer)\n (delete-instance))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotAccessMemory after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-access-memory \n ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function set-does-not-alias primary\n (?index)\n (llvm-function-set-does-not-alias ?self:pointer ?index)) \n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function set-does-not-capture primary\n (?index)\n (llvm-function-set-does-not-capture ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotThrow after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-throw ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-HasUWTable after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-has-uw-table ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotReturn after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-return ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-OnlyReadsMemory after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-only-reads-memory ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function drop-all-references primary\n ()\n (llvm-function-drop-all-references \n ?self:pointer))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function does-not-alias primary\n (?index)\n (llvm-function-set-does-not-alias ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function does-not-capture primary\n (?index)\n (llvm-function-does-not-capture ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function get-param-alignment primary\n (?index)\n (llvm-function-get-param-alignment ?self:pointer ?index))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMFunction.clp - Represents the LLVM Function class\n;------------------------------------------------------------------------------\n(defclass llvm::Function\n (is-a GlobalValue Diplomat)\n (slot ReturnType)\n (slot FunctionType)\n (slot IsVarArg (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IntrinsicID)\n (slot IsIntrinsic (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CallingConvention \n (type SYMBOL)\n (allowed-values Unknown intel-ocl-bi spir-kernel spir-func\n HiPE mblaze-svol mblaze-intr ptx-device ptx-kernel x86-thiscall\n msp430-intr arm-aapcs-vfp arm-aapcs arm-apcs x86-fastcall x86-stdcall\n GHC Cold Fast C))\n (slot HasGC (type SYMBOL) (allowed-values FALSE TRUE))\n (slot GC)\n (slot DoesNotAccessMemory (type SYMBOL) (allowed-values FALSE TRUE))\n (slot OnlyReadsMemory (type SYMBOL) (allowed-values FALSE TRUE))\n (slot DoesNotReturn (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUWTable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot NeedsUnwindTableEntry (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasStructRetAttr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDefTriviallyDead (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CallsFunctionThatReturnsTwice \n (type SYMBOL) \n (allowed-values FALSE TRUE)) \n (slot EntryBlock)\n (multislot Arguments))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-GC after \n (?str)\n (llvm-function-set-gc ?self:pointer ?str))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function clear-GC primary \n ()\n (llvm-function-clear-gc ?self:pointer)\n (bind ?self:GC \"\"))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function delete-body primary \n ()\n (llvm-function-delete-body ?self:pointer)\n (bind ?self:contents (create$)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function remove-from-parent primary\n ()\n (llvm-function-remove-from-parent ?self:pointer)\n (bind ?self:parent nil))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function erase-from-parent primary\n ()\n (llvm-function-erase-from-parent ?self:pointer)\n (delete-instance))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotAccessMemory after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-access-memory \n ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function set-does-not-alias primary\n (?index)\n (llvm-function-set-does-not-alias ?self:pointer ?index)) \n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function set-does-not-capture primary\n (?index)\n (llvm-function-set-does-not-capture ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotThrow after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-throw ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-HasUWTable after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-has-uw-table ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-DoesNotReturn after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-does-not-return ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function put-OnlyReadsMemory after\n (?symbol)\n (if ?symbol then\n (llvm-function-set-only-reads-memory ?self:pointer)))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function drop-all-references primary\n ()\n (llvm-function-drop-all-references \n ?self:pointer))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function does-not-alias primary\n (?index)\n (llvm-function-set-does-not-alias ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function does-not-capture primary\n (?index)\n (llvm-function-does-not-capture ?self:pointer ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler llvm::Function get-param-alignment primary\n (?index)\n (llvm-function-get-param-alignment ?self:pointer ?index))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9951816212bad396997379d6dc20203523cb467b","subject":"Finished a prototype GLAPIConversion expert system","message":"Finished a prototype GLAPIConversion expert system\n\nI still need to generate the actual code but this is a start\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defrule types::FunctionBuilder\n\t\t\t\"Builds C functions\"\n\t\t\t(is-a Object)\n\t\t\t(multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-contents ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n (declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t (parent ?p) \n\t\t\t\t\t\t\t (index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t(parent ?p)\n\t\t\t\t(contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n ?fct <- (message (to grouping-update)\n\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d56f8643a99f7928db5f3cb5657984406bac56d5","subject":"Added the rooms interactive game","message":"Added the rooms interactive game\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"games\/dev\/rooms.clp","new_file":"games\/dev\/rooms.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine \n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Inspect.clp - a simple inspect the room game\n;------------------------------------------------------------------------------\n; Required module implementations\n;------------------------------------------------------------------------------\n(defmodule pre-prompt\n (import constants defglobal router-out))\n(defrule pre-prompt::print-objectives\n =>\n (printout ?*router-out* \n \"This tools is meant to automate the construction of rooms\" crlf))\n(defmodule post-prompt\n (import constants \n defglobal \n router-out))\n;(defrule post-prompt::say-thanks\n; =>\n; (printout ?*router-out*\n; \"Thanks for playing!\" crlf))\n\n;------------------------------------------------------------------------------\n\n(defmodule game \n (import constants ?ALL)\n (import core ?ALL)\n (import world ?ALL)\n (import prompt defclass input-state))\n\n(definstances game::room-and-items\n (self of player)\n (entry of room \n (title \"\")\n (description \"A non descript room\")))\n\n(defrule game::handle-look-keyword:no-extra-input\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input look))\n (object (is-a player)\n (name [self])\n (current-room ?room))\n (object (is-a room)\n (name ?room)\n (description ?description))\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (printout ?*router-out* \n \"You are in a \" ?description crlf))\n\n(defrule game::handle-go-keyword\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input go ?direction))\n =>\n (modify-instance ?f (processed-input TRUE))\n (assert (go ?direction)))\n(defrule game::go-north\n ?f <- (go north)\n ?p <- (object (is-a player)\n (name [self])\n (current-room ?room))\n (object (is-a room)\n (name ?room)\n (north ?north))\n =>\n (retract ?f)\n (assert (go to room north ?north)))\n\n\n\n(defrule game::go-south\n ?f <- (go south)\n ?p <- (object (is-a player)\n (name [self])\n (current-room ?room))\n (object (is-a room)\n (name ?room)\n (south ?south))\n =>\n (retract ?f)\n (assert (go to room south ?south)))\n(defrule game::go-west\n ?f <- (go west)\n ?p <- (object (is-a player)\n (name [self])\n (current-room ?room))\n (object (is-a room)\n (name ?room)\n (west ?west))\n =>\n (retract ?f)\n (assert (go to room west ?west)))\n(defrule game::go-east\n ?f <- (go east)\n ?p <- (object (is-a player)\n (name [self])\n (current-room ?room))\n (object (is-a room)\n (name ?room)\n (east ?east))\n =>\n (retract ?f)\n (assert (go to room east ?east)))\n\n(defrule game::go-to-room:nope\n ?f <- (go to room ?dir FALSE)\n =>\n (retract ?f)\n (printout ?*router-out* \n \"Can't go \" ?dir \" from this room!\" crlf))\n\n(defrule game::go-to-room\n ?f <- (go to room ? ?target&~FALSE)\n =>\n (retract ?f)\n (modify-instance [self]\n (current-room ?target)))\n\n(defrule game::list-inventory\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input inventory))\n (object (is-a player)\n (name [self])\n (items $?items))\n =>\n (printout ?*router-out*\n tab \"Currently have in inventory:\" crlf)\n (progn$ (?item ?items)\n (printout ?*router-out*\n tab tab \"- \" (send ?item get-title) crlf))\n (modify-instance ?f \n (processed-input TRUE)))\n\n(defrule game::inspect-item\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input inspect ?item))\n (object (is-a item)\n (title ?item)\n (description ?desc)\n (name ?n))\n (object (is-a player)\n (name [self])\n (items $? ?n $?))\n =>\n (modify-instance ?f \n (processed-input TRUE))\n (printout ?*router-out* tab ?desc crlf))\n\n(defrule game::inspect-item:not-in-inventory\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input inspect ?item))\n (object (is-a item)\n (title ?item)\n (name ?n))\n (object (is-a player)\n (name [self])\n (items $?elements&:(not (member$ ?n ?elements))))\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (printout ?*router-out* \n tab \"This is not an item in your inventory\" crlf))\n\n(defrule game::inspect-item:doesn't-exist\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input inspect ?item))\n (not (exists (object (is-a item)\n (title ?item))))\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (printout ?*router-out* \n tab \"This is not an item in your inventory\" crlf))\n\n(defrule game::list-rooms\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input list rooms))\n =>\n (printout ?*router-out*\n tab \"Currently defined rooms\" crlf)\n (do-for-all-instances ((?r room))\n TRUE\n (printout ?*router-out*\n tab tab (instance-name ?r) crlf)))\n(defrule game::new-room::with-title\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input new-room ?room-name&:(symbolp ?room-name)))\n\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (printout ?*router-out* \n \"Made a new blank room named: \" \n (make-instance ?room-name of room) crlf))\n\n(defrule game::new-room\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input new-room))\n\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (printout ?*router-out* \n \"Made a new blank room named: \" \n (make-instance of room) crlf))\n\n(defrule game::set-title\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (input set-title ?room ?title))\n (object (is-a room)\n (name ?room))\n =>\n (modify-instance ?f\n (processed-input TRUE))\n (modify-instance ?room\n (title ?title))\n (printout ?*router-out*\n \"Set \" ?room \" to \" ?title crlf))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'games\/dev\/rooms.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6662ea51b976e6f67004b04fbad7a3aa16d130fb","subject":"Simplified the extended memory analysis rules by adding more of them","message":"Simplified the extended memory analysis rules by adding more of them\n\nI realized that the rules checking load to store, store to store, and store to\nload were a tad complex in that a bunch of data was generated but never\nactually used until the third conditional element was evaluated in the network.\nThe problem with this layout is that it is possible to do partial evaluation\nas we are matching. Thus, I created rules that generated unconditional\ndependency for the following load and store instructions if the target Load\nor Store had an unknown memory dependency. This reduces the total number of\nmatches for each rule. The flip side is that I have to introduce the parent\nbasic block and use a multifield match ($? ?t0 $? ?t1 $?) to find the elements\nthat come after ?t0 that are stores and loads.\n\nFor the cases when the memory target was not UNKNOWN I set it up so that it\nused the same basic block acquisition method but just checked the MemoryTarget\nof the second instruction to check to see if it is the same symbol. This change\nseems to make the code significantly simpler (and by proxy somewhat faster).\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/BlockDependencyCreation.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/BlockDependencyCreation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockDependencyCreation.clp - Contains rules pertaining to the creation of\n; data dependencies between different instructions inside of a basic block\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency-Call\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a CallInstruction) (parent ?p) (id ?t0) \n\t\t\t\t\t (ArgumentOperands $? ?o $?))\n\t\t\t(object (is-a Instruction) (id ?o) (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency \n\t\t\t?i0 <- (object (is-a Instruction&~CallInstruction) (parent ?p) (id ?t0) \n\t\t\t\t\t\t\t\t(Operands $? ?o $?))\n\t\t\t(object (is-a Instruction) (id ?o) (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-WritesToMemory\n\t\t\t(object (is-a BasicBlock) (id ?v) (contents $?before ?n0 $?))\n\t\t\t(object (is-a CallInstruction) (id ?n0) (parent ?v) \n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?before)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-HasSideEffects\n\t\t\t(Stage Analysis $?)\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $?a ?n0 $?))\n\t\t\t(object (is-a CallInstruction) (id ?n0) (parent ?p)\n\t\t\t\t\t (MayHaveSideEffects TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?a)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-ModifiesMemory\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call could modify memory.\"\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p)\n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-InlineAsm\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p) \n\t\t\t\t\t (IsInlineAsm TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-SideEffects\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call has side effects.\"\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p)\n\t\t\t\t\t (MayHaveSideEffects TRUE)) \n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Set\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency FALSE))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?inst (HasCallDependency TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Ignore\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency TRUE))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::StoreDependency-UNKNOWN\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (MemoryTarget UNKNOWN)\n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction|LoadInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::LoadDependency-UNKNOWN\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (MemoryTarget UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>LoadDependency\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>StoreDependency\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Load=>StoreDependency\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN)) \n\t\t\t(object (is-a BasicBlock)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockDependencyCreation.clp - Contains rules pertaining to the creation of\n; data dependencies between different instructions inside of a basic block\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency-Call\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a CallInstruction) (parent ?p) (id ?t0) \n\t\t\t\t\t (ArgumentOperands $? ?o $?))\n\t\t\t(object (is-a Instruction) (id ?o) (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency \n\t\t\t?i0 <- (object (is-a Instruction&~CallInstruction) (parent ?p) (id ?t0) \n\t\t\t\t\t\t\t\t(Operands $? ?o $?))\n\t\t\t(object (is-a Instruction) (id ?o) (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-WritesToMemory\n\t\t\t(object (is-a BasicBlock) (id ?v) (contents $?before ?n0 $?))\n\t\t\t(object (is-a CallInstruction) (id ?n0) (parent ?v) \n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?before)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-HasSideEffects\n\t\t\t(Stage Analysis $?)\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $?a ?n0 $?))\n\t\t\t(object (is-a CallInstruction) (id ?n0) (parent ?p)\n\t\t\t\t\t (MayHaveSideEffects TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?a)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-ModifiesMemory\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call could modify memory.\"\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p)\n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-InlineAsm\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p) \n\t\t\t\t\t (IsInlineAsm TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-SideEffects\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call has side effects.\"\n\t\t\t(object (is-a CallInstruction) (id ?name) (parent ?p)\n\t\t\t\t\t (MayHaveSideEffects TRUE)) \n\t\t\t(object (is-a BasicBlock) (id ?p) (contents $? ?name $?rest))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) (id ?z) (parent ?p) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Set\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency FALSE))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?inst (HasCallDependency TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Ignore\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency TRUE))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::StoreToLoadDependency\n\t\t\t(object (is-a StoreInstruction) (parent ?p) (id ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0))\n\t\t\t(object (is-a LoadInstruction) (parent ?p) (id ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(< ?ti0 ?ti1)) (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::StoreToStoreDependency\n\t\t\t(object (is-a StoreInstruction) (parent ?p) (id ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0))\n\t\t\t(object (is-a StoreInstruction) (parent ?p) (id ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(< ?ti0 ?ti1)) (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::LoadToStoreDependency\n\t\t\t(object (is-a LoadInstruction) (parent ?p) (id ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0)) \n\t\t\t(object (is-a StoreInstruction) (parent ?p) (id ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(< ?ti0 ?ti1)) (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0ade47bd7eb0e16c0643929d276e4129b0c10401","subject":"Removed the commented out code for Hint.clp as it's no longer necessary.","message":"Removed the commented out code for Hint.clp as it's no longer necessary.\n\nUsing the doom sector trick I can get paths through a loop without needing to\nfigure out where the backedge is :D.\n","repos":"DrItanium\/LibExpertSystem,DrItanium\/LibExpertSystem","old_file":"clips\/Types\/Hint.clp","new_file":"clips\/Types\/Hint.clp","new_contents":";------------------------------------------------------------------------------\n; Hint.clp - Contains the basic hint type plus a few ease of access sub types\n; Hints are my way of quickly creating objects that map a single\n; object to a series of other objects. A hint also contains a type\n; field that allows hints to be further constrained by another type.\n; Suprisingly enough hints are quite useful as they allow facts to\n; be created with a minimal amount of effort yet are very expressive\n; in their contents. \n;\n; They can also keep track of the number of references they have\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass Hint (is-a List)\n (slot Type (visibility public) (default nil))\n (slot Point (default nil))\n (slot ReferenceCount (visibility public) (type NUMBER)))\n\n(defmessage-handler Hint .IncrementReferenceCount ()\n (bind ?self:ReferenceCount (+ ?self:ReferenceCount 1)))\n\n(defmessage-handler Hint .DecrementReferenceCount ()\n (bind ?self:ReferenceCount (- ?self:ReferenceCount 1)))\n;------------------------------------------------------------------------------\n(deffunction hints-of-type-with-point (?type ?point)\n \"Gets all hints with the specified type and point\"\n (find-all-instances ((?h Hint)) (and (eq ?type (send ?h get-Type))\n\t\t\t\t\t\t\t\t\t\t\t (eq ?point (send ?h get-Point)))))\n;------------------------------------------------------------------------------\n(deffunction hints-of-type (?type)\n \"Returns all hints of a given type\"\n (find-all-instances ((?h Hint)) (eq ?type (send ?h get-Type))))\n;------------------------------------------------------------------------------\n(deffunction hintp (?instance)\n (if (or (instance-namep ?instance) \n\t\t(instance-addressp ?instance)) then\n (bind ?conv ?instance)\n else\n (bind ?conv (symbol-to-instance-name ?instance)))\n (return (eq (class ?conv) Hint)))\n;------------------------------------------------------------------------------\n(defclass Path (is-a Hint)\n (slot ExitBlock (type SYMBOL))\n (slot Closed (type SYMBOL) (allowed-values FALSE TRUE)))\n\n(defmessage-handler Path init after ()\n (bind ?self:Type Path))\n\n;------------------------------------------------------------------------------\n(defclass Hierarchy (is-a Hint))\n\n(defmessage-handler Hierarchy init after ()\n (bind ?self:Type Hierarchy))\n\n;------------------------------------------------------------------------------\n(defclass FrequencyAnalysis (is-a Hint)\n (slot Frequency (type NUMBER) (range 0 ?VARIABLE)))\n\n(defmessage-handler FrequencyAnalysis init after ()\n (bind ?self:Type FrequencyAnalysis))\n\n(defmessage-handler FrequencyAnalysis .IncrementFrequency ()\n (bind ?self:Frequency (+ 1 ?self:Frequency)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n; Hint.clp - Contains the basic hint type plus a few ease of access sub types\n; Hints are my way of quickly creating objects that map a single\n; object to a series of other objects. A hint also contains a type\n; field that allows hints to be further constrained by another type.\n; Suprisingly enough hints are quite useful as they allow facts to\n; be created with a minimal amount of effort yet are very expressive\n; in their contents. \n;\n; They can also keep track of the number of references they have\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass Hint (is-a List)\n (slot Type (visibility public) (default nil))\n (slot Point (default nil))\n (slot ReferenceCount (visibility public) (type NUMBER)))\n\n(defmessage-handler Hint .IncrementReferenceCount ()\n (bind ?self:ReferenceCount (+ ?self:ReferenceCount 1)))\n\n(defmessage-handler Hint .DecrementReferenceCount ()\n (bind ?self:ReferenceCount (- ?self:ReferenceCount 1)))\n;------------------------------------------------------------------------------\n(deffunction hints-of-type-with-point (?type ?point)\n \"Gets all hints with the specified type and point\"\n (find-all-instances ((?h Hint)) (and (eq ?type (send ?h get-Type))\n\t\t\t\t\t\t\t\t\t\t\t (eq ?point (send ?h get-Point)))))\n;------------------------------------------------------------------------------\n(deffunction hints-of-type (?type)\n \"Returns all hints of a given type\"\n (find-all-instances ((?h Hint)) (eq ?type (send ?h get-Type))))\n;------------------------------------------------------------------------------\n(deffunction hintp (?instance)\n (if (or (instance-namep ?instance) \n\t\t(instance-addressp ?instance)) then\n (bind ?conv ?instance)\n else\n (bind ?conv (symbol-to-instance-name ?instance)))\n (return (eq (class ?conv) Hint)))\n;------------------------------------------------------------------------------\n(defclass Path (is-a Hint)\n (slot ExitBlock (type SYMBOL))\n (slot Closed (type SYMBOL) (allowed-values FALSE TRUE)))\n; (multislot BackEdgesVisited))\n\n(defmessage-handler Path init after ()\n (bind ?self:Type Path))\n\n;(defmessage-handler Path .AddBackEdge (?be)\n; (bind ?self:BackEdgesVisited (create$ ?self:BackEdgesVisited ?be)))\n;------------------------------------------------------------------------------\n(defclass Hierarchy (is-a Hint))\n\n(defmessage-handler Hierarchy init after ()\n (bind ?self:Type Hierarchy))\n\n;------------------------------------------------------------------------------\n(defclass FrequencyAnalysis (is-a Hint)\n (slot Frequency (type NUMBER) (range 0 ?VARIABLE)))\n\n(defmessage-handler FrequencyAnalysis init after ()\n (bind ?self:Type FrequencyAnalysis))\n\n(defmessage-handler FrequencyAnalysis .IncrementFrequency ()\n (bind ?self:Frequency (+ 1 ?self:Frequency)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"541fea1d5b7dc1a062922a22d4b8c4706f27fa8c","subject":"Add chapter 2 tasks","message":"Add chapter 2 tasks\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter-2.clp","new_file":"ssu-ai-level-2\/chapter-2.clp","new_contents":"\/\/ First task\n\/\/ Students\n(deffacts students\n (student LelyakinMA 4)\n (student ArutunyaAS 4)\n (student KefalicsAI 1)\n (student BelokobylskySA 2)\n)\n\n(facts)\n\n(retract 2)\n(retract 3)\n\n(assert (student KefalicsAI 2))\n\n(facts)\n\n\n\/\/ Trains\n(deffacts trains\n (train 11 Saratov 11)\n (train 22 Engels 21)\n (train 33 Kazan 22)\n)\n\n\n(assert (train 44 Samara 10))\n(assert (train 55 Volgograd 08))\n\n(retract 1 4)\n\n(retract 2 3)\n\n(assert (train 22 Moscow 01))\n(assert (train 33 Kazan 00))\n\n\n\/\/ Employees\n(assert (sotrudnik LelyakinMA 1)\n (sotrudnik GerasimovVD 2)\n (sotrudnik VonnegutKG 3)\n (sotrudnik PushkinAS 3)\n)\n\n(retract 1)\n\n(retract 3)\n(assert (sotrudnik VasilevKD 3))\n\n\n\/\/ Products\n(assert (IceCream Russia 10 1)\n\t\t(ApelsineJuce Russia 20 2)\n\t\t(WaterMelone Russia 30 3)\n\t\t(Liberty USA 1000 99)\n)\n\n(facts)\n\n(retract 2)\n(ApelsineJuce Russia 19 2)\n\n(retract 4)\n(Liberty USA 0 99)","old_contents":"\/\/ First task\n(deffacts students\n (student LelyakinMA 4)\n (student ArutunyaAS 4)\n (student KefalicsAI 1)\n (student BelokobylskySA 2)\n)\n\n(facts)\n\n(retract 2)\n(retract 3)\n\n(assert (student KefalicsAI 2))\n\n(facts)\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"4b74b6a2406f9207a17ea4ab0d47a8c32776118c","subject":"Added a simple run script to make things easier to keep track of","message":"Added a simple run script to make things easier to keep track of\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"run.clp","new_file":"run.clp","new_contents":"(batch* constants.clp)\n(batch* core.clp)\n(batch* configuration.clp)\n(batch* world.clp)\n(batch* prompt.clp)\n; code goes here\n(batch* init.clp)\n(reset)\n(run)\n;(exit)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'run.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"1131ae409fcbf6211668c603898d522e1bde1493","subject":"Modified the assert-string message in Environment.clp","message":"Modified the assert-string message in Environment.clp\n\nThe assert-string message no longer uses format because it isn't necessary due\nto the env-assert-string function\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment (is-a Object InteropObject))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment (is-a Object InteropObject))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string \n ?self:pointer \n (format nil \n \"(assert (%s))\" (implode$ $?elements)))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"05f6c5ab9325ba2f163802e7235b955d5121ce99","subject":"Simplified the thing type","message":"Simplified the thing type\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"core.clp","new_file":"core.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Core module\n;------------------------------------------------------------------------------\n(defmodule core\n (export defclass thing))\n\n(defclass core::thing\n \"Base class of everything\"\n (is-a USER))\n","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Core module\n;------------------------------------------------------------------------------\n(defmodule core\n (export defclass thing))\n(defclass core::thing\n \"Base class for all entities in the world, has a parent child relationship\"\n (is-a USER)\n (slot parent\n (type INSTANCE\n SYMBOL)\n (allowed-classes thing)\n (allowed-symbols FALSE)\n (default-dynamic FALSE))\n (multislot children\n (type INSTANCE)\n (allowed-classes thing))\n (message-handler parent-is primary))\n\n(defmessage-handler thing parent-is primary\n (?value)\n (and ?self:parent\n (or (eq ?self:parent\n ?value)\n (send ?self:parent \n parent-is \n ?value))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"91f41d48ed62b327152e37e1188a3d3648114b2b","subject":"update beer-questions.clp","message":"update beer-questions.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule random-question-to-determine-which-sex\n (start)\n (not (which-sex ?sex))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you male or female? \ud83d\udc68\ud83c\udffb\ud83d\udc69\ud83c\udffb\")\n (why \"Male or female persons tend to prefer more or less intense beers.\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule random-question-to-determine-which-age\n (start)\n (not (which-age ?age))\n =>\n (set-strategy random)\n (assert (UI-state (display \"How old are you? \ud83d\udd1e\")\n (why \"Younger people tend to prefer less intense beers.\")\n (relation-asserted which-age)\n (valid-answers 18-23 24-29 >=30))))\n\n(defrule random-question-to-determine-which-season\n (start)\n (not (which-season ?season))\n =>\n (set-strategy random)\n (assert (UI-state (display \"It is autumn, spring, summer or winter? \ud83c\udf41\ud83c\udf31\ud83c\udfd6\u2744\ufe0f\")\n (why \"Weather conditions influence our perceptions and needs. The choice of a beer is among these.\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule random-question-to-determine-whether-he-is-a-regular-beer-drinker\n (start)\n (not (regular-beer-drinker ?drinker))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (why \"Better start with more standard beers. On the other hand, you may be surprised!\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule random-question-to-determine-whether-he-is-going-to-smoke\n (start)\n (not (smoker ?smoker))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you going to smoke while you drink? \ud83d\udeac\")\n \t\t\t\t\t (why \"Beer may alter the taste of tobacco. Also, stronger beers pair well with tobacco flavor.\")\n (relation-asserted smoker)\n (valid-answers yes no))))\n\n; depth questions for meal type recognition\n\n(defrule determine-main-meal\n (smoker ?smoker)\n (which-sex ?sex)\n (which-age ?age)\n (which-season ?season)\n (regular-beer-drinker ?drinker)\n =>\n (set-strategy depth)\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert?\")\n (relation-asserted main-meal)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-pizza-topping\n (main-meal pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other? \ud83c\udf55\ud83e\udd53\ud83c\udf46\ud83e\uddc0\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf55 _Classic_ topping pizzas pair well with crisp and clean beers. \"\n \"Complementary grain and cheese flavors balance hop character while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf55\ud83e\udd53 _Meat_ topping pizzas pair well with hoppy and bitter beers, which \"\n \"stands up to strong flavors and cut through fat to deliver a complex \"\n \"finish.\")\n (str-cat \"\ud83c\udf55\ud83c\udf46 _Vegetables_ topping pizzas pair well with sour beers which \"\n \"increases the perception of savoriness or with beers which contrasts \"\n \"the char of the oven-roasted vegetables.\")\n (str-cat \"\ud83c\udf55\ud83e\uddc0 _Cheese_ topping pizzas pair well with fruity and spicy beers, \"\n \"thanks to their high carbonation which works overtime to cleanse the \"\n \"palate from a strong flavor.\")))\n (relation-asserted pizza-topping)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping meat)\n =>\n (assert (UI-state (display \"Is the meat spicy? \ud83c\udf36\")\n (why (str-cat \"Malty flavors highlight the roasted qualities of the meat, while sweetness works to \"\n \"neutralize capsaicin, the active component in chili peppers.\"))\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (pizza-topping vegetables)\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (why \"The roasted character of the beer complements the char on oven-roasted vegetables.\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n(defrule determine-which-entree\n (main-meal entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n \"\ud83c\udf3e Complementary _grain_ flavors balance hops while remaining light on the palate.\"\n \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing salt and acidity.\"\n (str-cat \"\ud83d\udc1f\ud83e\udd90 _Fish_ pair well with the bitterness of the English-Style Bitter and \"\n \"the sweetness of the English-Style Pale Ale.\")\n \"\ud83e\udd69\ud83c\udf56 _Meat_ pairs well with Scottish-Style Ales.\"\n \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and American Brown Ale.\"\n \"\ud83e\udd5c With _fats_ strong flavors, beer balances and allows for a complex finish.\"))\n (relation-asserted which-entr\u00e9e)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-grain\n (which-entr\u00e9e grain)\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \ud83d\udc1f\ud83e\udd90\ud83e\udd80\ud83e\udd91\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-which-fish-cooking-method\n (which-fish ?fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus, etc.)? \ud83d\udc19\ud83e\udd91\")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \ud83e\udd90\ud83e\udd80\ud83d\udc1a\")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other? \ud83d\udc20\ud83d\udc1f\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game or other? \ud83c\udf56\ud83e\udd69\ud83e\udd86\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game other))))\n\n(defrule determine-which-meat-cooking-method\n (which-meat ?meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey? \ud83e\udd83\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other? \ud83e\udd86\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables\n (which-entr\u00e9e vegetables)\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other? \ud83e\udd55\ud83e\udd57\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-vegetables-cooking-method\n (which-vegetables ?vegetable)\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other? \ud83c\udf44\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.) \ud83e\udd51\ud83c\udf56?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-cheese-style\n (main-meal cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan, etc.), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and \"\n \"have a very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 _Semi-soft_(www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \"\ud83e\uddc0 _Firm\/hard_(www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \"\ud83e\uddc0 _Blue_(www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 _Natural rind_(www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 _Washed rind_(www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 _Semi-soft_ cheeses can be paired with many different craft beers, \"\n \"such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 _Firm\/hard_ cheeses are easily paired with an equally broad range of \"\n \"craft beer styles, such as Pilsner, Bock, Brown Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 _Blue_ cheeses are stronger-flavored cheeses which are most \"\n \"successfully balanced with stonger-flavored bolder beers like IPAs or \"\n \"Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 _Natural rind_ cheeses pair well with Golden, Blonde and traditional \"\n \"British-style ales.\")\n (str-cat \"\ud83e\uddc0 _Washed rind_ cheeses, while potentially pungent, are often creamy \"\n \"and can be paired with Belgian-styles ales, like Triples and Golden \"\n \"Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm-hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \ud83e\uddc0\")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \ud83e\uddc0\")\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n(defrule determine-which-dessert\n (main-meal dessert)\n =>\n (assert (UI-state (display \"Is the dessert creamy, fruit, chocolate or other? \ud83c\udf6e\ud83e\udd67\ud83c\udf6a\ud83c\udf6b\")\n (relation-asserted which-dessert)\n (valid-answers creamy fruit chocolate other))))\n\n(defrule determine-if-creamy-dessert-is-fruit\n (which-dessert creamy)\n =>\n (assert (UI-state (display \"Is the creamy dessert with fruit?\")\n (relation-asserted creamy-dessert-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-chocolate-dessert\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule random-question-to-determine-which-sex\n (start)\n (not (which-sex ?sex))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you male or female? \ud83d\udc68\ud83c\udffb\ud83d\udc69\ud83c\udffb\")\n (why \"Male or female persons tend to prefer more or less intense beers.\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule random-question-to-determine-which-age\n (start)\n (not (which-age ?age))\n =>\n (set-strategy random)\n (assert (UI-state (display \"How old are you? \ud83d\udd1e\")\n (why \"Younger people tend to prefer less intense beers.\")\n (relation-asserted which-age)\n (valid-answers 18-23 24-29 >=30))))\n\n(defrule random-question-to-determine-which-season\n (start)\n (not (which-season ?season))\n =>\n (set-strategy random)\n (assert (UI-state (display \"It is autumn, spring, summer or winter? \ud83c\udf41\ud83c\udf31\ud83c\udfd6\u2744\ufe0f\")\n (why \"Weather conditions influence our perceptions and needs. The choice of a beer is among these.\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule random-question-to-determine-whether-he-is-a-regular-beer-drinker\n (start)\n (not (regular-beer-drinker ?drinker))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (why \"Better start with more standard beers. On the other hand, you may be surprised!\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule random-question-to-determine-whether-he-is-going-to-smoke\n (start)\n (not (smoker ?smoker))\n =>\n (set-strategy random)\n (assert (UI-state (display \"Are you going to smoke while you drink? \ud83d\udeac\")\n \t\t\t\t\t (why \"Beer may alter the taste of tobacco. Also, stronger beers pair well with tobacco flavor.\")\n (relation-asserted smoker)\n (valid-answers yes no))))\n\n; depth questions for meal type recognition\n\n(defrule determine-main-meal\n (smoker ?smoker)\n (which-sex ?sex)\n (which-age ?age)\n (which-season ?season)\n (regular-beer-drinker ?drinker)\n =>\n (set-strategy depth)\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert?\")\n (relation-asserted main-meal)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-pizza-topping\n (main-meal pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other? \ud83c\udf55\ud83e\udd53\ud83c\udf46\ud83e\uddc0\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf55 _Classic_ topping pizzas pair well with crisp and clean beers. \"\n \"Complementary grain and cheese flavors balance hop character while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf55\ud83e\udd53 _Meat_ topping pizzas pair well with hoppy and bitter beers, which \"\n \"stands up to strong flavors and cut through fat to deliver a complex \"\n \"finish.\")\n (str-cat \"\ud83c\udf55\ud83c\udf46 _Vegetables_ topping pizzas pair well with sour beers which \"\n \"increases the perception of savoriness or with beers which contrasts \"\n \"the char of the oven-roasted vegetables.\")\n (str-cat \"\ud83c\udf55\ud83e\uddc0 _Cheese_ topping pizzas pair well with fruity and spicy beers, \"\n \"thanks to their high carbonation which works overtime to cleanse the \"\n \"palate from a strong flavor.\")))\n (relation-asserted pizza-topping)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping meat)\n =>\n (assert (UI-state (display \"Is the meat spicy? \ud83c\udf36\")\n (why (str-cat \"Malty flavors highlight the roasted qualities of the meat, while sweetness works to \"\n \"neutralize capsaicin, the active component in chili peppers.\"))\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (pizza-topping vegetables)\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (why \"The roasted character of the beer complements the char on oven-roasted vegetables.\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n(defrule determine-which-entree\n (main-meal entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n \"\ud83c\udf3e Complementary _grain_ flavors balance hops while remaining light on the palate.\"\n \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing salt and acidity.\"\n (str-cat \"\ud83d\udc1f\ud83e\udd90 _Fish_ pair well with the bitterness of the English-Style Bitter and \"\n \"the sweetness of the English-Style Pale Ale.\")\n \"\ud83e\udd69\ud83c\udf56 _Meat_ pairs well with Scottish-Style Ales.\"\n \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and American Brown Ale.\"\n \"\ud83e\udd5c With _fats_ strong flavors, beer balances and allows for a complex finish.\"))\n (relation-asserted which-entr\u00e9e)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-grain\n (which-entr\u00e9e grain)\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \ud83d\udc1f\ud83e\udd90\ud83e\udd80\ud83e\udd91\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus, etc.)? \ud83d\udc19\ud83e\udd91\")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \ud83e\udd90\ud83e\udd80\ud83d\udc1a\")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other? \ud83d\udc20\ud83d\udc1f\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game or other? \ud83c\udf56\ud83e\udd69\ud83e\udd86\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey? \ud83e\udd83\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other? \ud83e\udd86\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (which-entr\u00e9e vegetables)\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (which-entr\u00e9e vegetables)\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other? \ud83e\udd55\ud83e\udd57\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other? \ud83c\udf44\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.) \ud83e\udd51\ud83c\udf56?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-cheese-style\n (main-meal cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan, etc.), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and \"\n \"have a very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 _Semi-soft_(www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \"\ud83e\uddc0 _Firm\/hard_(www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \"\ud83e\uddc0 _Blue_(www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 _Natural rind_(www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 _Washed rind_(www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 _Semi-soft_ cheeses can be paired with many different craft beers, \"\n \"such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 _Firm\/hard_ cheeses are easily paired with an equally broad range of \"\n \"craft beer styles, such as Pilsner, Bock, Brown Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 _Blue_ cheeses are stronger-flavored cheeses which are most \"\n \"successfully balanced with stonger-flavored bolder beers like IPAs or \"\n \"Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 _Natural rind_ cheeses pair well with Golden, Blonde and traditional \"\n \"British-style ales.\")\n (str-cat \"\ud83e\uddc0 _Washed rind_ cheeses, while potentially pungent, are often creamy \"\n \"and can be paired with Belgian-styles ales, like Triples and Golden \"\n \"Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm-hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \ud83e\uddc0\")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \ud83e\uddc0\")\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n(defrule determine-which-dessert\n (main-meal dessert)\n =>\n (assert (UI-state (display \"Is the dessert creamy, fruit, chocolate or other? \ud83c\udf6e\ud83e\udd67\ud83c\udf6a\ud83c\udf6b\")\n (relation-asserted which-dessert)\n (valid-answers creamy fruit chocolate other))))\n\n(defrule determine-if-creamy-dessert-is-fruit\n (which-dessert creamy)\n =>\n (assert (UI-state (display \"Is the creamy dessert with fruit?\")\n (relation-asserted creamy-dessert-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-chocolate-dessert\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"96a5e25335a7d482260b1d0a88e346e08007f1b3","subject":"Start second chapter for this","message":"Start second chapter for this\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter-2.clp","new_file":"ssu-ai-level-2\/chapter-2.clp","new_contents":"\/\/ First task\n(deffacts students\n (student LelyakinMA 4)\n (student ArutunyaAS 4)\n (student KefalicsAI 1)\n (student BelokobylskySA 2)\n)\n\n(facts)\n\n(retract 2)\n(retract 3)\n\n(assert (student KefalicsAI 2))\n\n(facts)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter-2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"9bb02dc4841d0f7641f2ad05ffebad9449dc6936","subject":"Added the target-symbol-is-special function.","message":"Added the target-symbol-is-special function.\n\nThis function automates the process of defining symbol splitting due to the\nfact that the body of each rule assigned to symbol splitting is the same except\nfor the target symbol. By adding this function I make it easier to maintain the\ncode as I add new features. It also doesn't matter if I construct a binary\nimage of the expert system because the rules will have already been defined.\n\nThe only downside is that batch* must be used instead of load*. While this may\nseem like an issue, it really isn't.\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLCommonConversionRules.clp","new_file":"src\/tools\/conv\/gl\/GLCommonConversionRules.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLCommonConversionRules.clp - Common rules that multiple expert systems use\n; to do different kinds of conversion\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(deffunction types::target-symbol-is-special (?symbol ?name ?docString)\n (build (format nil \"(defrule modify-input::%s \\\"%s\\\"\n?fct <- (object (is-a file-line) (contents $?b ?s $?a))\n(test (input-is-not-split-symbol \\\"%s\\\" ?s))\n=>\n(modify-instance ?fct (contents $?b (break-apart \\\"%s\\\" ?s) $?a)))\" \n ?name ?docString ?symbol ?symbol)))\n;------------------------------------------------------------------------------\n;(defrule modify-input::identify-symbols-with-commas\n; ?fct <- (object (is-a file-line)\n; (contents $?before ?symbol $?after))\n; (test (input-is-not-split-symbol \",\" ?symbol))\n; =>\n; (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n; $?after)))\n(target-symbol-is-special \",\" identify-symbols-with-commas \"\")\n;------------------------------------------------------------------------------\n;(defrule modify-input::identify-symbols-with-open-parens\n; ?fct <- (object (is-a file-line)\n; (contents $?b ?s $?a))\n; (test (input-is-not-split-symbol \"(\" ?s))\n; =>\n; (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n(target-symbol-is-special \"(\" identify-symbols-with-open-parens \"\")\n;------------------------------------------------------------------------------\n;(defrule modify-input::identify-symbols-with-close-parens\n; ?fct <- (object (is-a file-line)\n; (contents $?before ?symbol $?after))\n; (test (input-is-not-split-symbol \")\" ?symbol))\n; =>\n; (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n; $?after)))\n(target-symbol-is-special \")\" identify-symbols-with-close-parens \"\")\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLCommonConversionRules.clp - Common rules that multiple expert systems use\n; to do different kinds of conversion\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"439e1e4a69e06facc0583617cdc0f463f5b267ab","subject":"Deleted the id and class slots as well as the init message-handler","message":"Deleted the id and class slots as well as the init message-handler\n\nThe slots consumed extra memory for no real benefit. In the case of id, the\nname field already exists (it is an implicit field) and matches on\ninstance-name instead of symbol. This means that we store the instance-names in\na list instead of symbols. It also means that the name retrieved from an object\ncan be directly invoked without having to match against it (in the case where\nthat is all we were looking for).\n\nThe class slot is useless because we can just call (class ...) if it is\nnecessary. There is no need to waste space. Hell, for matching purposes we can\njust use the (is-a ) field to do pattern matching as well.\n\nThe init message handler is no longer necessary because these fields no longer\nexist.\n\nI left the parent field in because I find it really useful in a wide number of\ncases.\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/cortex\/core\/Object.clp","new_file":"lib\/cortex\/core\/Object.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Contains basic object classes \n;------------------------------------------------------------------------------\n(defclass cortex::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot parent \n (type INSTANCE SYMBOL) \n (visibility public)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Contains basic object classes \n;------------------------------------------------------------------------------\n(defclass cortex::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visibility public) (access initialize-only))\n (slot class (type SYMBOL) (visibility public) (access initialize-only))\n (slot parent (type SYMBOL) (visibility public))\n (message-handler init around))\n;------------------------------------------------------------------------------\n(defmessage-handler cortex::Object init around \n \"Initializes the object, setting the id and class of the \n object\" \n ()\n (call-next-handler)\n ;we want to set this information as the last thing before \n ;we return \n (bind ?self:id (instance-name-to-symbol \n (instance-name ?self)))\n (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"06efcc2bea38c84ce678493af4a9179ff10d4a43","subject":"adding a sample to test deffunction. it's not implemented yet, but it's good to have a sample. this sample was copied from clips user guide peter","message":"adding a sample to test deffunction. it's not implemented yet, but it's good to have a sample.\nthis sample was copied from clips user guide\npeter\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@448 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/deffunction_test1.clp","new_file":"samples\/deffunction_test1.clp","new_contents":"(deffunction positive-slope\r\n\t(?x1 ?y1 ?x2 ?y2)\r\n\t(< \r\n\t\t0 \r\n\t\t(\/ \r\n\t\t\t(- ?y2 ?y1) \r\n\t\t\t(- ?x2 ?x1)\r\n\t\t)\r\n\t)\r\n)","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/deffunction_test1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"f52e57aa8abf5edc51bde03fe41518af3a6d4ea0","subject":"GLAPIArgumentConversion.clp: Overloaded message handlers for generating code","message":"GLAPIArgumentConversion.clp: Overloaded message handlers for generating code\n\nThe messages are overloaded in the subclasses of the argument builder class to\nprovide special functionality for \"edge\" cases.\n","repos":"DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/GLAPIArgumentConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIArgumentConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIArgumentConversion.clp\n; \n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot clips-type (type SYMBOL))\n (slot gl-type (type SYMBOL))\n (slot clips-function-name (type SYMBOL))\n (slot index (type INTEGER) (range 1 ?VARIABLE))\n (slot argument-name-base (type SYMBOL STRING))\n (slot data-object-argument-name (type SYMBOL STRING))\n (slot variable-argument-name (type SYMBOL STRING))\n (slot variable-declaration (type STRING))\n (slot data-object-declaration (type STRING))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-type-check-code ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,%s,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-type\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(deffunction types::flatten-type (?symbol)\n\t\t\t\t (switch ?symbol\n\t\t\t\t\t\t\t(case Float then FLOAT)\n\t\t\t\t\t\t\t(case float then FLOAT)\n\t\t\t\t\t\t\t(case FLOAT then FLOAT)\n\t\t\t\t\t\t\t(case double then DOUBLE)\n\t\t\t\t\t\t\t(case Double then DOUBLE)\n\t\t\t\t\t\t\t(case DOUBLE then DOUBLE)\n\t\t\t\t\t\t\t(case integer then INTEGER)\n\t\t\t\t\t\t\t(case Integer then INTEGER)\n\t\t\t\t\t\t\t(case INTEGER then INTEGER)\n\t\t\t\t\t\t\t(case LONG then LONG)\n\t\t\t\t\t\t\t(case long then LONG)\n\t\t\t\t\t\t\t(case Long then LONG)\n\t\t\t\t\t\t\t(case symbol then SYMBOL)\n\t\t\t\t\t\t\t(case Symbol then SYMBOL)\n\t\t\t\t\t\t\t(case SYMBOL then SYMBOL)\n\t\t\t\t\t\t\t(case string then STRING)\n\t\t\t\t\t\t\t(case String then STRING)\n\t\t\t\t\t\t\t(case STRING then STRING)\n\t\t\t\t\t\t\t(default ?symbol)))\n;------------------------------------------------------------------------------\n(deffunction types::get-conversion-function (?symbol)\n\t\t\t\t (bind ?fn-float \"DOToFloat\")\n\t\t\t\t (bind ?fn-double \"DOToDouble\")\n\t\t\t\t (bind ?fn-int \"DOToInteger\")\n\t\t\t\t (bind ?fn-long \"DOToLong\")\n\t\t\t\t (bind ?fn-string \"DOToString\")\n\t\t\t\t (switch ?symbol\n\t\t\t\t\t\t\t(case FLOAT then ?fn-float)\n\t\t\t\t\t\t\t(case DOUBLE then ?fn-double)\n\t\t\t\t\t\t\t(case INTEGER then ?fn-int)\n\t\t\t\t\t\t\t(case LONG then ?fn-long)\n\t\t\t\t\t\t\t(case SYMBOL then ?fn-string)\n\t\t\t\t\t\t\t(case STRING then ?fn-string)\n\t\t\t\t\t\t\t(default \"ERROR_NO_CONVERSION_FOUND\")))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s = %s(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t(get-conversion-function \n\t\t\t\t\t\t\t\t\t\t\t\t (flatten-type ?self:clips-type))\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-length-variable-declaration)\n (slot multifield-length-variable-name)\n (slot multifield-pointer-argument-name)\n (slot multifield-pointer-declaration)\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-type-check-code primary ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,MULTIFIELD,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s%n%s%n%s%n%s%n\"\n\t\t\t\t\t\t\t\t\t\t\t\t;GetLength\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetDOLength(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;GetValue\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetValue(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-pointer-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;Generate malloc\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = (%s*)calloc(%s,sizeof(%s));\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type)\n\t\t\t\t\t\t\t\t\t\t\t\t;Conversion\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s%n%s%n%s%n\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"int i, end;%nend = GetDOEnd(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"for(i = GetDOBegin(%s); i<=end; i++) {\", \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ;TODO: Continue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ))))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIArgumentBuilder\n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer TRUE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield-fixed\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIFixedArrayArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (size ?size))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIFixedMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(multifield-size ?size)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-multifield-conversion-code\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-multifield-conversion-code)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?o <- (object (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name)\n\t\t\t\t\t\t\t (argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-make-multifield-conversion-code))\n\t\t\t(bind ?baseName (sym-cat (format nil \"%s_MF\" ?anb)))\n\t\t\t(modify-instance ?o \n\t\t\t\t\t\t\t\t (multifield-pointer-argument-name ?baseName)\n\t\t\t\t\t\t\t\t (multifield-pointer-declaration (format nil \"void* %s;\" ?baseName))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-data-object-declaration\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-data-object-declaration)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?ab <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t\t(id ?name)\n\t\t\t\t\t\t\t\t(argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-data-object-declaration))\n\t\t\t(bind ?doArg (sym-cat (format nil \"%s_DO\" ?anb)))\n\t\t\t(modify-instance ?ab \n\t\t\t\t\t\t\t\t (data-object-argument-name ?doArg)\n\t\t\t\t\t\t\t\t (data-object-declaration \n\t\t\t\t\t\t\t\t\t (format nil \"DATA_OBJECT %s;\" ?doArg))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-type-check-contents\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-type-check-code)\n\t\t\t\t\t\t\t\t (arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (parent ?p)\n\t\t\t\t\t (argument-type ?arg-type)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t(object (is-a GLAPIFunction)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (function-name ?fname))\n\t\t\t?b <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t)\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIArgumentConversion.clp\n; \n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot clips-type (type SYMBOL))\n (slot gl-type (type SYMBOL))\n (slot clips-function-name (type SYMBOL))\n (slot index (type INTEGER) (range 1 ?VARIABLE))\n (slot argument-name-base (type SYMBOL STRING))\n (slot data-object-argument-name (type SYMBOL STRING))\n (slot variable-argument-name (type SYMBOL STRING))\n (slot variable-declaration (type STRING))\n (slot data-object-declaration (type STRING))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-type-check-code ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,%s,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-type\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(deffunction get-conversion-function (?symbol)\n\t\t\t\t (bind ?fn-float \"DOToFloat\")\n\t\t\t\t (bind ?fn-double \"DOToDouble\")\n\t\t\t\t (bind ?fn-int \"DOToInteger\")\n\t\t\t\t (bind ?fn-long \"DOToLong\")\n\t\t\t\t (bind ?fn-string \"DOToString\")\n\t\t\t\t (switch ?symbol\n\t\t\t\t\t\t\t(case float then ?fn-float)\n\t\t\t\t\t\t\t(case FLOAT then ?fn-float)\n\t\t\t\t\t\t\t(case Float then ?fn-float)\n\t\t\t\t\t\t\t(case double then ?fn-double)\n\t\t\t\t\t\t\t(case DOUBLE then ?fn-double)\n\t\t\t\t\t\t\t(case Double then ?fn-double)\n\t\t\t\t\t\t\t(case integer then ?fn-int)\n\t\t\t\t\t\t\t(case INTEGER then ?fn-int)\n\t\t\t\t\t\t\t(case Integer then ?fn-int)\n\t\t\t\t\t\t\t(case long then ?fn-long)\n\t\t\t\t\t\t\t(case LONG then ?fn-long)\n\t\t\t\t\t\t\t(case Long then ?fn-long)\n\t\t\t\t\t\t\t(case symbol then ?fn-string)\n\t\t\t\t\t\t\t(case Symbol then ?fn-string)\n\t\t\t\t\t\t\t(case SYMBOL then ?fn-string)\n\t\t\t\t\t\t\t(case string then ?fn-string)\n\t\t\t\t\t\t\t(case String then ?fn-string)\n\t\t\t\t\t\t\t(case STRING then ?fn-string)\n\t\t\t\t\t\t\t(default \"ERROR_NO_CONVERSION_FOUND\")))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-conversion-code ()\n (return (format nil \"%s = %s(%s);\"\n\t\t\t\t\t\t\t\t\t ?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t (get-conversion-function ?self:clips-type)\n\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-length-variable-declaration)\n (slot multifield-length-variable-name)\n (slot multifield-pointer-argument-name)\n (slot multifield-pointer-declaration)\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n get-type-check-code primary ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,MULTIFIELD,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n (\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n get-conversion-code ()\n (return (format nil \"%s%n%s%n%s%n%s%n\"\n\t\t\t ;GetLength\n\t\t\t (format nil \"%s = GetDOLength(%s);\"\n\t\t\t \t\t\t\t?self:multifield-length-variable-name\n\t\t\t\t\t\t\t?self:data-object-argument-name)\n\t\t\t ;GetValue\n\t\t\t (format nil \"%s = GetValue(%s);\"\n\t\t\t ?self:multifield-pointer-argument-name\n\t\t\t ?self:data-object-argument-name)\n\t\t\t ;Conversion\n\t\t\t ;(format nil \"%\n\t\t\t ;get the multifield pointer out\n\t\t\t)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIArgumentBuilder\n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer TRUE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield-fixed\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIFixedArrayArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (size ?size))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIFixedMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(multifield-size ?size)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-multifield-conversion-code\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-multifield-conversion-code)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?o <- (object (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name)\n\t\t\t\t\t\t\t (argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-make-multifield-conversion-code))\n\t\t\t(bind ?baseName (sym-cat (format nil \"%s_MF\" ?anb)))\n\t\t\t(modify-instance ?o \n\t\t\t\t\t\t\t\t (multifield-pointer-argument-name ?baseName)\n\t\t\t\t\t\t\t\t (multifield-pointer-declaration (format nil \"void* %s;\" ?baseName))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-data-object-declaration\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-data-object-declaration)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?ab <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t\t(id ?name)\n\t\t\t\t\t\t\t\t(argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-data-object-declaration))\n\t\t\t(bind ?doArg (sym-cat (format nil \"%s_DO\" ?anb)))\n\t\t\t(modify-instance ?ab \n\t\t\t\t\t\t\t\t (data-object-argument-name ?doArg)\n\t\t\t\t\t\t\t\t (data-object-declaration \n\t\t\t\t\t\t\t\t\t (format nil \"DATA_OBJECT %s;\" ?doArg))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-type-check-contents\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-type-check-code)\n\t\t\t\t\t\t\t\t (arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (parent ?p)\n\t\t\t\t\t (argument-type ?arg-type)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t(object (is-a GLAPIFunction)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (function-name ?fname))\n\t\t\t?b <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t)\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"ab36a6cd1c9b66814793743412e5b998624fc501","subject":"Added Interactable.clp","message":"Added Interactable.clp\n\nThe two objects within this file describe actions to be taken based on the\nuser's input. It is generic enough so that you can have a wide range of verbs\nor virtual theatre look and use.\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"src\/adventure\/Interactable.clp","new_file":"src\/adventure\/Interactable.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass InteractableObject (is-a Object)\n (slot name (type SYMBOL STRING))\n (multislot valid-stimuli (type SYMBOL)))\n\n(defclass Interaction (is-a Object)\n \"Links to a given object and provides an easy way to describe responses to a\n given stimuli\"\n (slot stimuli (type SYMBOL))\n (slot count (type NUMBER) (range 0 ?VARIABLE))\n ; by making this a multislot it's possible to define encoding schemes to\n ; perform actions\n (multislot reaction))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/adventure\/Interactable.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c622e0b0c40b54bb36636e5a24b8d028f374c2d5","subject":"Added the import commands","message":"Added the import commands\n","repos":"DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"lib\/import\/import.clp","new_file":"lib\/import\/import.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; import.clp - Defines the import method, a wrapper over load, load*, batch,\n; and batch* that makes it possible to do relative includes without having to\n; worry about absolute paths\n;------------------------------------------------------------------------------\n; Assume that etc\/sys.clp has already been loaded\n(defglobal MAIN\n ?*valid-import-actions* = (create$ load load* batch batch*))\n(defgeneric import)\n\n(defmethod import \n ((?action SYMBOL (neq ?action (expand$ ?*valid-import-actions*)))\n (?local-path LEXEME))\n (printout t \n (format nil \"Provided action %s is not valid for import\" ?action) crlf\n \"Valid actions are: \" ?*valid-import-actions* crlf)\n (return FALSE))\n\n(defmethod import \n ((?action SYMBOL (not (neq ?action (expand$ ?*valid-import-actions*))))\n (?local-path LEXEME))\n (progn$ (?front ?*path*)\n (if (funcall ?action \n (format nil \"%s\/%s\" ?front ?local-path)) then\n (return TRUE)))\n (return FALSE))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/import\/import.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c32719bf888d5302010ce2b9224bf820c9d7a57d","subject":"the single pixel rect is now in definstances","message":"the single pixel rect is now in definstances\n\nThis should make it possible to reset the system and still have this\nclass.\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery\/rectangle.clp","new_file":"lib\/chicanery\/rectangle.clp","new_contents":"(defgeneric defrectangle)\n(defgeneric quickrect)\n(defgeneric defpixel)\n(defgeneric pixel:nxn)\n(defgeneric pixel:1x1)\n\n(defclass Rectangle\n (is-a Pointer)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot bx\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Rectangle get-points () \n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n\n(defmethod defrectangle \n \"Creates a new rectangle object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (make-instance ?name of Rectangle \n (x ?x) \n (y ?y)\n (bx ?bx)\n (by ?by)\n (pointer (quickrect ?x ?y ?bx ?by))))\n(defmethod defrectangle\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (defrectangle (gensym*) ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(defmethod defpixel\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?factor INTEGER))\n (defrectangle ?name ?x ?y (+ ?x ?factor) (+ ?y ?factor)))\n\n(defmethod pixel:nxn\n ((?x INTEGER)\n (?y INTEGER)\n (?n INTEGER))\n (quickrect ?x ?y (+ ?x ?n) (+ ?y ?n)))\n\n(defmethod pixel:nxn\n ((?n INTEGER))\n (pixel:nxn 0 0 ?n))\n\n(defmethod pixel:1x1\n ((?x INTEGER)\n (?y INTEGER))\n (pixel:nxn ?x ?y 1))\n\n(defmethod pixel:1x1 () \n (pixel:1x1 0 0))\n\n(definstances default-rect-classes\n (rect:single-pixel of Rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)\n (pointer (quickrect 0 0 1 1))))\n\n","old_contents":"(defgeneric defrectangle)\n(defgeneric quickrect)\n(defgeneric defpixel)\n(defgeneric pixel:nxn)\n(defgeneric pixel:1x1)\n\n(defclass Rectangle\n (is-a Pointer)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot bx\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Rectangle get-points () \n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n\n(defmethod defrectangle \n \"Creates a new rectangle object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (make-instance ?name of Rectangle \n (x ?x) \n (y ?y)\n (bx ?bx)\n (by ?by)\n (pointer (quickrect ?x ?y ?bx ?by))))\n(defmethod defrectangle\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (defrectangle (gensym*) ?x ?y ?bx ?by))\n\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(defmethod defpixel\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?factor INTEGER))\n (defrectangle ?name ?x ?y (+ ?x ?factor) (+ ?y ?factor)))\n\n(defmethod pixel:nxn\n ((?x INTEGER)\n (?y INTEGER)\n (?n INTEGER))\n (quickrect ?x ?y (+ ?x ?n) (+ ?y ?n)))\n\n(defmethod pixel:nxn\n ((?n INTEGER))\n (pixel:nxn 0 0 ?n))\n\n(defmethod pixel:1x1\n ((?x INTEGER)\n (?y INTEGER))\n (pixel:nxn ?x ?y 1))\n\n(defmethod pixel:1x1 () \n (pixel:1x1 0 0))\n\n(defglobal MAIN \n ?*rect:single-pixel* = (send (defrectangle rect:single-pixel 0 0 1 1) get-pointer))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"796753fa3ab11bd025c91e814cf34ee00e553828","subject":"Create task7.clp","message":"Create task7.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task7.clp","new_file":"ssu-ai-level-2\/chapter6\/task7.clp","new_contents":"(deffunction summ-iter (?n)\n (if (= ?n 1) then (return (\/ 1 3)))\n (+ (\/ 1 (+ (* 2 ?n) 1)) (summ-iter (- ?n 1)))\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task7.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"dd62aca13262d72bfae4b735e77876fafbef5368","subject":"Start chapter4 for ai","message":"Start chapter4 for ai\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter4\/task1.clp","new_file":"ssu-ai-level-2\/chapter4\/task1.clp","new_contents":"(deffacts employees\n (employee Lelyakin 10 2 100000)\n (employee Lelyakina 11 2 100000)\n (employee Timkaev 12 3 110000)\n (employee Timkaeva 13 3 110000)\n (employee Kisurin 13 3 111000)\n)\n\n(defrule prem\n (employee ?name ?expierence ?children ?salary)\n \n (test (or (?children > 2)\n (?expierence >= 5)\n )\n )\n =>\n (assert (premia ?name (* ?salary 0.2)))\n)","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter4\/task1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"427dd07c68a2b79d7a63776e91c66a0da561ebcd","subject":"Removed commented out rules in MergeRules.clp and optimized the inject rules","message":"Removed commented out rules in MergeRules.clp and optimized the inject rules\n\nI modified the rules that inject consumers to just store the set of consumers\nin the target instruction if the instruction didn't have any consumers already\ndefined.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-consumer-list\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-consume-list)\n\t\t\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-producer-list\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-produce-list)\n\t\t\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-consumer-list\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-producer-list\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (if (= 0 (length$ ?cs)) then\n\t\t\t\t (bind ?cs ?t1)\n\t\t\t\t else\n\t\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t\t(if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t (bind ?cs (insert$ ?cs 1 ?target)))))\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (if (= 0 (length$ ?cons)) then\n\t\t\t\t (bind ?cons ?targets)\n\t\t\t\t else\n\t\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t\t(if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t (bind ?cons (insert$ ?cons 1 ?target))))))\n\t\t\t(modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t\t(bind ?prods (create$ ?prods ?target)))))\n\t\t\t(modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-consumer-list\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-consume-list)\n\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::generate-initial-producer-list\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?id => $?))))\n\t\t\t=>\n\t\t\t(modify ?f0 (action instruction-produce-list)\n\t\t\t (arguments ?id => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-consumer-list\n (declare (salience 1))\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::add-to-producer-list\n (declare (salience 1))\n ?f0 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?elements))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?elements ?a)))\n;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consumes)\n;\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consumes)\n;\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (action instruction-consume-list)\n;\t\t\t\t\t (arguments ?id => ?a ?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produces)\n;\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produces)\n;\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (action instruction-produce-list)\n;\t\t\t\t\t (arguments ?id => ?a ?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consume-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-consume-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n;\t\t\t(test (neq ?f0 ?f1))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n;\t\t\t?f0 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produce-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n;\t\t\t?f1 <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t (action instruction-produce-list)\n;\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n;\t\t\t(test (neq ?f0 ?f1))\n;\t\t\t=>\n;\t\t\t(retract ?f0)\n;\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n;\t\t\t(declare (salience -2))\n;\t\t\t?f <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t(action instruction-consumes)\n;\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n;\t\t\t=>\n;\t\t\t(modify ?f (action instruction-consume-list)\n;\t\t\t\t\t (arguments ?b => ?a)))\n;;------------------------------------------------------------------------------\n;(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n;\t\t\t(declare (salience -2))\n;\t\t\t?f <- (message (to dependency-analysis)\n;\t\t\t\t\t\t\t\t(action instruction-produces)\n;\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n;\t\t\t=>\n;\t\t\t(modify ?f (action instruction-produce-list)\n;\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"63d73a78b66610d58424f637542b3f3dee60db91","subject":"Fixed a bug where dendrite was not importing cortex","message":"Fixed a bug where dendrite was not importing cortex\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/lib\/dendrite\/Library.clp","new_file":"src\/lib\/dendrite\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the dendrite module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule dendrite \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/dendrite\/Interactable.clp\")\n(batch* \"lib\/dendrite\/Interaction.clp\")\n(batch* \"lib\/dendrite\/Event.clp\")\n(batch* \"lib\/dendrite\/Item.clp\")\n(batch* \"lib\/dendrite\/Entity.clp\")\n(batch* \"lib\/dendrite\/Player.clp\")\n(batch* \"lib\/dendrite\/Room.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the dendrite module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule dendrite (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/dendrite\/Interactable.clp\")\n(batch* \"lib\/dendrite\/Interaction.clp\")\n(batch* \"lib\/dendrite\/Event.clp\")\n(batch* \"lib\/dendrite\/Item.clp\")\n(batch* \"lib\/dendrite\/Entity.clp\")\n(batch* \"lib\/dendrite\/Player.clp\")\n(batch* \"lib\/dendrite\/Room.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"de9de0b8468f63db0906f225bb8c39377b08bfa3","subject":"LoadEngine.clp: Modified the file to use initialize-adventure-engine","message":"LoadEngine.clp: Modified the file to use initialize-adventure-engine\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron","old_file":"LoadEngine.clp","new_file":"LoadEngine.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(initialize-adventure-engine)\n;------------------------------------------------------------------------------\n(load-library cortex)\n(load-library dendrite)\n(load-library lobe)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"init\/Library.clp\")\n;------------------------------------------------------------------------------\n(load-library cortex)\n(load-library dendrite)\n(load-library lobe)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"3a244ce5a96cb49682150566dc29fb5839094202","subject":"Added wrappers for the Point native type","message":"Added wrappers for the Point native type\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"lib\/chicanery\/point.clp","new_file":"lib\/chicanery\/point.clp","new_contents":"; point.clp - classes and methods to wrap around the Point native type\n\n(defgeneric quickpoint)\n(defgeneric defpoint)\n(defgeneric to-point)\n(defclass Point\n (is-a Pointer)\n (slot pointer-class \n (source composite)\n (default Point))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Point get-points ()\n (create$ ?self:x ?self:y))\n\n(defmethod defpoint\n \"Creates a new point object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER))\n (make-instance ?name of Point\n (x ?x)\n (y ?y)\n (pointer (quickpoint ?x ?y))))\n\n(defmethod defpoint\n ((?x INTEGER)\n (?y INTEGER))\n (defpoint (gensym*) ?x ?y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n\n(definstances default-point-classes\n (ZP of Point \n (x 0) \n (y 0)\n (pointer (quickpoint 0 0))))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/chicanery\/point.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"344634fb63db21cb561a88172b5d883e27a699e3","subject":"Added shell.clp - used for accessing the electron shell","message":"Added shell.clp - used for accessing the electron shell\n","repos":"DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"logic\/shell.clp","new_file":"logic\/shell.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; shell.clp - Logic used to startup the electron shell with all of the electron\n; settings activated.\n;------------------------------------------------------------------------------\n(defglobal MAIN\n ; Change the value of this global to change the name of the\n ; corresponding shell variable.\n ?*electron-fs-root* = ElectronFSRoot\n ; Use this to make sure that we fail out if we can't bootstrap\n ?*fsys* = (progn (bind ?result (get-shell-variable ?*electron-fs-root*))\n (if (not ?result) then\n (printout t \"ERROR: \" ?*electron-fs-root* \" not defined - Exiting\" crlf)\n (exit)\n else\n ?result)))\n; Can't do loads within defglobal calls because it could cause crashes if\n; we do a defglobal within a defglobal.\n\n; Load the filesystem base points\n(load* (format nil \"%s\/etc\/sys.clp\" ?*fsys*))\n; Load the system base (import commands)\n(load* (format nil \"%s\/import\/import.clp\" ?*lib*))\n(import load* util\/message.clp)\n(import load* util\/strings.clp)\n(import batch* os\/os.clp)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'logic\/shell.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"44af90f64dac53dbee696c863d77f6c995be97ef","subject":"shorter CASP version","message":"shorter CASP version\n","repos":"tortinator\/asprilo","old_file":"quantitiesS.clp","new_file":"quantitiesS.clp","new_contents":"% >>> addition to input.lp <<<\nordered(order(O),product(A),number(N)) :- init(object(order,O), value(line,(A,N))).\nonShelf(product(A),shelf(S),number(N)) :- init(object(product,A), value(on, (S,N))).\n\n#include \"\/home\/torsten\/local\/lib\/clingcon\/csp.lp\". % CHECK MAX\n\n&dom{N..N} = amountMissing(A,O,0) :- ordered(O,A,number(N)).\n&dom{0..N} = amountMissing(A,O,T) :- ordered(O,A,number(N)), time(T).\n&dom{N..N} = amountOnShelf(A,S,0) :- onShelf(A,S,number(N)).\n&dom{0..N} = amountOnShelf(A,S,T) :- onShelf(A,S,number(N)), time(T).\n\n&dom{0..N} = pick(A,O,S,T) :- ordered(O,A,number(N)), onShelf(A,S), time(T).\n\n{ pick(A,O,S,T) : ordered(O,A), onShelf(A,S) } 1 :- time(T). % pick one article at a time at one picking station (via order)\n\n:- pick(_,O,_,T), target(O,P), not serves(_,P,T).\n:- pick(A,O,S,T), target(O,P), serves(R,P,T), not carries(R,S,T).\n:- pick(A,O,S,T), &sum{ amountOnShelf(A,S,T-1); -pick(A,O,S,T) } < 0.\n\n:- pick(A,O,S,T), onShelf(A,S), &sum{ amountOnShelf(A,S,T-1); -amountOnShelf(A,S,T); -pick(A,O,S,T) } != 0.\n:- pick(A,O,S,T), ordered(O,A), &sum{ amountMissing(A,O,T-1); -amountMissing(A,O,T); -pick(A,O,S,T) } != 0.\n:- pick(A,O,S,T), &sum{ pick(A,O,S,T) } = 0.\n\n:- not pick(A,_,S,T), onShelf(A,S), &sum{ amountOnShelf(A,S,T-1); -amountOnShelf(A,S,T) } != 0, time(T).\n:- not pick(A,O,_,T), ordered(O,A), &sum{ amountMissing(A,O,T-1); -amountMissing(A,O,T) } != 0, time(T). % >>> REPORT MAX!!! <<<\n:- not pick(A,O,S,T), onShelf(A,S), ordered(O,A), &sum{ pick(A,O,S,T) } != 0, time(T).\n%*\n:- onShelf(A,S), &sum{ amountOnShelf(A,S,T-1); -amountOnShelf(A,S,T) } < 0, time(T).\n:- ordered(O,A), &sum{ amountMissing(A,O,T-1); -amountMissing(A,O,T) } < 0, time(T).\n*%\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'quantitiesS.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"dc92a280db6ddc2ac82392bd485de02224616870","subject":"added the knowledge template","message":"added the knowledge template\n\nThis template is meant to allow me to pass extra information between passes so\nthat we can control execution.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Templates.clp","new_file":"lib\/durandal\/modules\/indirect\/Templates.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Templates.clp - Contains the deftemplates used to by LibIndirect\n;------------------------------------------------------------------------------\n(deftemplate indirect::run-passes\n (slot on (type SYMBOL INSTANCE-NAME INTEGER) \n (allowed-classes InteropObject))\n (multislot passes (type SYMBOL STRING)))\n;------------------------------------------------------------------------------\n(deftemplate indirect::knowledge\n \"Used to pass extra knowledge to allow selective invocation to occur\"\n (slot about (type SYMBOL INSTANCE-NAME)) \n (multislot is))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Templates.clp - Contains the deftemplates used to by LibIndirect\n;------------------------------------------------------------------------------\n(deftemplate indirect::run-passes\n (slot on (type SYMBOL INSTANCE-NAME INTEGER) \n (allowed-classes InteropObject))\n (multislot passes (type SYMBOL STRING)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"bc6089eaaa48e688ac35be2f0c792d64cb2e5f90","subject":"fixed bug converting from input","message":"fixed bug converting from input\n","repos":"tortinator\/asprilo","old_file":"quantities.clp","new_file":"quantities.clp","new_contents":"#include . \n\n&dom{N..N} = ordered(order(O),product(A),0) :- init(object(order,O), value(line,(A,N))).\n&dom{0..N} = ordered(order(O),product(A),T) :- init(object(order,O), value(line,(A,N))), time(T).\n&dom{N..N} = shelved(shelf(S),product(A),0) :- init(object(product,A), value(on, (S,N))).\n&dom{0..N} = shelved(shelf(S),product(A),T) :- init(object(product,A), value(on, (S,N))), time(T).\n\n&dom{0..N} = process(product(A),order(O),S,T) :- init(object(order,O), value(line,(A,N))), shelved(S,product(A)), time(T).\n\n{ process(A,O,S,T) : ordered(O,A), shelved(S,A) } 1 :- time(T). % process one article at a time at one processing station (via order)\n\n:- process(_,O,_,T), target(O,P), not serves(_,P,T).\n:- process(A,O,S,T), target(O,P), serves(R,P,T), not carries(R,S,T).\n:- process(A,O,S,T), &sum{ shelved(S,A,T-1); -process(A,O,S,T) } < 0.\n\n:- process(A,O,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), &sum{ process(A,O,S,T) } = 0.\n\n:- not process(A,_,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } != 0, time(T).\n:- not process(A,O,_,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } != 0, time(T).\n:- not process(A,O,S,T), shelved(S,A), ordered(O,A), &sum{ process(A,O,S,T) } != 0, time(T).\n\n\n\n\n\n\n\n%*\n:- shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } < 0, time(T).\n:- ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } < 0, time(T).\n*%\n","old_contents":"#include . \n\n&dom{N..N} = ordered(order(O),product(A),0) :- init(object(order,O), value(line,(A,N))).\n&dom{0..N} = ordered(order(O),product(A),T) :- init(object(order,O), value(line,(A,N))), time(T).\n&dom{N..N} = shelved(shelf(S),product(A),0) :- init(object(product,A), value(on, (S,N))).\n&dom{0..N} = shelved(shelf(S),product(A),T) :- init(object(product,A), value(on, (S,N))), time(T).\n\n&dom{0..N} = process(A,O,S,T) :- init(object(order,O), value(line,(A,N))), shelved(S,A), time(T).\n\n{ process(A,O,S,T) : ordered(O,A), shelved(S,A) } 1 :- time(T). % process one article at a time at one processing station (via order)\n\n:- process(_,O,_,T), target(O,P), not serves(_,P,T).\n:- process(A,O,S,T), target(O,P), serves(R,P,T), not carries(R,S,T).\n:- process(A,O,S,T), &sum{ shelved(S,A,T-1); -process(A,O,S,T) } < 0.\n\n:- process(A,O,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T); -process(A,O,S,T) } != 0.\n:- process(A,O,S,T), &sum{ process(A,O,S,T) } = 0.\n\n:- not process(A,_,S,T), shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } != 0, time(T).\n:- not process(A,O,_,T), ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } != 0, time(T). % >>> REPORT MAX!!! <<<\n:- not process(A,O,S,T), shelved(S,A), ordered(O,A), &sum{ process(A,O,S,T) } != 0, time(T).\n\n\n\n\n\n\n\n%*\n:- shelved(S,A), &sum{ shelved(S,A,T-1); -shelved(S,A,T) } < 0, time(T).\n:- ordered(O,A), &sum{ ordered(O,A,T-1); -ordered(O,A,T) } < 0, time(T).\n*%\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9745143583b2e0cc0d921fb8c9bb551725c41e9f","subject":"WidgetEvent.clp: Added a description to the raise event message-handler","message":"WidgetEvent.clp: Added a description to the raise event message-handler\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron","old_file":"src\/lib\/widget\/WidgetEvent.clp","new_file":"src\/lib\/widget\/WidgetEvent.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetEvent.clp - Base class of all events to cause widgets to do things\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetEvent\n \"Base class of all events in the widget library\"\n (is-a Object)\n (slot event-name (type SYMBOL))\n (slot function-to-call (type SYMBOL))\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n(defmessage-handler widget::WidgetEvent raise-event primary \n \"Fires the given event\"\n ($?args)\n (funcall ?self:function-to-call $?args))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetEvent.clp - Base class of all events to cause widgets to do things\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetEvent\n \"Base class of all events in the widget library\"\n (is-a Object)\n (slot event-name (type SYMBOL))\n (slot function-to-call (type SYMBOL))\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n(defmessage-handler widget::WidgetEvent raise-event primary ($?args)\n (funcall ?self:function-to-call $?args))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"aec0578a88a8e93af6cb666c9909695805648ce0","subject":"Finished porting the wavefront-scheduling-acquire module","message":"Finished porting the wavefront-scheduling-acquire module\n\nI rewrote the CPV rules to do one massive update to the corresponding object to\nreduce the number of entrances into the object itself.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (argument ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 (?sLen)) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule SetifyInstructionList\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?pa <- (object (is-a PathAggregate) (InstructionList $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (InstructionList $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule GenerateInitialSliceFactsForElementsOnTheWavefront \n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n (object (is-a PathAggregate) (Parent ?e) \n (CompensationPathVectors $?cpv))\n (test (> (length$ ?cpv) 0))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule GenerateFactForSlicesFromCPV\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) (ID ?i) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptySlicesCreationFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule QueryCanCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $? ?e $?))\n ;(test (member$ ?e ?z))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule QueryCantCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $?z))\n (test (not (member$ ?e ?z)))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule TryConstructNewSlice\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) (ID ?path) (Contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance (gensym*) of Slice (Parent ?b) (TargetPath ?path)\n (TargetBlock ?e) (Contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule SliceAlreadyExists\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveSliceAnalysisFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n (object (is-a Wavefront) (Contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID) \n (CompensationPathVectors $?cpvIDs))\n (test (> (length$ ?cpvIDs) 0))\n =>\n (modify-instance ?agObj (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule SetifyTargetCompensationPathVectors\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (TargetCompensationPathVectors $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule SelectCPVForAnalysis\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze0 $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ;(not (exists (Schedule ?e for ?r)))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (TargetCompensationPathVectors $?cpvs))\n (test (> (length$ ?cpvs) 0))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj (TargetCompensationPathVectors))\n (bind ?result (create$))\n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (progn$ (?p (send (symbol-to-instance-name ?cpv) get-Paths))\n (if ?det then \n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?det \n (or ?det \n (member$ ?e \n (send ?o2 get-Contents))))))\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n (assert (Analyze block ?e for ?r using cpvs $?result)))\n;------------------------------------------------------------------------------\n(defrule SegmentCPVsApart\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ?e for ?r using cpvs ?cpv $?cpvs)\n (object (is-a BasicBlock) (ID ?e))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n =>\n ;(printout t \"Analyze instruction \" ?i \" { associated cpv \" ?cpv \n ; \" } for \" ?e crlf)\n (retract ?fct)\n (assert (Analyze block ?e for ?r using cpvs $?cpvs)\n (Analyze instruction ?i { associated cpv ?cpv } for ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractCPVSegmentationFact\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ? for ? using cpvs)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) (Parent ?a))))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ; \" because a CPV wasn't tied to the instruction\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) (Parent ?a) (ID ?id))\n (test (not (member$ ?id $?cpvs)))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ;\" because the corresponding CPV wasn't registered with the path\"\n ;\" aggregate\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVIsImpossibleToScheduleIntoTargetBlock\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;(printout t ?i \" is impossible to schedule into \" ?e crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"Schedule = \" ?sched crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n\n(defrule TargetCPVCantBeScheduledIntoTargetBlockYet\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?paObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld) \n (NonLocalDependencies $?nld) (Parent ?parent))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;(printout t \"Can't schedule \" ?i \" into \" ?e \" right now!\" crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Scheduled = \" ?sched crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"From = \" ?parent crlf)\n ;(printout t \"CPVS = \" ?cpvs crlf)\n ;(facts)\n (retract ?fct)\n (assert (Cant schedule ?cpv for ?e now)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVNeedsToBeSliceAnalyzed\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n (object (is-a PathAggregate) (Parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (Parent ?b) \n (LocalDependencies $?ld))\n (test (subsetp ?ld ?sched))\n (object (is-a CompensationPathVector) (ID ?cpv) (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (foreach ?z ?paths\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (if (member$ ?e (send ?obj get-Contents)) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule CreateSliceSegments\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) (Parent ?b) (TargetBlock ?e) (TargetPath ?path)\n (ID ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (Analyze slice ?s for ?e and cpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule RetractSliceSegmenterFact\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule FAILURE-MISSING-SLICE \n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-Contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (exit))\n\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-SingleSingle\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n ?f1 <- (Analyze slice ?s1&~?s0 for ?e and cpv ?cpv)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule ConvertSingleSliceRule\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n =>\n (retract ?f0)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0)))\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-MultiMulti\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze in ?e using cpv ?cpv and slices $?q)\n ?f1 <- (Analyze in ?e using cpv ?cpv and slices $?z)\n (test (neq ?f0 ?f1)) \n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices $?z $?q)))\n;------------------------------------------------------------------------------\n(defrule SetifyAnalyzeSlicesFact\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c ?b $?d)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule ERROR-ANALYSIS-FAILURE\n (declare (salience -900))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n (Analyze instruction ?i for ?blkID)\n ?inst <- (object (is-a Instruction) (ID ?i))\n (object (is-a PathAggregate) (Parent ?blkID) \n (ScheduledInstructions $?si))\n ?cpv <- (object (is-a CompensationPathVector) (Parent ?i))\n =>\n (printout t \"ERROR: ANALYZE INSTRUCTION \" ?i \" WASN'T MATCHED!!!\" crlf\n \"SCHEDULED INSTRUCTIONS: \" $?si crlf)\n (send ?inst print)\n (printout t crlf)\n (send ?cpv print)\n (exit))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?)\n (exists (Cant schedule ?cpv for ?e ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n ; (printout t \"Failed Instruction \" ?i \" because producer is lower \"\n ; \"than block \" ?e \" on the wavefront\" crlf)\n (retract ?fct)\n (bind ?ind (member ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-CallBarrier\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled - \"\n ; \"Call Barrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i)\n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled into \" ?e \n ; \" - MemoryBarrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n ?instruction <- (object (is-a LoadInstruction|StoreInstruction) \n (ID ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier FALSE) (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n ;(printout t \"Removed \" ?i \" from being scheduled into \" \n ;\t\t\t\t\t ?e \" because \" ?element \" - ModifiesSameMemory\" crlf)\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?cpv) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i) \n (Parent ?q) (DestinationRegisters ?dr))\n (object (ID ?element) (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled from block \" ?q \n ;\t\t\t\t\t \" unknown reference\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?ss)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleInstructionThisIteration\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices)\n =>\n (retract ?fct)\n (assert (Can schedule ?cpv for ?e)))\n;------------------------------------------------------------------------------\n(defrule AddCPVToSuccessList\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Can schedule ?cpvID for ?blkID)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj MovableCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule FailCPVForNow\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID now)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj StalledCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule RemoveCPVFromService\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID ever)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n ?cpvObj <- (object (is-a CompensationPathVector) (ID ?cpvID) \n (Parent ?i))\n =>\n (retract ?fct)\n (slot-insert$ ?cpvObj Failures 1 ?blkID)\n (slot-insert$ ?agObj ImpossibleCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule PonderMovementIteration\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?)\n (object (is-a Wavefront) (ID ?r) (Contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) (Parent ?e) (ID ?pa)\n (StalledCompensationPathVectors $?scpv))\n (test (> (length$ $?scpv) 0))\n =>\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule AnotherMovementIsRequired\n (Stage WavefrontSchedule $?)\n ?ponder <- (Substage Ponder $?rest)\n ?f <- (Another Movement Required)\n =>\n ;this returns a tuple\n (retract ?ponder ?f)\n (assert (Substage GenerateAnalyze0 \n GenerateAnalyze \n Analyze \n SliceAnalyze \n MergeInit \n Merge \n MergeUpdate\n ReopenBlocks \n Ponder \n $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishSchedulingIntoBlock\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?rest)\n =>\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ;get the Mrs. Hitler birth certificate\n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (argument ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule SelectValidCPVs \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule FindValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule RetractValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule IgnorePHIInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreCallInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule IgnoreTerminatorInstructions\n (declare (salience 1))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) (ID ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction) (ID ?inst) (Parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg) (Parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) (ID ?inst) (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) (ID ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule TagValidCPVs\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) (ID ?inst) (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractDrainedGetCPVFacts\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (not (member$ ?cpvID \n (send ?agObj \n get-ImpossibleCompensationPathVectors))))\n =>\n (retract ?fct)\n (if (not (member$ ?inst (send ?agObj get-InstructionList))) then \n (slot-insert$ ?agObj InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?agObj get-InstructionList))) then\n (slot-insert$ ?agObj InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld \n (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (slot-insert$ ?agObj CompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule CPVIsImpossible\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) (Parent ?inst) (ID ?cpvID))\n ?agObj <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n (object (is-a Instruction) (ID ?inst) (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg) (Class ?class))\n (test (member$ ?cpvID (send ?agObj \n get-ImpossibleCompensationPathVectors)))\n =>\n ;add the non-local dependencies\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?agObj \n get-ScheduledInstructions))) then\n (slot-insert$ ?agObj ScheduledInstructions 1 ?nld)))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule MakeCPV \n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector) (Parent ?inst))))\n (object (is-a Instruction) (Class ?class) (ID ?inst) (Parent ?pv) \n (DestinationRegisters ?reg) (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) (ID ?pv) (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) (ID ?ag) (Parent ?e))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?name (gensym*))\n (slot-insert$ ?pa CompensationPathVectors 1 ?name)\n (make-instance ?name of CompensationPathVector (Parent ?inst) \n (Paths $?paths) (OriginalBlock ?pv))\n (if (not (member$ ?inst (send ?pa get-InstructionList))) then \n (slot-insert$ ?pa InstructionList 1 ?inst))\n (if (not (member$ ?reg (send ?pa get-InstructionList))) then\n (slot-insert$ ?pa InstructionList 1 ?reg))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld (send ?pa get-ScheduledInstructions))) \n then (slot-insert$ ?pa ScheduledInstructions 1 ?nld))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule SetifyInstructionList\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?pa <- (object (is-a PathAggregate) (InstructionList $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (InstructionList $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule GenerateInitialSliceFactsForElementsOnTheWavefront \n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n (object (is-a PathAggregate) (Parent ?e) \n (CompensationPathVectors $?cpv))\n (test (> (length$ ?cpv) 0))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule GenerateFactForSlicesFromCPV\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) (ID ?i) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptySlicesCreationFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule QueryCanCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $? ?e $?))\n ;(test (member$ ?e ?z))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule QueryCantCreateSliceForPath\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) (ID ?path) (Contents $?z))\n (test (not (member$ ?e ?z)))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule TryConstructNewSlice\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) (ID ?path) (Contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance (gensym*) of Slice (Parent ?b) (TargetPath ?path)\n (TargetBlock ?e) (Contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule SliceAlreadyExists\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) (Parent ?b) (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveSliceAnalysisFact\n (Stage WavefrontSchedule $?)\n (Substage Slice $?)\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n (object (is-a Wavefront) (Contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID) \n (CompensationPathVectors $?cpvIDs))\n (test (> (length$ ?cpvIDs) 0))\n =>\n (modify-instance ?agObj (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule SetifyTargetCompensationPathVectors\n (Stage WavefrontSchedule $?)\n (Substage AnalyzeInit $?)\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (modify-instance ?pa (TargetCompensationPathVectors $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule SelectCPVForAnalysis\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze0 $?)\n (object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) (ID ?e) (IsOpen TRUE))\n ;(not (exists (Schedule ?e for ?r)))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (TargetCompensationPathVectors $?cpvs))\n (test (> (length$ ?cpvs) 0))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj (TargetCompensationPathVectors))\n (bind ?result (create$))\n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (progn$ (?p (send (symbol-to-instance-name ?cpv) get-Paths))\n (if ?det then \n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?det \n (or ?det \n (member$ ?e \n (send ?o2 get-Contents))))))\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n (assert (Analyze block ?e for ?r using cpvs $?result)))\n;------------------------------------------------------------------------------\n(defrule SegmentCPVsApart\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ?e for ?r using cpvs ?cpv $?cpvs)\n (object (is-a BasicBlock) (ID ?e))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n =>\n ;(printout t \"Analyze instruction \" ?i \" { associated cpv \" ?cpv \n ; \" } for \" ?e crlf)\n (retract ?fct)\n (assert (Analyze block ?e for ?r using cpvs $?cpvs)\n (Analyze instruction ?i { associated cpv ?cpv } for ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractCPVSegmentationFact\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?fct <- (Analyze block ? for ? using cpvs)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) (Parent ?a))))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ; \" because a CPV wasn't tied to the instruction\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n (Stage WavefrontSchedule $?)\n (Substage GenerateAnalyze $?)\n ?pa <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) (Parent ?a) (ID ?id))\n (test (not (member$ ?id $?cpvs)))\n =>\n ;(printout t \"NOTE: Removed \" ?a \" from the path aggregate of \" ?e \n ;\" because the corresponding CPV wasn't registered with the path\"\n ;\" aggregate\" crlf)\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVIsImpossibleToScheduleIntoTargetBlock\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?agObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;(printout t ?i \" is impossible to schedule into \" ?e crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"Schedule = \" ?sched crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n\n(defrule TargetCPVCantBeScheduledIntoTargetBlockYet\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n ?paObj <- (object (is-a PathAggregate) (Parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n (object (is-a Instruction) (ID ?i) (LocalDependencies $?ld) \n (NonLocalDependencies $?nld) (Parent ?parent))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;(printout t \"Can't schedule \" ?i \" into \" ?e \" right now!\" crlf)\n ;(printout t \"Non Local Dependencies = \" ?nld crlf)\n ;(printout t \"Local Dependencies = \" ?ld crlf)\n ;(printout t \"Scheduled = \" ?sched crlf)\n ;(printout t \"Instruction List = \" ?il crlf)\n ;(printout t \"From = \" ?parent crlf)\n ;(printout t \"CPVS = \" ?cpvs crlf)\n ;(facts)\n (retract ?fct)\n (assert (Cant schedule ?cpv for ?e now)))\n;------------------------------------------------------------------------------\n(defrule TargetCPVNeedsToBeSliceAnalyzed\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze instruction ?i { associated cpv ?cpv } for ?e)\n (object (is-a PathAggregate) (Parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) (ID ?i) (Parent ?b) \n (LocalDependencies $?ld))\n (test (subsetp ?ld ?sched))\n (object (is-a CompensationPathVector) (ID ?cpv) (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (foreach ?z ?paths\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (if (member$ ?e (send ?obj get-Contents)) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule CreateSliceSegments\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) (Parent ?b) (TargetBlock ?e) (TargetPath ?path)\n (ID ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (Analyze slice ?s for ?e and cpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule RetractSliceSegmenterFact\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule FAILURE-MISSING-SLICE \n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) (Parent ?b) (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-Contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (exit))\n\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-SingleSingle\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n ?f1 <- (Analyze slice ?s1&~?s0 for ?e and cpv ?cpv)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule ConvertSingleSliceRule\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze slice ?s0 for ?e and cpv ?cpv)\n =>\n (retract ?f0)\n (assert (Analyze in ?e using cpv ?cpv and slices ?s0)))\n;------------------------------------------------------------------------------\n(defrule MergeSliceAnalysisFacts-MultiMulti\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?f0 <- (Analyze in ?e using cpv ?cpv and slices $?q)\n ?f1 <- (Analyze in ?e using cpv ?cpv and slices $?z)\n (test (neq ?f0 ?f1)) \n =>\n (retract ?f0 ?f1)\n (assert (Analyze in ?e using cpv ?cpv and slices $?z $?q)))\n;------------------------------------------------------------------------------\n(defrule SetifyAnalyzeSlicesFact\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c ?b $?d)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule ERROR-ANALYSIS-FAILURE\n (declare (salience -900))\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n (Analyze instruction ?i for ?blkID)\n ?inst <- (object (is-a Instruction) (ID ?i))\n (object (is-a PathAggregate) (Parent ?blkID) \n (ScheduledInstructions $?si))\n ?cpv <- (object (is-a CompensationPathVector) (Parent ?i))\n =>\n (printout t \"ERROR: ANALYZE INSTRUCTION \" ?i \" WASN'T MATCHED!!!\" crlf\n \"SCHEDULED INSTRUCTIONS: \" $?si crlf)\n (send ?inst print)\n (printout t crlf)\n (send ?cpv print)\n (exit))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices $?)\n (exists (Cant schedule ?cpv for ?e ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n ; (printout t \"Failed Instruction \" ?i \" because producer is lower \"\n ; \"than block \" ?e \" on the wavefront\" crlf)\n (retract ?fct)\n (bind ?ind (member ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule AnalyzeSliceContentsForFailure-CallBarrier\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) (Parent ?b)\n (Contents $? ?element $?))\n (object (ID ?element) (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a Instruction) (ID ?i) (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled - \"\n ; \"Call Barrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i)\n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled into \" ?e \n ; \" - MemoryBarrier\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?b) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n ?instruction <- (object (is-a LoadInstruction|StoreInstruction) \n (ID ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (ID ?element) (HasMemoryBarrier FALSE) (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n ;(printout t \"Removed \" ?i \" from being scheduled into \" \n ;\t\t\t\t\t ?e \" because \" ?element \" - ModifiesSameMemory\" crlf)\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n (Stage WavefrontSchedule $?)\n (Substage Analyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n (object (is-a Slice) (ID ?s) (TargetBlock ?e) \n (Parent ?cpv) (Contents $? ?element $?))\n (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) (ID ?i) \n (Parent ?q) (DestinationRegisters ?dr))\n (object (ID ?element) (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) (Parent ?e))\n =>\n (retract ?fct)\n ;(printout t \"Removed \" ?i \" from being scheduled from block \" ?q \n ;\t\t\t\t\t \" unknown reference\" crlf)\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if (neq FALSE ?ind) then \n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (Cant schedule ?cpv for ?e ever)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices ?s $?ss)\n =>\n (retract ?fct)\n (assert (Analyze in ?e using cpv ?cpv and slices $?ss)))\n;------------------------------------------------------------------------------\n(defrule CanScheduleInstructionThisIteration\n (declare (salience -3))\n (Stage WavefrontSchedule $?)\n (Substage SliceAnalyze $?)\n ?fct <- (Analyze in ?e using cpv ?cpv and slices)\n =>\n (retract ?fct)\n (assert (Can schedule ?cpv for ?e)))\n;------------------------------------------------------------------------------\n(defrule AddCPVToSuccessList\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Can schedule ?cpvID for ?blkID)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj MovableCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule FailCPVForNow\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID now)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n =>\n (retract ?fct)\n (slot-insert$ ?agObj StalledCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule RemoveCPVFromService\n (Stage WavefrontSchedule $?)\n (Substage MergeInit $?)\n ?fct <- (Cant schedule ?cpvID for ?blkID ever)\n ?agObj <- (object (is-a PathAggregate) (Parent ?blkID))\n ?cpvObj <- (object (is-a CompensationPathVector) (ID ?cpvID) \n (Parent ?i))\n =>\n (retract ?fct)\n (slot-insert$ ?cpvObj Failures 1 ?blkID)\n (slot-insert$ ?agObj ImpossibleCompensationPathVectors 1 ?cpvID))\n;------------------------------------------------------------------------------\n(defrule PonderMovementIteration\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?)\n (object (is-a Wavefront) (ID ?r) (Contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) (Parent ?e) (ID ?pa)\n (StalledCompensationPathVectors $?scpv))\n (test (> (length$ $?scpv) 0))\n =>\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule AnotherMovementIsRequired\n (Stage WavefrontSchedule $?)\n ?ponder <- (Substage Ponder $?rest)\n ?f <- (Another Movement Required)\n =>\n ;this returns a tuple\n (retract ?ponder ?f)\n (assert (Substage GenerateAnalyze0 \n GenerateAnalyze \n Analyze \n SliceAnalyze \n MergeInit \n Merge \n MergeUpdate\n ReopenBlocks \n Ponder \n $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishSchedulingIntoBlock\n (declare (salience -1))\n (Stage WavefrontSchedule $?)\n (Substage Ponder $?rest)\n =>\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0d47fa14165f1b09aa6ad08241019c1fda3cb841","subject":"Create expert-system.clp","message":"Create expert-system.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/expert-system.clp","new_file":"ssu-ai-level-2\/expert-system.clp","new_contents":"(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n\n (if (lexemep ?answer) then\n (bind ?answer (lowcase ?answer)))\n )\n\n ?answer\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/expert-system.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"327062b2c959d942dc8be4ce8ae7da2ac5d1cc78","subject":"Updated WavefrontInitialization.clp to use modules","message":"Updated WavefrontInitialization.clp to use modules\n\nThe code has been rewritten to also use messages as well.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInitialization.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInitialization.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; NOTE: This is the execution order of the wavefront scheduler\n;(defrule InitializeWavefrontSchedulingFacts\n; (declare (salience 1001))\n; (Stage WavefrontSchedule $?)\n; =>\n; (assert (Substage Init \n; Identify \n; PhiIdentify\n; PhiNode \n; PhiNodeUpdate\n; Pathing \n; Strip \n; Inject \n; Acquire \n; Slice \n; AnalyzeInit \n; GenerateAnalyze0\n; GenerateAnalyze\n; Analyze \n; SliceAnalyze\n; MergeInit \n; Merge \n; MergeUpdate \n; ReopenBlocks\n; Ponder\n; Rename \n; DependencyAnalysis \n; AdvanceInit\n; AdvanceIdentify\n; Advance\n; AdvanceEnd\n; Update)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-block\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $?c))\n =>\n (assert (message (to wavefront-schedule) \n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e) \n (OriginalStopIndex (- (length$ $?c) 1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-region\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a Region) \n (id ?e)) \n =>\n (assert (message (to wavefront-schedule)\n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule InitializeWavefrontSchedulingFacts\n\t\t\t(declare (salience 1001))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t=>\n\t\t\t(assert (Substage Init \n\t\t\t\t\t\t\t\t\tIdentify \n\t\t\t\t\t\t\t\t\tPhiIdentify\n\t\t\t\t\t\t\t\t\tPhiNode \n\t\t\t\t\t\t\t\t\tPhiNodeUpdate\n\t\t\t\t\t\t\t\t\tPathing \n\t\t\t\t\t\t\t\t\tStrip \n\t\t\t\t\t\t\t\t\tInject \n\t\t\t\t\t\t\t\t\tAcquire \n\t\t\t\t\t\t\t\t\tSlice \n\t\t\t\t\t\t\t\t\tAnalyzeInit \n\t\t\t\t\t\t\t\t\tGenerateAnalyze0\n\t\t\t\t\t\t\t\t\tGenerateAnalyze\n\t\t\t\t\t\t\t\t\tAnalyze \n\t\t\t\t\t\t\t\t\tSliceAnalyze\n\t\t\t\t\t\t\t\t\tMergeInit \n\t\t\t\t\t\t\t\t\tMerge \n\t\t\t\t\t\t\t\t\tMergeUpdate \n\t\t\t\t\t\t\t\t\tReopenBlocks\n\t\t\t\t\t\t\t\t\tPonder\n\t\t\t\t\t\t\t\t\tRename \n\t\t\t\t\t\t\t\t\tDependencyAnalysis \n\t\t\t\t\t\t\t\t\t;ScheduleObjectCreation \n\t\t\t\t\t\t\t\t\t;ScheduleObjectUsage\n\t\t\t\t\t\t\t\t\t;ResetScheduling\n\t\t\t\t\t\t\t\t\t;InitLLVMUpdate\n\t\t\t\t\t\t\t\t\t;LLVMUpdate \n\t\t\t\t\t\t\t\t\tAdvanceInit\n\t\t\t\t\t\t\t\t\tAdvanceIdentify\n\t\t\t\t\t\t\t\t\tAdvance\n\t\t\t\t\t\t\t\t\tAdvanceEnd\n\t\t\t\t\t\t\t\t\tUpdate)))\n;------------------------------------------------------------------------------\n(defrule NextWavefrontSchedulingSubstage\n\t\t\t(declare (salience -1000))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t?fct <- (Substage ? $?rest)\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Substage $?rest)))\n;------------------------------------------------------------------------------\n(defrule RetractSubstageCompletely\n\t\t\t(declare (salience -1001))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t?fct <- (Substage)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule InitializeWavefrontSchedulingForARegion-SelectBlockDirectly\n\t\t\t(declare (salience 2))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t(object (is-a Region) (CanWavefrontSchedule TRUE) (ID ?r) \n\t\t\t\t\t (Entrances $? ?e $?))\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Parent ?r))\n\t\t\t=>\n\t\t\t(assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule InitializeWavefrontSchedulingForARegion-AssertRegionInstead\n\t\t\t(declare (salience 2))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t(object (is-a Region) (CanWavefrontSchedule TRUE) (ID ?r) \n\t\t\t\t\t (Entrances $? ?e $?))\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Parent ~?r))\n\t\t\t(object (is-a Region) (Parent ?r) (Entrances $? ?e $?) (ID ?q))\n\t\t\t=>\n\t\t\t(assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule MergeWavefrontCreationContents-Convert-SingleSingle\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t?f0 <- (Add ?v0 to wavefront for ?r)\n\t\t\t?f1 <- (Add ?v1 to wavefront for ?r)\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (Create wavefront for ?r containing ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule MergeWavefrontCreationContents-Convert-MultiSingle\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t?f0 <- (Add ?v0 to wavefront for ?r)\n\t\t\t?f1 <- (Create wavefront for ?r containing $?g0)\n\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (Create wavefront for ?r containing $?g0 ?v0)))\n;------------------------------------------------------------------------------\n(defrule MergeWavefrontCreationContents-Convert-MultiMulti\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t?f0 <- (Create wavefront for ?r containing $?g0)\n\t\t\t?f1 <- (Create wavefront for ?r containing $?g1)\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (Create wavefront for ?r containing $?g0 $?g1)))\n;------------------------------------------------------------------------------\n(defrule ConvertWavefrontCreationFact\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t?f0 <- (Add ?v0 to wavefront for ?r)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (Create wavefront for ?r containing ?v0)))\n;------------------------------------------------------------------------------\n(defrule ConstructInitialWavefront\n\t\t\t(Stage WavefrontInit $?)\n\t\t\t?f0 <- (Create wavefront for ?r containing $?w)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(make-instance of Wavefront (Parent ?r) (Contents ?w)))\n;------------------------------------------------------------------------------\n(defrule ConstructPathAggregateForBlock \n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Init $?)\n\t\t\t(object (is-a Hint) (Type Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?e) (Contents $?c)) \n\t\t\t=>\n\t\t\t(assert (Propagate aggregates of ?e))\n\t\t\t(make-instance of PathAggregate (Parent ?e) (OriginalStopIndex \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(- (length$ $?c) 1))))\n;------------------------------------------------------------------------------\n(defrule ConstructPathAggregateForRegion\n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Init $?)\n\t\t\t(object (is-a Hint) (Type Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t?bb <- (object (is-a Region) (ID ?e)) \n\t\t\t=>\n\t\t\t(assert (Propagate aggregates of ?e))\n\t\t\t(make-instance of PathAggregate (Parent ?e)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4ae43d56c7d55a462a79747476e92b91567770fa","subject":"painter.clp actually draws","message":"painter.clp actually draws\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery.clp)\n(defglobal MAIN\n ?*old-timestamp* = 0\n ?*max-factor* = 128\n ?*factor* = 1)\n\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (bind ?*old-timestamp* (send [mouse] get-timestamp))\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?*factor*)) \n (by (+ ?y ?*factor*)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n =>\n (if (< ?*factor* ?*max-factor*) then\n (bind ?*factor* (+ ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n =>\n (if (>= ?*factor* 0) then\n (bind ?*factor* (- ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"19b5d0e9a89f2aec2d547b57c8e35431dddbc173","subject":"just adding options to the menu","message":"just adding options to the menu\n","repos":"The4Ms\/family-knowledgebase","old_file":"UserInterface.clp","new_file":"UserInterface.clp","new_contents":"(defrule ShowMainMenu\n\n=>\n\t(printout t \"- Infering relations about:\" crlf)\n\t(printout t \" 1- cousins \" crlf)\n\t(printout t \" 2- Nephews\" crlf)\n\t(printout t \" 3- Nieces\" crlf)\n\t(printout t \" 4- Uncle\" crlf)\n\t(printout t \" 5- Aunt\" crlf)\n\t(printout t \" 6- Grandfather\" crlf)\n\t(printout t \" 7- Grandmother\" crlf)\n\t(printout t \"- Familly knowledge base\" crlf)\n\t(printout t \" 8- Display a familly member by name\" crlf)\n\t(printout t \" 9- Display a familly member by parent\" crlf)\n\t(printout t \" 9- Add family member\" crlf)\n\t(printout t \" 11- Remove family member\" crlf)\n\t(printout t \"- Modify family member properties\" crlf)\n\t(printout t \" 8- Modify familly member name\" crlf)\n\t(printout t \" 9- Display a familly member by data\" crlf)\n\t(printout t \" 9- Add family member\" crlf)\n\t(printout t \" 11- Remove family member\" crlf)\n\t(printout t \"- Search familly members by properties\" crlf)\n\t(printout t \" 12- Show all individuals that match a combination of properties familly knowledge base\" crlf)\n\n\t(bind ?selectedOption (read))\n\n\t(assert(Selected ?selectedOption))\n)\n\n(defrule GetQueryData\n\t(Selected 12)\n=>\n\t(printout t \"Enter the criteria to search upon in the same order, write 'all' if you do not care about a specific property:\" crlf)\n\t\n\t(printout t \"What is the gender ? (m or f) or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryGender ?answer))\n\n\t(printout t \"What is the spouse name ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySpouse ?answer))\n\t\n\t(printout t \"What is the name of one of parents ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryParent ?answer))\n\t\n\t(printout t \"What is the name of one of siblings ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySiblings ?answer))\n\t\n\t(printout t \"What is the height range ? (equals to|greater than|less than) then press enter then input the height or write 'all'\" crlf)\n\t(bind ?type (readline))\n\t(bind ?height (read))\n\t(assert (QueryHeight ?type ?height))\n\t(printout t ?type crlf)\n\n)\n","old_contents":"(defrule ShowMainMenu\n\n=>\n\t(printout t \"- Infering relations about:\" crlf)\n\t(printout t \" 1- cousins \" crlf)\n\t(printout t \" 2- Nephews\" crlf)\n\t(printout t \" 3- Nieces\" crlf)\n\t(printout t \" 4- Uncle\" crlf)\n\t(printout t \" 5- Aunt\" crlf)\n\t(printout t \" 6- Grandfather\" crlf)\n\t(printout t \" 7- Grandmother\" crlf)\n\t(printout t \"- Modifiy familly knowledge base\" crlf)\n\t(printout t \" 8- Display a familly member by name\" crlf)\n\t(printout t \" 9- Display a familly member by data\" crlf)\n\t(printout t \" 9- Add family member\" crlf)\n\t(printout t \" 10- Modify family member properties\" crlf)\n\t(printout t \" 11- Remove family member\" crlf)\n\t(printout t \"- Search familly members by properties\" crlf)\n\t(printout t \" 12- Show all individuals that match a combination of properties familly knowledge base\" crlf)\n\n\t(bind ?selectedOption (read))\n\n\t(assert(Selected ?selectedOption))\n)\n\n(defrule GetQueryData\n\t(Selected 12)\n=>\n\t(printout t \"Enter the criteria to search upon in the same order, write 'all' if you do not care about a specific property:\" crlf)\n\t\n\t(printout t \"What is the gender ? (m or f) or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryGender ?answer))\n\n\t(printout t \"What is the spouse name ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySpouse ?answer))\n\t\n\t(printout t \"What is the name of one of parents ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryParent ?answer))\n\t\n\t(printout t \"What is the name of one of siblings ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySiblings ?answer))\n\t\n\t(printout t \"What is the height range ? (equals to|greater than|less than) then press enter then input the height or write 'all'\" crlf)\n\t(bind ?type (readline))\n\t(bind ?height (read))\n\t(assert (QueryHeight ?type ?height))\n\t(printout t ?type crlf)\n\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"4eb10a1424a9311eaab1d990ca0c62e88ff758ee","subject":"Rearranged the matching rules for determinant matching.","message":"Rearranged the matching rules for determinant matching.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::InstanceFrequencyCounter\n \"Creates a frequency counter hint for basic blocks\"\n (declare (salience 2))\n (object (is-a Region) \n (id ?p) \n (class Region))\n (not (exists (object (is-a FrequencyAnalysis) \n (parent ?p))))\n =>\n (make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::IncrementFrequencyCounter-BasicBlock\n \"Goes through a given Region counting the number of basic blocks found\n within the region. Valid blocks are blocks that contain more than one \n instruction as we don't want to count JS nodes as they don't usually \n contain code.\"\n (declare (salience 1))\n ?wa <- (object (is-a FrequencyAnalysis) \n (parent ?p))\n (object (is-a Region) \n (id ?p) \n (class Region) \n (contents $? ?t $?))\n (object (is-a BasicBlock) \n (id ?t) \n (parent ?p) \n (contents $?insts&:(> (length$ $?insts) 1)))\n =>\n (send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::ImplyEnoughBlocks\n \"There are enough blocks within the target region to make it a \n candidate for wavefront scheduling. Make a hint that says this.\"\n ?fa <- (object (is-a FrequencyAnalysis) \n (parent ?p) \n (frequency ?z&:(and (< ?z 100) (> ?z 1))))\n ?region <- (object (is-a Region) \n (id ?p)\n (class Region))\n =>\n (assert (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?p))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant-cleanup::cleanup-frequency-analysis\n ?fct <- (message (from pipeline) \n (to wavefront-scheduling-determinant-cleanup)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?fa (find-all-instances ((?freq FrequencyAnalysis)) TRUE))\n (unmake-instance ?fa)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::InstanceFrequencyCounter\n \"Creates a frequency counter hint for basic blocks\"\n (declare (salience 2))\n (object (is-a Region) \n (id ?p) \n (class Region))\n (not (exists (object (is-a FrequencyAnalysis) \n (parent ?p))))\n =>\n (make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::IncrementFrequencyCounter-BasicBlock\n \"Goes through a given Region counting the number of basic blocks found\n within the region. Valid blocks are blocks that contain more than one \n instruction as we don't want to count JS nodes as they don't usually \n contain code.\"\n (declare (salience 1))\n (object (is-a Region) \n (id ?p) \n (class Region) \n (contents $? ?t $?))\n (object (is-a BasicBlock) \n (id ?t) \n (parent ?p) \n (contents $?insts&:(> (length$ $?insts) 1)))\n ?wa <- (object (is-a FrequencyAnalysis) \n (parent ?p))\n =>\n (send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::ImplyEnoughBlocks\n \"There are enough blocks within the target region to make it a \n candidate for wavefront scheduling. Make a hint that says this.\"\n ?fa <- (object (is-a FrequencyAnalysis) \n (parent ?p) \n (frequency ?z&:(and (< ?z 100) (> ?z 1))))\n ?region <- (object (is-a Region) \n (id ?p)\n (class Region))\n =>\n (assert (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?p))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant-cleanup::cleanup-frequency-analysis\n ?fct <- (message (from pipeline) \n (to wavefront-scheduling-determinant-cleanup)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?fa (find-all-instances ((?freq FrequencyAnalysis)) TRUE))\n (unmake-instance ?fa)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"8947dcbb06942cee0d455621803c1b45f4c98c32","subject":"del comment","message":"del comment\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"frame.clp","new_file":"frame.clp","new_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)","old_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2\n;;howareyougit \n<<<<<<< HEAD\n;;sadasdh\n;asdhasdhoas;shdklfjhsdjk\n=======\n;;123131469564131345561\n;;mmmark\n;sdfsdfjklsdfh\n>>>>>>> origin\/master\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"57364d3c7242959a06dce9496b4baf7f04045ebb","subject":"Added the loop-region-merging pass to the PassRegistry","message":"Added the loop-region-merging pass to the PassRegistry\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/PassRegistry.clp","new_file":"lib\/durandal\/passes\/PassRegistry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ([loop-region-merging] of Pass\n (entry-point \"passes\/loop-region-merging\/PassHeader.clp\")\n (pass-name loop-region-merging)\n (pass-description \"Merges the loops and regions of a given function into a single logical CFG.\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes loop-region-merging)\n (required loops regions))\n\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"357818d390c0ea480577f6b72f2625e6e590b22d","subject":"Fixed bugs in WavefrontPropagation.clp","message":"Fixed bugs in WavefrontPropagation.clp\n\nI had given $?elements the name $?targets in my rewrite of one of the phi\nfunctions. I have reverted this.\n\nI had also made it so that the result of (\/ (length$ $?elements) 2) was not\nbeing bound to a variable and instead was being passed directly to the\ncreate-phi-node function. This has been fixed.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n ?count\n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n (\/ (length$ $?elements) 2) \n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"abbb90042f69bc82c3590655ed0b597ce83a31d0","subject":"waltz: commented out the deffunctions","message":"waltz: commented out the deffunctions\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltz\/waltz.clp","new_file":"clipsfiles\/waltz\/waltz.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n; ;;; #################################################################\n; ;;; Deffunctions\n; ;;;\n; ;;; In the OPS5 version of this program, the following deffunctions\n; ;;; were implemented in C code that needed to be linked with the OPS5\n; ;;; interpreter. Using deffunctions allows the benchmark to be run\n; ;;; without having to recompile and relink CLIPS with the C code used\n; ;;; in the original benchmark. The performance impact of using\n; ;;; deffunctions for this benchmark rather than C code is minimal.\n; ;;; #################################################################\n\n; (defglobal ?*MOD-NUM* = 100)\n\n; ;;; *****\n; ;;; atan2\n; ;;; *****\n\n; (deffunction atan2 (?y ?x)\n; (if (> ?x 0)\n; then\n; (return (atan (\/ ?y ?x))))\n\n; (if (< ?x 0)\n; then\n; (return (- (atan (\/ ?y ?x)) (pi))))\n\n; (if (> ?y 0) then\n; then\n; (return (pi)))\n\n; (if (< ?y 0)\n; then\n; (return (- 0 (pi))))\n\n; (return undefined))\n\n; ;;; *****\n; ;;; get-y\n; ;;; *****\n\n; (deffunction get-y (?val)\n; (mod ?val ?*MOD-NUM*))\n\n; ;;; *****\n; ;;; get-x\n; ;;; *****\n\n; (deffunction get-x (?val)\n; (integer (\/ ?val ?*MOD-NUM*)))\n\n; ;;; *********\n; ;;; get-angle\n; ;;; *********\n\n; (deffunction get-angle (?p1 ?p2)\n; (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n; (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n; (if (= ?delta-x 0)\n; then\n; (if (> ?delta-y 0)\n; \t\t then (return (\/ (pi) 2))\n; \t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n; else\n; (if (= ?delta-y 0)\n; then\n; (if (> ?delta-x 0)\n; then (return 0.0)\n; \t\t else (if (< ?delta-x 0) then return (pi)))\n; else\n; (return (atan2 ?delta-y ?delta-x)))))\n\n; ;;; ***************\n; ;;; inscribed-angle\n; ;;; ***************\n\n; (deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n; \t;; Get the angle between line #1 and the origin and the angle\n; \t;; between line #2 and the origin, and then subtract these values.\n\n; (bind ?angle1 (get-angle ?basepoint ?p1))\n; (bind ?angle2 (get-angle ?basepoint ?p2))\n; (bind ?temp (- ?angle1 ?angle2))\n\n; (if (< ?temp 0)\n; then (bind ?temp (- 0 ?temp)))\n\n; ;; We always want the smaller of the two angles inscribed, so\n; ;; if the answer is greater than 180 degrees, calculate the\n; ;; smaller angle and return it.\n\n; (if (> ?temp (pi))\n; then\n; (bind ?temp (- (* 2 (pi)) ?temp)))\n\n; (if (< ?temp 0)\n; then (return (- 0 ?temp)))\n\n; (return ?temp))\n\n; ;;; ***************\n; ;;; make-3-junction\n; ;;; ***************\n\n; (deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n; (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n; (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n; (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n; (bind ?sum1213 (+ ?angle12 ?angle13))\n; (bind ?sum1223 (+ ?angle12 ?angle23))\n; (bind ?sum1323 (+ ?angle13 ?angle23))\n\n; (if (< ?sum1213 ?sum1223)\n; then\n; (if (< ?sum1213 ?sum1323)\n; then\n; (bind ?sum ?sum1213)\n; (bind ?shaft ?p1)\n; (bind ?barb1 ?p2)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2))\n; else\n; (if (< ?sum1223 ?sum1323)\n; then\n; (bind ?sum ?sum1223)\n; (bind ?shaft ?p2)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2)))\n\n; (bind ?delta (- ?sum (pi)))\n; (if (< ?delta 0)\n; then (bind ?delta (- 0 ?delta)))\n\n; (if (< ?delta 0.001)\n; then (bind ?jtype tee)\n; else\n; (if (> ?sum (pi))\n; then (bind ?jtype fork)\n; else (bind ?jtype arrow)))\n\n; (assert (junction (p1 (integer ?barb1))\n; (p2 (integer ?shaft))\n; (p3 (integer ?barb2))\n; (base_point (integer ?basepoint))\n; (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","old_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n;;; #################################################################\n;;; Deffunctions\n;;;\n;;; In the OPS5 version of this program, the following deffunctions\n;;; were implemented in C code that needed to be linked with the OPS5\n;;; interpreter. Using deffunctions allows the benchmark to be run\n;;; without having to recompile and relink CLIPS with the C code used\n;;; in the original benchmark. The performance impact of using\n;;; deffunctions for this benchmark rather than C code is minimal.\n;;; #################################################################\n\n(defglobal ?*MOD-NUM* = 100)\n\n;;; *****\n;;; atan2\n;;; *****\n\n(deffunction atan2 (?y ?x)\n (if (> ?x 0)\n then\n (return (atan (\/ ?y ?x))))\n\n (if (< ?x 0)\n then\n (return (- (atan (\/ ?y ?x)) (pi))))\n\n (if (> ?y 0) then\n then\n (return (pi)))\n\n (if (< ?y 0)\n then\n (return (- 0 (pi))))\n\n (return undefined))\n\n;;; *****\n;;; get-y\n;;; *****\n\n(deffunction get-y (?val)\n (mod ?val ?*MOD-NUM*))\n\n;;; *****\n;;; get-x\n;;; *****\n\n(deffunction get-x (?val)\n (integer (\/ ?val ?*MOD-NUM*)))\n\n;;; *********\n;;; get-angle\n;;; *********\n\n(deffunction get-angle (?p1 ?p2)\n (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n (if (= ?delta-x 0)\n then\n (if (> ?delta-y 0)\n\t\t then (return (\/ (pi) 2))\n\t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n else\n (if (= ?delta-y 0)\n then\n (if (> ?delta-x 0)\n then (return 0.0)\n\t\t else (if (< ?delta-x 0) then return (pi)))\n else\n (return (atan2 ?delta-y ?delta-x)))))\n\n;;; ***************\n;;; inscribed-angle\n;;; ***************\n\n(deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n\t;; Get the angle between line #1 and the origin and the angle\n\t;; between line #2 and the origin, and then subtract these values.\n\n (bind ?angle1 (get-angle ?basepoint ?p1))\n (bind ?angle2 (get-angle ?basepoint ?p2))\n (bind ?temp (- ?angle1 ?angle2))\n\n (if (< ?temp 0)\n then (bind ?temp (- 0 ?temp)))\n\n ;; We always want the smaller of the two angles inscribed, so\n ;; if the answer is greater than 180 degrees, calculate the\n ;; smaller angle and return it.\n\n (if (> ?temp (pi))\n then\n (bind ?temp (- (* 2 (pi)) ?temp)))\n\n (if (< ?temp 0)\n then (return (- 0 ?temp)))\n\n (return ?temp))\n\n;;; ***************\n;;; make-3-junction\n;;; ***************\n\n(deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n (bind ?sum1213 (+ ?angle12 ?angle13))\n (bind ?sum1223 (+ ?angle12 ?angle23))\n (bind ?sum1323 (+ ?angle13 ?angle23))\n\n (if (< ?sum1213 ?sum1223)\n then\n (if (< ?sum1213 ?sum1323)\n then\n (bind ?sum ?sum1213)\n (bind ?shaft ?p1)\n (bind ?barb1 ?p2)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2))\n else\n (if (< ?sum1223 ?sum1323)\n then\n (bind ?sum ?sum1223)\n (bind ?shaft ?p2)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2)))\n\n (bind ?delta (- ?sum (pi)))\n (if (< ?delta 0)\n then (bind ?delta (- 0 ?delta)))\n\n (if (< ?delta 0.001)\n then (bind ?jtype tee)\n else\n (if (> ?sum (pi))\n then (bind ?jtype fork)\n else (bind ?jtype arrow)))\n\n (assert (junction (p1 (integer ?barb1))\n (p2 (integer ?shaft))\n (p3 (integer ?barb2))\n (base_point (integer ?basepoint))\n (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"7c71a2fb25d616ba179afd32b8cf3d3758cd982f","subject":"Replaced a call to (not (eq with (<> in ValidBlockIdentification.clp","message":"Replaced a call to (not (eq with (<> in ValidBlockIdentification.clp\n\nThis was done to make the code slightly more efficient by having one native\ncall instead of two for each match attempt when dealing with successor checks\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) \n (id ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n\t\t\t\t\t\t\t\t(Successors $?a&:(<> (length$ $?a) 1)))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) \n (id ?path) \n (values $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?path ?block => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) \n (id ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) \n (id ?path) \n (values $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?path ?block => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9a280df63795d4b80f9315638d9714942be8cc62","subject":"Modified GLConstantConversion.clp to output code with correct formatting","message":"Modified GLConstantConversion.clp to output code with correct formatting\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n; Alright, we now need to build a corresponding procedure from each heading\n; There are several ways to do this. The easiest would be to just do it\n; procedurally in a single rule fire. \n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\")) {\" \n (if ?if then \"if\" else \"} else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-constant-conversion-procedure\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (> (length$ $?entries) 0))\n =>\n (unmake-instance ?obj)\n (bind ?target (format nil \"\/\/%s\" ?group))\n (bind ?header (format nil \"extern GLenum To%s(char* input) {\" ?group))\n (bind ?first (to-conditional-field (nth$ 1 (first$ ?entries)) TRUE))\n (bind ?result (create$ ?target ?header ?first))\n (progn$ (?e (rest$ ?entries))\n (bind ?result \n (create$ ?result (to-conditional-field ?e FALSE))))\n (bind ?result (create$ ?result \"} else {\" \"return 0;\" \"}\" \"}\"))\n (progn$ (?r ?result) (printout t ?r crlf))\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule grouping-update::skip-constant-conversion\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (= (length$ $?entries) 0))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n; Alright, we now need to build a corresponding procedure from each heading\n; There are several ways to do this. The easiest would be to just do it\n; procedurally in a single rule fire. \n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\")) {\" \n (if ?if then \"if\" else \"else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)\n \"}\"))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-constant-conversion-procedure\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (> (length$ $?entries) 0))\n =>\n (unmake-instance ?obj)\n (bind ?target (format nil \"\/\/%s\" ?group))\n (bind ?header \"extern GLenum To????(char* input) {\")\n (bind ?first (to-conditional-field (nth$ 1 (first$ ?entries)) TRUE))\n (bind ?result (create$ ?target ?header ?first))\n (progn$ (?e (rest$ ?entries))\n (bind ?result \n (create$ ?result (to-conditional-field ?e FALSE))))\n (bind ?result (create$ ?result \"else {\" \"return 0;\" \"}\" \"}\"))\n (progn$ (?r ?result) (printout t ?r crlf))\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule grouping-update::skip-constant-conversion\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (= (length$ $?entries) 0))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"afae5543bf00e22b20ef9fd6a13360217a1bbc51","subject":"waltz: added type info, renamed slot \"type\" to \"jtype\", removed trailing spaces","message":"waltz: added type info, renamed slot \"type\" to \"jtype\", removed trailing spaces\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltz\/waltz.clp","new_file":"clipsfiles\/waltz\/waltz.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n;;; #################################################################\n;;; Deffunctions\n;;;\n;;; In the OPS5 version of this program, the following deffunctions\n;;; were implemented in C code that needed to be linked with the OPS5\n;;; interpreter. Using deffunctions allows the benchmark to be run\n;;; without having to recompile and relink CLIPS with the C code used\n;;; in the original benchmark. The performance impact of using\n;;; deffunctions for this benchmark rather than C code is minimal.\n;;; #################################################################\n\n(defglobal ?*MOD-NUM* = 100)\n\n;;; *****\n;;; atan2\n;;; *****\n\n(deffunction atan2 (?y ?x)\n (if (> ?x 0)\n then\n (return (atan (\/ ?y ?x))))\n\n (if (< ?x 0)\n then\n (return (- (atan (\/ ?y ?x)) (pi))))\n\n (if (> ?y 0) then\n then\n (return (pi)))\n\n (if (< ?y 0)\n then\n (return (- 0 (pi))))\n\n (return undefined))\n\n;;; *****\n;;; get-y\n;;; *****\n\n(deffunction get-y (?val)\n (mod ?val ?*MOD-NUM*))\n\n;;; *****\n;;; get-x\n;;; *****\n\n(deffunction get-x (?val)\n (integer (\/ ?val ?*MOD-NUM*)))\n\n;;; *********\n;;; get-angle\n;;; *********\n\n(deffunction get-angle (?p1 ?p2)\n (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n (if (= ?delta-x 0)\n then\n (if (> ?delta-y 0)\n\t\t then (return (\/ (pi) 2))\n\t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n else\n (if (= ?delta-y 0)\n then\n (if (> ?delta-x 0)\n then (return 0.0)\n\t\t else (if (< ?delta-x 0) then return (pi)))\n else\n (return (atan2 ?delta-y ?delta-x)))))\n\n;;; ***************\n;;; inscribed-angle\n;;; ***************\n\n(deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n\t;; Get the angle between line #1 and the origin and the angle\n\t;; between line #2 and the origin, and then subtract these values.\n\n (bind ?angle1 (get-angle ?basepoint ?p1))\n (bind ?angle2 (get-angle ?basepoint ?p2))\n (bind ?temp (- ?angle1 ?angle2))\n\n (if (< ?temp 0)\n then (bind ?temp (- 0 ?temp)))\n\n ;; We always want the smaller of the two angles inscribed, so\n ;; if the answer is greater than 180 degrees, calculate the\n ;; smaller angle and return it.\n\n (if (> ?temp (pi))\n then\n (bind ?temp (- (* 2 (pi)) ?temp)))\n\n (if (< ?temp 0)\n then (return (- 0 ?temp)))\n\n (return ?temp))\n\n;;; ***************\n;;; make-3-junction\n;;; ***************\n\n(deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n (bind ?sum1213 (+ ?angle12 ?angle13))\n (bind ?sum1223 (+ ?angle12 ?angle23))\n (bind ?sum1323 (+ ?angle13 ?angle23))\n\n (if (< ?sum1213 ?sum1223)\n then\n (if (< ?sum1213 ?sum1323)\n then\n (bind ?sum ?sum1213)\n (bind ?shaft ?p1)\n (bind ?barb1 ?p2)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2))\n else\n (if (< ?sum1223 ?sum1323)\n then\n (bind ?sum ?sum1223)\n (bind ?shaft ?p2)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2)))\n\n (bind ?delta (- ?sum (pi)))\n (if (< ?delta 0)\n then (bind ?delta (- 0 ?delta)))\n\n (if (< ?delta 0.001)\n then (bind ?jtype tee)\n else\n (if (> ?sum (pi))\n then (bind ?jtype fork)\n else (bind ?jtype arrow)))\n\n (assert (junction (p1 (integer ?barb1))\n (p2 (integer ?shaft))\n (p3 (integer ?barb2))\n (base_point (integer ?basepoint))\n (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicate)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicate))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicate))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","old_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n \n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is \n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark \n \n;;; ##########################################################################\n;;; Deftemplates \n;;;\n;;; Lines have the lable line followed by the 2 points defining the line. \n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted. \n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines \n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at \n;;; this junction\n;;; ##########################################################################\n \n(deftemplate stage \n (slot value))\n \n(deftemplate line \n (slot p1) \n (slot p2))\n \n(deftemplate edge\n (slot p1)\n (slot p2)\n (slot joined)\n (slot label)\n (slot plotted))\n \n(deftemplate junction \n (slot p1)\n (slot p2)\n (slot p3)\n (slot base_point)\n (slot type))\n\n;;; #################################################################\n;;; Deffunctions \n;;; \n;;; In the OPS5 version of this program, the following deffunctions \n;;; were implemented in C code that needed to be linked with the OPS5 \n;;; interpreter. Using deffunctions allows the benchmark to be run \n;;; without having to recompile and relink CLIPS with the C code used \n;;; in the original benchmark. The performance impact of using \n;;; deffunctions for this benchmark rather than C code is minimal.\n;;; #################################################################\n\n(defglobal ?*MOD-NUM* = 100)\n\n;;; *****\n;;; atan2\n;;; *****\n\n(deffunction atan2 (?y ?x)\n (if (> ?x 0) \n then\n (return (atan (\/ ?y ?x))))\n \n (if (< ?x 0) \n then\n (return (- (atan (\/ ?y ?x)) (pi))))\n \n (if (> ?y 0) then\n then\n (return (pi)))\n\n (if (< ?y 0)\n then\n (return (- 0 (pi))))\n \n (return undefined))\n \n;;; *****\n;;; get-y\n;;; *****\n\n(deffunction get-y (?val)\n (mod ?val ?*MOD-NUM*))\n \n;;; *****\n;;; get-x\n;;; *****\n\n(deffunction get-x (?val)\n (integer (\/ ?val ?*MOD-NUM*)))\n \n;;; *********\n;;; get-angle\n;;; *********\n\n(deffunction get-angle (?p1 ?p2)\n (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n (if (= ?delta-x 0)\n then\n (if (> ?delta-y 0)\n\t\t then (return (\/ (pi) 2))\n\t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n else\n (if (= ?delta-y 0)\n then\n (if (> ?delta-x 0)\n then (return 0.0)\n\t\t else (if (< ?delta-x 0) then return (pi)))\n else\n (return (atan2 ?delta-y ?delta-x)))))\n \n;;; ***************\n;;; inscribed-angle\n;;; ***************\n\n(deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\t\n\t;; Get the angle between line #1 and the origin and the angle\n\t;; between line #2 and the origin, and then subtract these values. \n\n (bind ?angle1 (get-angle ?basepoint ?p1))\n (bind ?angle2 (get-angle ?basepoint ?p2))\n (bind ?temp (- ?angle1 ?angle2))\n \n (if (< ?temp 0) \n then (bind ?temp (- 0 ?temp)))\n \n ;; We always want the smaller of the two angles inscribed, so \n ;; if the answer is greater than 180 degrees, calculate the \n ;; smaller angle and return it. \n\n (if (> ?temp (pi))\n then\n (bind ?temp (- (* 2 (pi)) ?temp)))\n \n (if (< ?temp 0)\n then (return (- 0 ?temp)))\n \n (return ?temp))\n\n;;; ***************\n;;; make-3-junction\n;;; ***************\n\n(deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n \n (bind ?sum1213 (+ ?angle12 ?angle13))\n (bind ?sum1223 (+ ?angle12 ?angle23))\n (bind ?sum1323 (+ ?angle13 ?angle23))\n \n (if (< ?sum1213 ?sum1223)\n then\n (if (< ?sum1213 ?sum1323)\n then\n (bind ?sum ?sum1213)\n (bind ?shaft ?p1)\n (bind ?barb1 ?p2)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2))\n else\n (if (< ?sum1223 ?sum1323)\n then\n (bind ?sum ?sum1223)\n (bind ?shaft ?p2)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2)))\n \n (bind ?delta (- ?sum (pi)))\n (if (< ?delta 0)\n then (bind ?delta (- 0 ?delta)))\n \n (if (< ?delta 0.001)\n then (bind ?type tee)\n else\n (if (> ?sum (pi))\n then (bind ?type fork)\n else (bind ?type arrow)))\n \n (assert (junction (p1 (integer ?barb1))\n (p2 (integer ?shaft))\n (p3 (integer ?barb2))\n (base_point (integer ?basepoint))\n (type ?type))))\n\n;;; ########\n;;; Defrules \n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the \n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicate)))\n \n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicate))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n \n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more \n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicate))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n \n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already \n;;; been joined in a junction, then make the corresponding type of junction and \n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what type of junction it is based on the angles inscribed by the \n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n \n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not \n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (type L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n \n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are \n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n \n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary \n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (type L) \n (base_point ?base_point) \n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n \n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n \n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary \n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n \n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (type L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n \n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\t\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n \n;;; *******\n;;; label_L\n;;; *******\n \n(defrule label_L\n\t(stage (value labeling))\n\t(junction (type L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n \n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n \n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (type tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n \n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (type fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n \n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (type fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n \n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (type fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n \n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (type fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n \n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n \n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n \n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n \n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n \n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n \n;;; **************\n;;; label_arrow-4A\n;;; **************\n \n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n \n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n \n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n \n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (type arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n \n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production \n;;; if no productions that are more complicated are satisfied. This production \n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n \n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may \n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n \n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only \n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n \n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n ","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"b9bcb7ea93e45cb7c0c96e3f51f383575c9d49af","subject":"Updated the etc\/sys.clp description comment","message":"Updated the etc\/sys.clp description comment\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-filesystem","old_file":"etc\/sys.clp","new_file":"etc\/sys.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; sys.clp - Defines system variables that the rest of the filesystem uses. This\n; is called by the system bootstrap after finding out where it is\n;------------------------------------------------------------------------------\n; Define filesystem base points \n(defglobal MAIN\n ; lib directory\n ?*lib* = (format nil \"%s\/lib\" ?*fsys*)\n ; data directory\n ?*data* = (format nil \"%s\/data\" ?*fsys*)\n ; bin directory\n ?*bin* = (format nil \"%s\/bin\" ?*fsys*)\n ; etc directory\n ?*etc* = (format nil \"%s\/etc\" ?*fsys*)\n ?*path* = (create$ ?*lib*))\n\n","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; sys.clp - Defines system variables that the rest of the filesystem uses. This\n; is the bootstrap\n;------------------------------------------------------------------------------\n; Define filesystem base points \n(defglobal MAIN\n ; lib directory\n ?*lib* = (format nil \"%s\/lib\" ?*fsys*)\n ; data directory\n ?*data* = (format nil \"%s\/data\" ?*fsys*)\n ; bin directory\n ?*bin* = (format nil \"%s\/bin\" ?*fsys*)\n ; etc directory\n ?*etc* = (format nil \"%s\/etc\" ?*fsys*)\n ?*path* = (create$ ?*lib*))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"cc5e049ff3a5d43ee18f1765a3899edb6003e545","subject":"Modified GLConstantConverter to ignore GLAPI calls at this point in time","message":"Modified GLConstantConverter to ignore GLAPI calls at this point in time\n","repos":"DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type #define) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (object (is-a heading-span)\n (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) \n ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \"(\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \"(\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (object (is-a heading-span)\n (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"a9405efd7fb92ebb115f4187f871fa3a8b031d43","subject":"Added support for removing the leading * on three-line-headers","message":"Added support for removing the leading * on three-line-headers\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"ee3109efd4fcb161b3e18842e3f385e5a9fee561","subject":"Fixed a bug in logic\/painter.clp","message":"Fixed a bug in logic\/painter.clp\n","repos":"DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery.clp)\n(defglobal MAIN\n ?*old-timestamp* = 0\n ?*max-factor* = 128\n ?*factor* = 1)\n\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (bind ?*old-timestamp* (send [mouse] get-timestamp))\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?*factor*)) \n (by (+ ?y ?*factor*)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n =>\n (if (< ?*factor* ?*max-factor*) then\n (bind ?*factor* (+ ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n =>\n (if (> ?*factor* 1) then\n (bind ?*factor* (- ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery.clp)\n(defglobal MAIN\n ?*old-timestamp* = 0\n ?*max-factor* = 128\n ?*factor* = 1)\n\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (bind ?*old-timestamp* (send [mouse] get-timestamp))\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?*factor*)) \n (by (+ ?y ?*factor*)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n =>\n (if (< ?*factor* ?*max-factor*) then\n (bind ?*factor* (+ ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n =>\n (if (>= ?*factor* 0) then\n (bind ?*factor* (- ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"1fbc4d82c2ba7ca45813ce308f9601615745c3c7","subject":"src\/LoadEngine.clp: Added the widget library","message":"src\/LoadEngine.clp: Added the widget library\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/LoadEngine.clp","new_file":"src\/LoadEngine.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"init\/Library.clp\")\n;------------------------------------------------------------------------------\n(load-library cortex)\n(load-library dendrite)\n(load-library widget)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n;relative to the root of the source directory\n(batch* \"init\/Library.clp\")\n;------------------------------------------------------------------------------\n(load-library cortex)\n(load-library dendrite)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"33dc635afafea7e16e9bdcb14eb5159b2c6bdbd7","subject":"fixed clips import","message":"fixed clips import\n","repos":"DonatoMeoli\/BeerEX","old_file":"clipsrc\/beerex.clp","new_file":"clipsrc\/beerex.clp","new_contents":"\n;;;===============================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===============================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (range -1.0 1.0)\n (default 1.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clipsrc\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?attribute1 ?attribute2)\n (< (fact-slot-value ?attribute1 certainty) (fact-slot-value ?attribute2 certainty)))\n\n(deffunction combine-CFs (?x ?y)\n (if (and (> ?x 0) (> ?y 0))\n then (bind ?c (- (+ ?x ?y) (* ?x ?y)))\n else (if (and (< ?x 0) (< ?y 0))\n then (bind ?c (+ (+ ?x ?y) (* ?x ?y)))\n else (bind ?c (\/ (+ ?x ?y ) (- 1 (min (abs ?x) (abs ?y)))))))\n ?c)\n\n(deffunction get-explanation ()\n (bind ?explanation (format nil \"%s %n%n\" \"*... for the following reasons:*\"))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-scenario)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-preference)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-main-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-specific-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n ?explanation)\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clipsrc\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clipsrc\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (combine-CFs ?certainty1 ?certainty2))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule clean-working-memory-and-print-results\n (declare (salience ?*low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (bind ?beers \"\")\n (bind ?attributes (sort sort-certainties (find-all-facts ((?a attribute)) (eq ?a:name beer))))\n (progn$ (?a ?attributes)\n (if (< (member$ ?a ?attributes) 5)\n then (bind ?beers (str-cat ?beers (format nil \"%s with certainty %2d%% %n\" (fact-slot-value ?a value)\n (* (fact-slot-value ?a certainty) 100)))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n%s %n%s\" \"*\u2705 Done. I have selected these beer styles for you...*\"\n ?beers (get-explanation))))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (do-for-all-facts ((?a attribute)) TRUE (retract ?a))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq (get-strategy) random)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"random-question\" ?rule) FALSE)\n then (refresh ?rule))))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))\n","old_contents":"\n;;;===============================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===============================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (range -1.0 1.0)\n (default 1.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clips\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?attribute1 ?attribute2)\n (< (fact-slot-value ?attribute1 certainty) (fact-slot-value ?attribute2 certainty)))\n\n(deffunction combine-CFs (?x ?y)\n (if (and (> ?x 0) (> ?y 0))\n then (bind ?c (- (+ ?x ?y) (* ?x ?y)))\n else (if (and (< ?x 0) (< ?y 0))\n then (bind ?c (+ (+ ?x ?y) (* ?x ?y)))\n else (bind ?c (\/ (+ ?x ?y ) (- 1 (min (abs ?x) (abs ?y)))))))\n ?c)\n\n(deffunction get-explanation ()\n (bind ?explanation (format nil \"%s %n%n\" \"*... for the following reasons:*\"))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-scenario)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute))\n (eq ?a:name explanation-preference)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-main-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n (do-for-all-facts ((?a attribute)) (eq ?a:name explanation-specific-meal)\n (bind ?explanation (str-cat ?explanation ?a:value \" \")))\n ?explanation)\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clipsrc\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clipsrc\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (combine-CFs ?certainty1 ?certainty2))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule clean-working-memory-and-print-results\n (declare (salience ?*low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (bind ?beers \"\")\n (bind ?attributes (sort sort-certainties (find-all-facts ((?a attribute)) (eq ?a:name beer))))\n (progn$ (?a ?attributes)\n (if (< (member$ ?a ?attributes) 5)\n then (bind ?beers (str-cat ?beers (format nil \"%s with certainty %2d%% %n\" (fact-slot-value ?a value)\n (* (fact-slot-value ?a certainty) 100)))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n%s %n%s\" \"*\u2705 Done. I have selected these beer styles for you...*\"\n ?beers (get-explanation))))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (do-for-all-facts ((?a attribute)) TRUE (retract ?a))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq (get-strategy) random)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"random-question\" ?rule) FALSE)\n then (refresh ?rule))))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"6be2cbe873151fa954cd9b146ee21b63004a6388","subject":"Updated pipeline logic to not pop the top focus element","message":"Updated pipeline logic to not pop the top focus element\n\nThis was causing a slow down to occur because we were entering the MAIN module\nwhich was being saved to the focus stack when focus was called.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n ?fct <- (message (to pipeline) \n (action pass-description) \n (arguments $?passes))\n =>\n (retract ?fct)\n (make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n ?obj <- (object (is-a pass-description) \n (passes ?first $?rest))\n =>\n (modify-instance ?obj (passes $?rest))\n ;remove what is currently on the focus stack\n ;\t\t\t(pop-focus)\n (assert (message (from pipeline) \n (to ?first) \n (action initial-fact)))\n (focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n ?obj <- (object (is-a pass-description) \n (passes))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n\t\t\t?fct <- (message (to pipeline) \n\t\t\t\t\t\t\t\t (action pass-description) \n\t\t\t\t\t\t\t\t (arguments $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n\t\t\t?obj <- (object (is-a pass-description) \n\t\t\t\t\t\t\t\t (passes ?first $?rest))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (passes $?rest))\n\t\t\t;remove what is currently on the focus stack\n\t\t\t(pop-focus)\n\t\t\t(assert (message (from pipeline) \n\t\t\t\t\t\t\t\t (to ?first) \n\t\t\t\t\t\t\t\t (action initial-fact)))\n\t\t\t(focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n\t\t\t?obj <- (object (is-a pass-description) \n\t\t\t\t\t\t\t\t (passes))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c04392096cebfbb8b25e3557875e8ef8bb51d55f","subject":"Update task3.clp","message":"Update task3.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task3.clp","new_file":"ssu-ai-level-2\/chapter7\/task3.clp","new_contents":"(deffunction str-del (?substr ?str)\n (bind ?n1 (str-length ?substr))\n (bind ?n2 (str-length ?str))\n (bind ?k (str-index ?substr ?str))\n (while (> ?k 0) do\n (bind ?st1 (sub-string 1 (- ?k 1) ?str))\n (bind ?st2 (sub-string (+ ?k ?n1) ?n2 ?str))\n (bind ?str (str-cat ?st1 ?st2))\n (bind ?k (str-index ?substr ?str))\n (if (not ?k) then \n (bind ?k 0)\n )\n )\n ?str)\n\n(defrule substr_delete\n=>\n(bind ?str (read))\n(bind ?substr (read))\n(bind ?str (str-del ?substr ?str))\n(printout t \"str=\" ?str crlf))\n","old_contents":"(deffunction str-del (?substr ?str)\n (bind ?n1 (str-length ?substr))\n (bind ?n2 (str-length ?str))\n (bind ?k (str-index ?substr ?str))\n (while (> ?k 0) do\n (bind ?st1 (sub-string 1 (- ?k 1) ?str))\n (bind ?st2 (sub-string (+ ?k ?n1) ?n2 ?str))\n (bind ?str (str-cat ?st1 ?st2))\n (bind ?k (str-index ?substr ?str))\n (if (not ?k) then \n (bind ?k 0)\n )\n )\n ?str)\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"8fd0b25ac79a9ea3723ddeda6b1928af40f913aa","subject":"add and sample","message":"add and sample\n","repos":"qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace,qrsforever\/workspace","old_file":"clips\/learn\/user_guide\/class-rule.clp","new_file":"clips\/learn\/user_guide\/class-rule.clp","new_contents":"; sample test\n\n(clear)\n(defclass DUCK (is-a USER)\n (slot age (default 1))\n (multislot sound (default quack quack))\n)\n\n(defrule find-sound\n ?duck <- (object\n (is-a DUCK)\n (sound $?find))\n =>\n (printout t \"Duck \" (instance-name ?duck) \" says \" ?find crlf)\n)\n\n(defrule find-dorky-sound\n (object\n (is-a DUCK)\n (sound $?find)\n (name [Dorky_Duck]))\n =>\n (printout t \"[Dorky_Duck] sound\" crlf)\n)\n\n(make-instance [Dorky_Duck] of DUCK)\n(make-instance [Dinky_Duck] of DUCK)\n\n(instances)\n\n(agenda)\n(run)\n\n(defrule find-age-over-10\n ?duck <- (object\n (is-a DUCK)\n (age ?age &:(> ?age 10)))\n =>\n (printout t \"Duck-1 \" (instance-name ?duck) \" age \" ?age crlf)\n)\n\n(defrule find-age-over-20-or-below-10\n ?duck <- (object\n (is-a DUCK)\n (age ?age &:(> ?age 20)|:(< ?age 10)))\n =>\n (printout t \"Duck-2 \" (instance-name ?duck) \" age \" ?age crlf)\n)\n\n(defrule find-age-over-10-and-below-20\n ?duck <- (object\n (is-a DUCK)\n (age ?age &:(> ?age 10)&:(< ?age 20)))\n =>\n (printout t \"Duck-3 \" (instance-name ?duck) \" age \" ?age crlf)\n)\n\n(defrule find-name-is-unkown-or-name-is-dinky\n (or\n (object\n (is-a DUCK)\n (age 30)\n )\n\n (object\n (is-a DUCK)\n (name [Dinky_Duck])\n )\n )\n ?f <- (make-again 1)\n =>\n (retract ?f)\n (printout t \"Duck-3 \" crlf)\n)\n\n; (send [Dinky_Duck] put-age 30)\n; (assert (make-again 1))\n; (send [Dinky_Duck] print)\n; \n(instances)\n\n(send [Dinky_Duck] print)\n(send [Dorky_Duck] print)\n(send [Dinky_Duck] put-age 25)\n(send [Dinky_Duck] put-age 15)\n(agenda)\n(run)\n\n; (agenda)\n; (run)\n; (agenda)\n; \n; (assert (make-again 1))\n; (facts)\n; (instances)\n; (agenda)\n\n(exit)\n","old_contents":"; sample test\n\n(clear)\n(defclass DUCK (is-a USER)\n (slot age (default 1))\n (multislot sound (default quack quack))\n)\n\n(defrule find-sound\n ?duck <- (object\n (is-a DUCK)\n (sound $?find))\n =>\n (printout t \"Duck \" (instance-name ?duck) \" says \" ?find crlf)\n)\n\n(defrule find-dorky-sound\n (object\n (is-a DUCK)\n (sound $?find)\n (name [Dorky_Duck]))\n =>\n (printout t \"[Dorky_Duck] sound\" crlf)\n)\n\n(make-instance [Dorky_Duck] of DUCK)\n(make-instance [Dinky_Duck] of DUCK)\n\n(instances)\n\n(agenda)\n(run)\n\n(defrule find-age-over-10\n ?duck <- (object\n (is-a DUCK)\n (age ?age &:(> ?age 10)))\n =>\n (printout t \"Duck-1 \" (instance-name ?duck) \" age \" ?age crlf)\n)\n\n(defrule find-age-over-20-or-below-10\n ?duck <- (object\n (is-a DUCK)\n (age ?age &:(> ?age 20)|:(< ?age 10)))\n =>\n (printout t \"Duck-2 \" (instance-name ?duck) \" age \" ?age crlf)\n)\n\n(defrule find-name-is-unkown-or-name-is-dinky\n (or\n (object\n (is-a DUCK)\n (age 30)\n )\n\n (object\n (is-a DUCK)\n (name [Dinky_Duck])\n )\n )\n ?f <- (make-again 1)\n =>\n (retract ?f)\n (printout t \"Duck-3 \" crlf)\n)\n\n(send [Dinky_Duck] put-age 30)\n(assert (make-again 1))\n(send [Dinky_Duck] print)\n\n(instances)\n\n(agenda)\n(run)\n(agenda)\n\n(assert (make-again 1))\n(facts)\n(instances)\n(agenda)\n\n(exit)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"6959704b2ffc49e6403104a006276edb99bf150e","subject":"- fixed the view test.","message":"- fixed the view test.\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@881 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/view-test.clp","new_file":"samples\/view-test.clp","new_contents":"(printout t '\n\n\n---J-A-M-O-C-H-A---B-Y---E-X-A-M-P-L-E---\n* Defining two templates *\n' crlf)\n\n(printout t '\nDefining a template T-1 with a slot S-1 of type STRING\nand a slot S-2 of type INTEGER:\n\n(deftemplate T-1 \n\t(slot S-1 (type STRING))\n\t(slot S-2 (type INTEGER))\n)'\n crlf)\n\n(deftemplate T-1 \n\t(slot S-1 (type STRING))\n\t(slot S-2 (type INTEGER))\n)\n\n\n\n(printout t '\nDefining a template T-2 with a slot S-3 of type STRING\nand a slot S-4 of type INTEGER:\n\n(deftemplate T-2\n\t(slot S-3 (type STRING))\n\t(slot S-4 (type INTEGER))\n)\n'\n crlf)\n\n(deftemplate T-2\n\t(slot S-3 (type STRING))\n\t(slot S-4 (type INTEGER))\n)\n\n\n(printout t '\nChecking if the templates defined exist by typing\n\n(templates)\n-->'\ncrlf)\n\n(templates)\n\n(printout t '\nand pretty print the definition of T-1 with\n\n(ppdeftemplate T-1)\n-->'\n crlf)\n \n(ppdeftemplate T-1)\n\n(printout t '\n\n\n---J-A-M-O-C-H-A---B-Y---E-X-A-M-P-L-E---\n* Defining two rules\n' crlf)\n\n(defrule R-1 \"rule one\"\n\t(T-1 (S-1 ?x)(S-2 42)) \n\t=>\n\t(printout t ?x crlf)\n)\n\n\n(defrule R-2 \"rule two\"\n\t(T-2 (S-3 ?y)(S-4 28))\n\t=>\n\t(printout t ?y crlf)\n)\n\n(defrule R-3 \"rule three\"\n\t(T-1 (S-1 ?x)(S-2 2)) (T-2 (S-3 ?y)(S-4 2))\n\t=>\n\t(printout t ?x crlf)\n)\n\n(assert (T-1 (S-1 a)(S-2 1)))\n(assert (T-2 (S-3 a)(S-4 1)))\n\n(assert (T-1 (S-1 b)(S-2 2)))\n(assert (T-2 (S-3 b)(S-4 2)))\n\n(fire)\n\n","old_contents":"(printout t '\n\n\n---J-A-M-O-C-H-A---B-Y---E-X-A-M-P-L-E---\n* Defining two templates *\n' crlf)\n\n(printout t '\nDefining a template T-1 with a slot S-1 of type STRING\nand a slot S-2 of type INTEGER:\n\n(deftemplate T-1 \n\t(slot S-1 (type STRING))\n\t(slot S-2 (type INTEGER))\n)'\n crlf)\n\n(deftemplate T-1 \n\t(slot S-1 (type STRING))\n\t(slot S-2 (type INTEGER))\n)\n\n\n\n(printout t '\nDefining a template T-2 with a slot S-3 of type STRING\nand a slot S-4 of type INTEGER:\n\n(deftemplate T-2\n\t(slot S-3 (type STRING))\n\t(slot S-4 (type INTEGER))\n)\n'\n crlf)\n\n(deftemplate T-2\n\t(slot S-3 (type STRING))\n\t(slot S-4 (type INTEGER))\n)\n\n\n(printout t '\nChecking if the templates defined exist by typing\n\n(templates)\n-->'\ncrlf)\n\n(templates)\n\n(printout t '\nand pretty print the definition of T-1 with\n\n(ppdeftemplate T-1)\n-->'\n crlf)\n \n(ppdeftemplate T-1)\n\n(printout t '\n\n\n---J-A-M-O-C-H-A---B-Y---E-X-A-M-P-L-E---\n* Defining two rules\n' crlf)\n\n(defrule R-1 \"rule one\"\n\t(T-1 (S-1 ?x)(S-2 42)) \n\t=>\n\t(printout t ?x crlf)\n)\n\n\n(defrule R-2 \"rule two\"\n\t(T-2 (S-3 ?y)(S-4 28))\n\t=>\n\t(printout t ?y crlf)\n)\n\n(defrule R-3 \"rule three\"\n\t(T-1 (S-1 ?x)(S-2 a)) (T-2 (S-3 ?y)(S-4 a))\n\t=>\n\t(printout t ?x crlf)\n)\n\n(assert (T-1 (S-1 a)(S-2 b)))\n(assert (T-2 (S-3 a)(S-4 b)))\n\n(assert (T-1 (S-1 b)(S-2 a)))\n(assert (T-2 (S-3 b)(S-4 a)))\n\n(fire)\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"cfe513b2be8857a924c44b6b117518c36c950148","subject":"Added the Path class to the path module","message":"Added the Path class to the path module\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/passes\/path\/Path.clp","new_file":"modules\/llvm\/passes\/path\/Path.clp","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2d57af8110c88a83131ea285496b19ffb06be2a8","subject":"Modified Init.clp to load the standard module set","message":"Modified Init.clp to load the standard module set\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/Init.clp","new_file":"lib\/durandal\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n \t \"modules\/rampancy\/ModuleHeader.clp\"\n\t\t\t \"modules\/indirect\/ModuleHeader.clp\"\n\t\t\t \"modules\/types\/ModuleHeader.clp\"\n\t\t\t \"modules\/pipeline\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n;(defmodule MAIN (import core ?ALL) (import llvm ?ALL))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/scheduler\/ModuleHeader.clp\"\n \"modules\/rampancy\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n;(defmodule MAIN (import core ?ALL) (import llvm ?ALL))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2496b0c9f2e7cc6c7f5892a6c053c1211f57d113","subject":"Fixed the CompensationPathVector class to work with the new module layout","message":"Fixed the CompensationPathVector class to work with the new module layout\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/CompensationPathVector.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/CompensationPathVector.clp","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"72a0e997f5ac330ca9445753858c4d1a3d3513a4","subject":"Fixed a bug where there was a duplicate defmodule in Loader.clp","message":"Fixed a bug where there was a duplicate defmodule in Loader.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5eca66a03f5df92641fd3f19f829f1a8dbceb917","subject":"Fixed bugs in WavefrontDependencyUpdate.clp","message":"Fixed bugs in WavefrontDependencyUpdate.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"86d20bba931228b43c0bf4e46bade087aa4119f0","subject":"Added the initial-fact to the error checking rule in paths-conditional","message":"Added the initial-fact to the error checking rule in paths-conditional\n\nThis made the rule actually fire and I found out that the pather is quite\nbroken. To this end, I am rewriting the path pass to fix this.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/conditional\/BlockUpdates.clp","new_file":"lib\/durandal\/passes\/path\/conditional\/BlockUpdates.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockUpdates.clp - Contains rules that add paths that a given block is a part\n; of\n; Written by Joshua Scoggins (6\/7\/2012)\n;------------------------------------------------------------------------------\n(defrule paths-conditional-update::FAIL-UNFINISHED-PATHS \n (message (to paths-conditional-update)\n (action initial-fact))\n\t\t\t(test (> (length$ \n\t\t\t\t\t\t (find-all-instances ((?path Path)) (not ?path:closed))) 0))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: Not all paths were closed!\" crlf)\n\t\t\t(progn$ (?inst (find-all-instances ((?path Path)) \n\t\t\t\t\t\t\t\t\t(not ?path:closed)))\n\t\t\t\t\t\t(send ?inst print))\n\t\t\t(printout t \"Current facts!\" crlf)\n\t\t\t(facts)\n\t\t\t(printout t \"Halting Execution!!!\" crlf)\n\t\t\t(halt))\n\n(defrule paths-conditional::AddPathToDiplomat\n\t\t\t\"Adds the given path name to the target diplomat\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Path) (closed TRUE) (id ?i) (values $? ?b $?))\n\t\t\t?d <- (object (is-a Diplomat) (id ?b))\n\t\t\t(test (not (member$ ?i (send ?d get-Paths))))\n\t\t\t=>\n\t\t\t(slot-insert$ ?d Paths 1 ?i))\n\n(defrule paths-conditional-update::TraversePathForElementInjection\n\t\t\t(object (is-a Path) (closed TRUE) (id ?p) (values $? ?a ?b $?))\n\t\t\t?o0 <- (object (is-a Diplomat) (id ?a))\n\t\t\t?o1 <- (object (is-a Diplomat) (id ?b))\n\t\t\t=>\n\t\t\t(if (not (member$ ?a (send ?o1 get-PreviousPathElements))) then\n\t\t\t (slot-insert$ ?o1 PreviousPathElements 1 ?a))\n\t\t\t(if (not (member$ ?b (send ?o0 get-NextPathElements))) then\n\t\t\t (slot-insert$ ?o0 NextPathElements 1 ?b)))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockUpdates.clp - Contains rules that add paths that a given block is a part\n; of\n; Written by Joshua Scoggins (6\/7\/2012)\n;------------------------------------------------------------------------------\n(defrule paths-conditional-update::FAIL-UNFINISHED-PATHS \n\t\t\t(test (> (length$ \n\t\t\t\t\t\t (find-all-instances ((?path Path)) (not ?path:closed))) 0))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: Not all paths were closed!\" crlf)\n\t\t\t(progn$ (?inst (find-all-instances ((?path Path)) \n\t\t\t\t\t\t\t\t\t(not ?path:closed)))\n\t\t\t\t\t\t(send ?inst print))\n\t\t\t(printout t \"Current facts!\" crlf)\n\t\t\t(facts)\n\t\t\t(printout t \"Halting Execution!!!\" crlf)\n\t\t\t(halt))\n\n(defrule paths-conditional::AddPathToDiplomat\n\t\t\t\"Adds the given path name to the target diplomat\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Path) (closed TRUE) (id ?i) (values $? ?b $?))\n\t\t\t?d <- (object (is-a Diplomat) (id ?b))\n\t\t\t(test (not (member$ ?i (send ?d get-Paths))))\n\t\t\t=>\n\t\t\t(slot-insert$ ?d Paths 1 ?i))\n\n(defrule paths-conditional-update::TraversePathForElementInjection\n\t\t\t(object (is-a Path) (closed TRUE) (id ?p) (values $? ?a ?b $?))\n\t\t\t?o0 <- (object (is-a Diplomat) (id ?a))\n\t\t\t?o1 <- (object (is-a Diplomat) (id ?b))\n\t\t\t=>\n\t\t\t(if (not (member$ ?a (send ?o1 get-PreviousPathElements))) then\n\t\t\t (slot-insert$ ?o1 PreviousPathElements 1 ?a))\n\t\t\t(if (not (member$ ?b (send ?o0 get-NextPathElements))) then\n\t\t\t (slot-insert$ ?o0 NextPathElements 1 ?b)))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4ace0e161f63af3fbcedc86af04a39ea82592f3a","subject":"this is the assignment for knowledge enineering2","message":"this is the assignment for knowledge enineering2\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"function1.clp","new_file":"function1.clp","new_contents":"","old_contents":"","returncode":0,"stderr":"unknown","license":"mit","lang":"CLIPS"} {"commit":"84e73ca8088b4ea6c7e97925691251474a691c5b","subject":"Added first$ and rest$ messages to List","message":"Added first$ and rest$ messages to List\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/List.clp","new_file":"modules\/core\/List.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; List.clp - represents a wrapper over a multifield\n;------------------------------------------------------------------------------\n(defclass core::List (is-a core::Object)\n (multislot contents (visibility public)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List count primary\n \"Returns the count of the given list.\" ()\n (length$ ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List add primary\n (?first $?rest)\n (slot-direct-insert$ contents (+ 2 (length$ ?self:contents)) ?first $?rest))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List add-to-front primary\n (?first $?rest)\n (slot-direct-insert$ contents 1 ?first $?rest))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List clear primary ()\n (bind ?self:contents (create$)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove primary\n (?element $?elements)\n (bind ?self:contents (delete-member$ ?self:contents ?element $?elements)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove-range primary \n (?start ?finish)\n (slot-direct-delete$ contents ?start ?finish))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove-at primary \n (?index)\n (slot-direct-delete$ contents ?index ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List element-at primary \n (?index)\n (nth$ ?index ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List contains primary \n (?item)\n (member$ ?item ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List contains-subset primary \n ($?subset)\n (subsetp ?subset ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List reverse primary\n \"Reverses the order of the values in contents\" ()\n (bind ?copy (create$))\n (progn$ (?element ?self:contents)\n (bind ?copy (create$ ?element ?copy)))\n (bind ?self:contents ?copy))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List implode$ primary\n \"Calls implode$ on the contents of this object\"\n (implode$ ?self:contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List exists primary \n \"Takes in the name of a function and applies the function to each element of\n the list until either the list is completed or a value is found. If TRUE is\n returned then it means that the query was successful and an element was found\n that satsified the given function. If FALSE is returned then none of the\n elements in this list satisfy the given function.\"\n (?fn)\n (progn$ (?element ?self:contents)\n (if (funcall ?fn ?element) then\n\t(return TRUE)))\n (return FALSE))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List apply primary\n \"Returns a new multifield with the results of the given function applied to\n each element of this list\"\n (?fn)\n (bind ?list (create$))\n (progn$ (?e ?self:contents)\n (bind ?list (create$ ?list (funcall ?fn ?e))))\n (return ?list))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List first$ primary\n \"Returns the first element of this list as a list.\" \n () \n (first$ ?self:contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List rest$ primary\n \"Returns a list missing the first element of the original list\"\n ()\n (rest$ ?self:contents))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; List.clp - represents a wrapper over a multifield\n;------------------------------------------------------------------------------\n(defclass core::List (is-a core::Object)\n (multislot contents (visibility public)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List count primary\n \"Returns the count of the given list.\" ()\n (length$ ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List add primary\n (?first $?rest)\n (slot-direct-insert$ contents (+ 2 (length$ ?self:contents)) ?first $?rest))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List add-to-front primary\n (?first $?rest)\n (slot-direct-insert$ contents 1 ?first $?rest))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List clear primary ()\n (bind ?self:contents (create$)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove primary\n (?element $?elements)\n (bind ?self:contents (delete-member$ ?self:contents ?element $?elements)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove-range primary \n (?start ?finish)\n (slot-direct-delete$ contents ?start ?finish))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List remove-at primary \n (?index)\n (slot-direct-delete$ contents ?index ?index))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List element-at primary \n (?index)\n (nth$ ?index ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List contains primary \n (?item)\n (member$ ?item ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List contains-subset primary \n ($?subset)\n (subsetp ?subset ?self:Contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List reverse primary\n \"Reverses the order of the values in contents\" ()\n (bind ?copy (create$))\n (progn$ (?element ?self:contents)\n (bind ?copy (create$ ?element ?copy)))\n (bind ?self:contents ?copy))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List implode$ primary\n \"Calls implode$ on the contents of this object\"\n (implode$ ?self:contents))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List exists primary \n \"Takes in the name of a function and applies the function to each element of\n the list until either the list is completed or a value is found. If TRUE is\n returned then it means that the query was successful and an element was found\n that satsified the given function. If FALSE is returned then none of the\n elements in this list satisfy the given function.\"\n (?fn)\n (progn$ (?element ?self:contents)\n (if (funcall ?fn ?element) then\n\t(return TRUE)))\n (return FALSE))\n;------------------------------------------------------------------------------\n(defmessage-handler core::List apply primary\n \"Returns a new multifield with the results of the given function applied to\n each element of this list\"\n (?fn)\n (bind ?list (create$))\n (progn$ (?e ?self:contents)\n (bind ?list (create$ ?list (funcall ?fn ?e))))\n (return ?list))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"433c933f94c1624e9c876bf4b8f38ae404ea0772","subject":"Cambio en clases","message":"Cambio en clases\n\nTenias mal el rango de las horas porque van desde las 8 a las 14 horas\n","repos":"RubenAgudo\/InteligenciaArtificial","old_file":"src\/CLIPS\/EjercicioFinal\/classes.clp","new_file":"src\/CLIPS\/EjercicioFinal\/classes.clp","new_contents":"(defclass ASIGNATURA\n (is-a USER)\n (role concrete)\n \n (slot curso\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (slot horasRestantes\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (slot profesor\n (type SYMBOL)\n (create-accessor read-write)\n )\n \n)\n\n(defclass DIA\n (is-a USER)\n (role concrete)\n \n (multislot clases\n (type INSTANCE)\n (allowed-classes CLASE)\n (create-accessor read-write)\n )\n)\n\n(defclass SEMANA\n (is-a USER)\n (role concrete)\n \n (slot deCurso\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (multislot dias\n (type INSTANCE)\n (allowed-classes DIA)\n (create-accessor read-write)\n )\n \n (slot diasUsados\n (type INTEGER)\n (range 1 5 DEFAULT 0)\n (create-accessor read-write)\n )\n)\n\n(defclass CLASE\n (is-a USER)\n (role concrete)\n \n (slot deAsignatura\n (type INSTANCE)\n (allowed-instances ASIGNATURA)\n )\n \n (slot diaSemana\n (type SYMBOL)\n (allowed-values LUNES MARTES MIERCOLES JUEVES VIERNES)\n (create-accessor read-write)\n )\n \n (slot horaInicio\n (type INTEGER)\n (range 8 14)\n )\n \n (slot horaFin\n (type INTEGER)\n (range 8 14)\n )\n)","old_contents":"(defclass ASIGNATURA\n (is-a USER)\n (role concrete)\n \n (slot curso\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (slot horasRestantes\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (slot profesor\n (type SYMBOL)\n (create-accessor read-write)\n )\n \n)\n\n(defclass DIA\n (is-a USER)\n (role concrete)\n \n (multislot clases\n (type INSTANCE)\n (allowed-classes CLASE)\n (create-accessor read-write)\n )\n)\n\n(defclass SEMANA\n (is-a USER)\n (role concrete)\n \n (slot deCurso\n (type INTEGER)\n (range 1 4)\n (create-accessor read-write)\n )\n \n (multislot dias\n (type INSTANCE)\n (allowed-classes DIA)\n (create-accessor read-write)\n )\n \n (slot diasUsados\n (type INTEGER)\n (range 1 5 DEFAULT 0)\n (create-accessor read-write)\n )\n)\n\n(defclass CLASE\n (is-a USER)\n (role concrete)\n \n (slot deAsignatura\n (type INSTANCE)\n (allowed-instances ASIGNATURA)\n )\n \n (slot diaSemana\n (type SYMBOL)\n (allowed-values LUNES MARTES MIERCOLES JUEVES VIERNES)\n (create-accessor read-write)\n )\n \n (slot horaInicio\n (type INTEGER)\n (range 8 12)\n )\n \n (slot horaFin\n (type INTEGER)\n (range 8 12)\n )\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"7caa5c410421a1e5fc50fb2ad8b8bd48fe92bbb5","subject":"Create task3.clp","message":"Create task3.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task3.clp","new_file":"ssu-ai-level-2\/chapter7\/task3.clp","new_contents":"(deffunction str-del (?substr ?str)\n (bind ?n1 (str-length ?substr))\n (bind ?n2 (str-length ?str))\n (bind ?k (str-index ?substr ?str))\n (while (> ?k 0) do\n (bind ?st1 (sub-string 1 (- ?k 1) ?str))\n (bind ?st2 (sub-string (+ ?k ?n1) ?n2 ?str))\n (bind ?str (str-cat ?st1 ?st2))\n (bind ?k (str-index ?substr ?str))\n (if (not ?k) then \n (bind ?k 0)\n )\n )\n ?str)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task3.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"2d1110eaab3a0a68619426eb2c10086648172285","subject":"Create task6.clp","message":"Create task6.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task6.clp","new_file":"ssu-ai-level-2\/chapter6\/task6.clp","new_contents":"(deffunction summ-iter (?n)\n (if (= ?n 1) then (return 1))\n (+ (\/ 1 ?n) (summ-iter (- ?n 1)))\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task6.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"5c30e637c13adf2c87276ed7815ed9195c7352ae","subject":"- checked in the missing init.clp","message":"- checked in the missing init.clp\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1196 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"src\/main\/org\/jamocha\/apps\/jamochaagent\/init.clp","new_file":"src\/main\/org\/jamocha\/apps\/jamochaagent\/init.clp","new_contents":"; ===================================================\n; Initial data that is essential to run the JamochaAgent.\n; ===================================================\n\n\n; ===================================================\n; Definition of the templates that are needed.\n; ===================================================\n\n(deftemplate agent-description\n\t\"A template defining an agent.\"\n (slot name (type STRING))\n (slot local (type BOOLEAN))\n)\n\n(deftemplate agent-ontology\n\t\"Definition of ontologies. (not needed at the moment)\"\n (slot name (type STRING))\n (slot definition (type STRING))\n)\n\n(deftemplate agent-message\n\t\"Definition of an (incoming) agent-message.\"\n\t(slot sender (type STRING))\n\t(multislot receivers)\n\t(multislot reply-to)\n\t(slot performative (type STRING))\n\t(slot content (type STRING))\n\t(slot language (type STRING))\n\t(slot encoding (type STRING))\n\t(slot ontology (type STRING))\n\t(slot protocol (type STRING))\n\t(slot conversation-id (type STRING))\n\t(slot in-reply-to (type STRING))\n\t(slot reply-with (type STRING))\n\t(slot reply-by (type LONG))\n\t(multislot user-properties)\n\t(silent slot content-clips (type STRING))\n\t(slot processed (type BOOLEAN)(default FALSE))\n)\n\n(deftemplate agent-message-initiator\n\t\"Deftemplate for a message initiator.\"\n\t(slot receiver)\n\t(slot refering-message)\n\t(slot protocol (type STRING))\n\t(slot previous-performative (type STRING))\n\t(slot content (type STRING))\n\t(slot content-clips (type STRING))\n\t(slot processed (type BOOLEAN)(default FALSE))\n\t(slot error (type STRING)(default NIL))\n)\n\n; ===================================================\n; definition of functions that are needed\n; ===================================================\n\n(deffunction process-incoming-message\n\t\"Processes incoming messages with any protocol and performative.\"\n\t(functiongroup AgentFunctions)\n\t(?message ?protocol)\n\t\n\t; Assert the agent that sent the message if he is unknown.\n\t(bind ?agent (fact-id \n\t\t(assert (agent-description (name (fact-slot-value ?message \"sender\"))(local FALSE)))\n\t))\n\t\n\t; Translate the Code according to the given performative.\n\t(bind ?clipsCode\n\t (sl2clips\n\t \t(fact-slot-value ?message \"performative\")\n\t \t(fact-slot-value ?message \"content\")\n\t )\n\t)\n\t\n\t; Add the translated code to the initial message.\n\t(modify ?message (content-clips ?clipsCode))\n\t\n\t; Set the message to processed.\n\t(modify ?message (processed TRUE))\n\t\n\t; Evaluate the code in the rete engine.\n\t(bind ?error \"\")\n\t(bind ?result (eval ?clipsCode ?error))\n\t\n\t; Assert a new agent message initiator that will initiate a new message according\n\t; to the used performative and protocol.\n\t(assert (agent-message-initiator\n\t\t(receiver ?agent)\n\t\t(refering-message ?message)\n\t\t(protocol ?protocol)\n\t\t(previous-performative (fact-slot-value ?message \"performative\"))\n\t\t(content (clips2sl ?result))\n\t\t(content-clips ?result)\n\t\t(error ?error)\n\t))\n)\n\n; ===================================================\n; Definition of rules that are needed\n; ===================================================\n\n(defrule incoming-message\n\t\"Fires when a message in FIPA-SL arrives, that is addressed to a local Agent.\"\n\t; Only look for messages addressed to a local agent. There might be more than one\n\t; agent running locally using this rete engine.\n\t(agent-description\n\t\t(name ?receiver)\n\t\t(local TRUE)\n\t)\n\t; Only extract messages that have not been answered yet.\n\t?message <- (agent-message\n\t\t(receivers ?receivers)\n\t\t(language \"fipa-sl\")\n\t\t(protocol ?protocol)\n\t\t(processed FALSE)\n\t)\n\t; The receiver of the message must be local.\n\t(test (> (member$ ?receiver ?receivers) 0))\n\t\n\t=>\n\t\n\t; Process the message.\n\t(process-incoming-message ?message ?protocol)\n\t\n\t(fire)\n)","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/main\/org\/jamocha\/apps\/jamochaagent\/init.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"29ab6c1ac46aae4b86e0241f504cca04599fc05b","subject":"snapshot","message":"snapshot\n","repos":"Ramarren\/lisa","old_file":"misc\/sample.clp","new_file":"misc\/sample.clp","new_contents":"(deftemplate rocky\n (slot name))\n\n(deftemplate boris\n (slot name))\n\n(deftemplate natasha\n (slot name)\n (slot nemesis))\n\n(load-package jess.ViewFunctions)\n(set-node-index-hash 1)\n\n; (defrule rocky-boris-natasha\n; ?f-1 <- (rocky (name ?n&:(= (str-compare \"bullwinkle\" ?n) 0)))\n; (boris (name ?boris-name&:(= (str-compare ?boris-name \"boris\") 0)))\n; (natasha (name ?name&:(= (str-compare ?name \"natasha\") 0))\n; (nemesis ?z&:(= (str-compare ?z ?boris-name) 0)))\n; =>\n; (printout t \"rocky-boris-natasha fired (?boris-name = \" ?boris-name \")\" crlf)\n; (retract ?f-1))\n\n; (defrule not-rocky\n; (not (rocky (name \"rocky\")))\n; =>\n; (printout t \"not-rocky fired.\" crlf))\n\n; (defrule duplicate-vars\n; (natasha (name ?name) (nemesis ?name))\n; =>\n; (printout t \"duplicate-vars fired!\" crlf))\n\n; (defrule schtum\n; ?rocky <- (rocky (name \"rocky\"))\n; (boris (name \"boris\"))\n; ?natasha <- (natasha (name \"natasha\"))\n; =>\n; (retract ?rocky)\n; (retract ?natasha)\n; (printout t \"schtum!\" crlf))\n\n; (defrule schtum-shared\n; (boris (name \"boris\"))\n; =>\n; (printout t \"schtum-shared!\" crlf))\n\n; (defrule schtum-simple\n; (rocky (name ?name&:(stringp ?name)))\n; (boris (name ?name&:(stringp ?name)))\n; (natasha (name \"natasha\"))\n; =>\n; (printout t \"schtum-simple!\" crlf))\n\n; (defrule no-patterns\n; =>\n; (printout t \"no-patterns!\" crlf))\n\n;(reset)\n;(assert (rocky (name \"boris\")))\n;(assert (boris (name \"boris\")))\n;(assert (natasha (name \"natasha\")))\n\n(defrule rocky-1\n (rocky (name ?name&:(eq ?name \"rocky\")))\n (boris (name ?boris&:(eq ?boris ?name)))\n =>\n (format t \"rocky-1 fired: ?name = ~S~%\" ?name))\n\n(defrule rocky-2\n (rocky (name ?name&:(eq ?name \"rocky\")))\n (natasha)\n (boris (name ?schtum&:(eq ?schtum ?name)))\n =>\n (format t \"rocky-2 fired: ?name = ~S~%\" ?name))\n","old_contents":"(deftemplate rocky\n (slot name))\n\n(deftemplate boris\n (slot name))\n\n(deftemplate natasha\n (slot name)\n (slot nemesis))\n\n(load-package jess.ViewFunctions)\n(set-node-index-hash 1)\n\n(defrule rocky-1\n (rocky (name ?name&:(eq ?name \"rocky\")))\n (boris (name ?boris&:(eq ?boris ?name)))\n =>\n (format t \"rocky-1 fired: ?name = ~S~%\" ?name))\n\n(defrule rocky-2\n (rocky (name ?name&:(eq ?name \"rocky\")))\n (natasha)\n (boris (name ?schtum&:(eq ?schtum ?name)))\n =>\n (format t \"rocky-2 fired: ?name = ~S~%\" ?name))\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"bacc9ffb2aaf82553aa891e757fb3b64af4ebc42","subject":"New file","message":"New file\n","repos":"Ramarren\/lisa","old_file":"misc\/mab-slow.clp","new_file":"misc\/mab-slow.clp","new_contents":";;;======================================================\n;;; Monkees and Bananas Sample Problem\n;;;\n;;; This is an extended version of a\n;;; rather common AI planning problem.\n;;; The point is for the monkee to find\n;;; and eat some bananas.\n;;;\n;;; CLIPS Version 6.0 Example\n;;;\n;;; To execute, merely load, reset and run.\n;;;======================================================\n;;;\n;;; modified EJFH 4\/11\/96 for JES Java Expert System\n;;; produces identical output under CLIPS\n\n;;;*************\n;;;* TEMPLATES *\n;;;*************\n\n(deftemplate monkey \n (slot location \n (default green-couch))\n (slot on-top-of \n (default floor)) \n (slot holding \n (default nothing)))\n\n(deftemplate thing \n (slot name)\n (slot location)\n (slot on-top-of \n (default floor))\n (slot weight \n (default light)))\n \n(deftemplate chest \n (slot name)\n (slot contents)\n (slot unlocked-by))\n \n(deftemplate goal-is-to \n (slot action)\n (slot argument-1)\n (slot argument-2))\n \n;;;*************************\n;;;* CHEST UNLOCKING RULES *\n;;;*************************\n\n(defrule hold-chest-to-put-on-floor \"\" \n (goal-is-to (action unlock) (argument-1 ?chest))\n (thing (name ?a&:(eq ?a ?chest)) (on-top-of ~floor) (weight light))\n (monkey (holding ?b&:(neq ?b ?chest)))\n (not (goal-is-to (action hold) (argument-1 ?c&:(eq ?c ?chest))))\n =>\n (assert (goal-is-to (action hold) (argument-1 ?chest))))\n\n(defrule put-chest-on-floor \"\" \n (goal-is-to (action unlock) (argument-1 ?chest))\n ?monkey <- (monkey (location ?place)\n (on-top-of ?on)\n (holding ?c&:(eq ?c ?chest)))\n ?thing <- (thing (name ?d&:(eq ?d ?chest)))\n =>\n (printout t \"Monkey throws the \" ?chest \" off the \" \n ?on \" onto the floor.\" crlf)\n (modify ?monkey (holding blank))\n (modify ?thing (location ?place) (on-top-of floor)))\n\n(defrule get-key-to-unlock \"\" \n (goal-is-to (action unlock) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (on-top-of floor))\n (chest (name ?b&:(eq ?b ?obj)) (unlocked-by ?key))\n (monkey (holding ?c&:(neq ?c ?key)))\n (not (goal-is-to (action hold) (argument-1 ?d&:(eq ?d ?key))))\n =>\n (assert (goal-is-to (action hold) (argument-1 ?key))))\n\n;; one conjunction removed here just by reordering patterns.\n\n(defrule move-to-chest-with-key \"\" \n (goal-is-to (action unlock) (argument-1 ?chest))\n (thing (name ?a&:(eq ?a ?chest)) (location ?cplace) (on-top-of floor))\n (monkey (location ?b&:(neq ?b ?cplace)) (holding ?key))\n (chest (name ?c&:(eq ?c ?chest)) (unlocked-by ?d&:(eq ?d ?key)))\n (not (goal-is-to (action walk-to) (argument-1 ?e&:(eq ?e ?cplace))))\n =>\n (assert (goal-is-to (action walk-to) (argument-1 ?cplace))))\n\n(defrule unlock-chest-with-key \"\" \n ?goal <- (goal-is-to (action unlock) (argument-1 ?name))\n ?chest <- (chest (name ?a&:(eq ?a ?name)) (contents ?contents)\n (unlocked-by ?key))\n (thing (name ?b&:(eq ?b ?name)) (location ?place) (on-top-of ?on))\n (monkey (location ?c&:(eq ?c ?place)) (on-top-of ?d&:(eq ?d ?on))\n (holding ?e&:(eq ?e ?key)))\n =>\n (printout t \"Monkey opens the \" ?name \" with the \" ?key \n \" revealing the \" ?contents \".\" crlf)\n (modify ?chest (contents nothing))\n (assert (thing (name ?contents) (location ?place) (on-top-of ?name)))\n (retract ?goal))\n\n;;;*********************\n;;;* HOLD OBJECT RULES * \n;;;*********************\n\n(defrule unlock-chest-to-hold-object \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (chest (name ?chest) (contents ?a&:(eq ?a ?obj)))\n (not (goal-is-to (action unlock) (argument-1 ?b&:(eq ?b ?chest))))\n =>\n (assert (goal-is-to (action unlock) (argument-1 ?chest))))\n\n(defrule use-ladder-to-hold \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place) (on-top-of ceiling)\n (weight light)) \n (not (thing (name ladder) (location ?b&:(eq ?b ?place))))\n (not (goal-is-to (action move) (argument-1 ladder)\n (argument-2 ?c&:(eq ?c ?place))))\n =>\n (assert (goal-is-to (action move) (argument-1 ladder) (argument-2 ?place))))\n\n(defrule climb-ladder-to-hold \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place)\n (on-top-of ceiling) (weight light))\n (thing (name ladder) (location ?b&:(eq ?b ?place)) (on-top-of floor))\n (monkey (on-top-of ~ladder))\n (not (goal-is-to (action on) (argument-1 ladder)))\n =>\n (assert (goal-is-to (action on) (argument-1 ladder))))\n\n(defrule grab-object-from-ladder \"\" \n ?goal <- (goal-is-to (action hold) (argument-1 ?name))\n ?thing <- (thing (name ?a&:(eq ?a ?name)) (location ?place) \n (on-top-of ceiling) (weight light))\n (thing (name ladder) (location ?b&:(eq ?b ?place)))\n ?monkey <- (monkey (location ?c&:(eq ?c ?place)) (on-top-of ladder)\n (holding blank))\n =>\n (printout t \"Monkey grabs the \" ?name \".\" crlf)\n (modify ?thing (location held) (on-top-of held))\n (modify ?monkey (holding ?name))\n (retract ?goal))\n\n(defrule climb-to-hold \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place&~ceiling)\n (on-top-of ?on) (weight light))\n (monkey (location ?b&:(eq ?b ?place)) (on-top-of ?c&:(neq ?c ?on)))\n (not (goal-is-to (action on) (argument-1 ?d&:(eq ?d ?on))))\n =>\n (assert (goal-is-to (action on) (argument-1 ?on))))\n\n(defrule walk-to-hold \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place)\n (on-top-of ~ceiling) (weight light))\n (monkey (location ?b&:(neq ?b ?place)))\n (not (goal-is-to (action walk-to) (argument-1 ?c&:(eq ?c ?place))))\n =>\n (assert (goal-is-to (action walk-to) (argument-1 ?place))))\n\n(defrule drop-to-hold \"\"\n (goal-is-to (action hold) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place) (on-top-of ?on)\n (weight light))\n (monkey (location ?b&:(eq ?b ?place)) (on-top-of ?c&:(eq ?c ?on))\n (holding ~blank))\n (not (goal-is-to (action hold) (argument-1 blank)))\n =>\n (assert (goal-is-to (action hold) (argument-1 blank))))\n\n(defrule grab-object \"\" \n ?goal <- (goal-is-to (action hold) (argument-1 ?name))\n ?thing <- (thing (name ?a&:(eq ?a ?name)) (location ?place) \n (on-top-of ?on) (weight light))\n ?monkey <- (monkey (location ?b&:(eq ?b ?place))\n (on-top-of ?c&:(eq ?c ?on)) (holding blank))\n =>\n (printout t \"Monkey grabs the \" ?name \".\" crlf)\n (modify ?thing (location held) (on-top-of held))\n (modify ?monkey (holding ?name))\n (retract ?goal))\n\n(defrule drop-object \"\" \n ?goal <- (goal-is-to (action hold) (argument-1 blank))\n ?monkey <- (monkey (location ?place) \n (on-top-of ?on) \n (holding ?name&~blank))\n ?thing <- (thing (name ?a&:(eq ?a ?name)))\n =>\n (printout t \"Monkey drops the \" ?name \".\" crlf)\n (modify ?monkey (holding blank))\n (modify ?thing (location ?place) (on-top-of ?on))\n (retract ?goal))\n\n;;;*********************\n;;;* MOVE OBJECT RULES * \n;;;*********************\n\n(defrule unlock-chest-to-move-object \"\" \n (goal-is-to (action move) (argument-1 ?obj))\n (chest (name ?chest) (contents ?a&:(eq ?a ?obj)))\n (not (goal-is-to (action unlock) (argument-1 ?b&:(eq ?b ?chest))))\n =>\n (assert (goal-is-to (action unlock) (argument-1 ?chest))))\n\n(defrule hold-object-to-move \"\" \n (goal-is-to (action move) (argument-1 ?obj) (argument-2 ?place))\n (thing (name ?a&:(eq ?a ?obj)) (location ?b&:(neq ?b ?place))\n (weight light))\n (monkey (holding ?c&:(neq ?c ?obj)))\n (not (goal-is-to (action hold) (argument-1 ?d&:(eq ?d ?obj))))\n =>\n (assert (goal-is-to (action hold) (argument-1 ?obj))))\n\n(defrule move-object-to-place \"\" \n (goal-is-to (action move) (argument-1 ?obj) (argument-2 ?place))\n (monkey (location ?a&:(neq ?a ?place)) (holding ?b&:(eq ?b ?obj)))\n (not (goal-is-to (action walk-to) (argument-1 ?c&:(eq ?c ?place))))\n =>\n (assert (goal-is-to (action walk-to) (argument-1 ?place))))\n\n(defrule drop-object-once-moved \"\" \n ?goal <- (goal-is-to (action move) (argument-1 ?name) (argument-2 ?place))\n ?monkey <- (monkey (location ?a&:(eq ?a ?place)) (holding ?obj))\n ?thing <- (thing (name ?b&:(eq ?b ?name)) (weight light))\n =>\n (printout t \"Monkey drops the \" ?name \".\" crlf)\n (modify ?monkey (holding blank))\n (modify ?thing (location ?place) (on-top-of floor))\n (retract ?goal))\n\n(defrule already-moved-object \"\"\n ?goal <- (goal-is-to (action move) (argument-1 ?obj) (argument-2 ?place))\n (thing (name ?a&:(eq ?a ?obj)) (location ?b&:(eq ?b ?place)))\n =>\n (retract ?goal))\n\n;;;***********************\n;;;* WALK TO PLACE RULES *\n;;;***********************\n\n(defrule already-at-place \"\" \n ?goal <- (goal-is-to (action walk-to) (argument-1 ?place))\n (monkey (location ?a&:(eq ?a ?place)))\n =>\n (retract ?goal))\n\n(defrule get-on-floor-to-walk \"\"\n (goal-is-to (action walk-to) (argument-1 ?place))\n (monkey (location ?a&:(neq ?a ?place)) (on-top-of ~floor))\n (not (goal-is-to (action on) (argument-1 floor)))\n =>\n (assert (goal-is-to (action on) (argument-1 floor))))\n\n(defrule walk-holding-nothing \"\"\n ?goal <- (goal-is-to (action walk-to) (argument-1 ?place))\n ?monkey <- (monkey (location ?a&:(neq ?a ?place)) (on-top-of floor)\n (holding blank)) \n =>\n (printout t \"Monkey walks to \" ?place \".\" crlf)\n (modify ?monkey (location ?place))\n (retract ?goal))\n\n(defrule walk-holding-object \"\"\n ?goal <- (goal-is-to (action walk-to) (argument-1 ?place))\n ?monkey <- (monkey (location ?a&:(neq ?a ?place)) (on-top-of floor)\n (holding ?obj))\n (thing (name ?b&:(eq ?b ?obj)))\n =>\n (printout t \"Monkey walks to \" ?place \" holding the \" ?obj \".\" crlf)\n (modify ?monkey (location ?place))\n (retract ?goal))\n\n;;;***********************\n;;;* GET ON OBJECT RULES * \n;;;***********************\n\n(defrule jump-onto-floor \"\" \n ?goal <- (goal-is-to (action on) (argument-1 floor))\n ?monkey <- (monkey (on-top-of ?on&~floor))\n =>\n (printout t \"Monkey jumps off the \" ?on \" onto the floor.\" crlf)\n (modify ?monkey (on-top-of floor))\n (retract ?goal))\n\n(defrule walk-to-place-to-climb \"\" \n (goal-is-to (action on) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place))\n (monkey (location ?b&:(neq ?b ?place)))\n (not (goal-is-to (action walk-to) (argument-1 ?c&:(eq ?c ?place))))\n =>\n (assert (goal-is-to (action walk-to) (argument-1 ?place))))\n\n(defrule drop-to-climb \"\" \n (goal-is-to (action on) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place))\n (monkey (location ?b&:(eq ?b ?place)) (holding ~blank))\n (not (goal-is-to (action hold) (argument-1 blank)))\n =>\n (assert (goal-is-to (action hold) (argument-1 blank))))\n\n(defrule climb-indirectly \"\" \n (goal-is-to (action on) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place) (on-top-of ?on))\n (monkey (location ?b&:(eq ?b ?place)) (on-top-of ~?on&~obj)\n (holding blank))\n (not (goal-is-to (action on) (argument-1 ?c&:(eq ?c ?on))))\n =>\n (assert (goal-is-to (action on) (argument-1 ?on))))\n\n(defrule climb-directly \"\" \n ?goal <- (goal-is-to (action on) (argument-1 ?obj))\n (thing (name ?a&:(eq ?a ?obj)) (location ?place) (on-top-of ?on))\n ?monkey <- (monkey (location ?b&:(eq ?b ?place))\n (on-top-of ?c&:(eq ?c ?on)) (holding blank))\n =>\n (printout t \"Monkey climbs onto the \" ?obj \".\" crlf)\n (modify ?monkey (on-top-of ?obj))\n (retract ?goal))\n\n(defrule already-on-object \"\"\n ?goal <- (goal-is-to (action on) (argument-1 ?obj))\n (monkey (on-top-of ?a&:(eq ?a ?obj)))\n =>\n (retract ?goal))\n\n;;;********************\n;;;* EAT OBJECT RULES * \n;;;********************\n(defrule hold-to-eat \"\"\n (goal-is-to (action eat) (argument-1 ?obj))\n (monkey (holding ?a&:(neq ?a ?obj)))\n (not (goal-is-to (action hold) (argument-1 ?b&:(eq ?b ?obj))))\n =>\n (assert (goal-is-to (action hold) (argument-1 ?obj))))\n\n(defrule satisfy-hunger \"\"\n ?goal <- (goal-is-to (action eat) (argument-1 ?name))\n ?monkey <- (monkey (holding ?a&:(eq ?a ?name)))\n ?thing <- (thing (name ?b&:(eq ?b ?name)))\n =>\n (printout t \"Monkey eats the \" ?name \".\" crlf)\n (modify ?monkey (holding blank))\n (retract ?goal ?thing))\n \n;;;**********************\n;;;* INITIAL STATE RULE * \n;;;**********************\n\n(defrule startup \"\"\n =>\n (assert (monkey (location t5-7) (on-top-of green-couch) (holding blank)))\n (assert (thing (name green-couch) (location t5-7) (weight heavy)))\n (assert (thing (name red-couch) (location t2-2) (weight heavy)))\n (assert (thing (name big-pillow) (location t2-2) (on-top-of red-couch)))\n (assert (thing (name red-chest) (location t2-2) (on-top-of big-pillow)))\n (assert (chest (name red-chest) (contents ladder) (unlocked-by red-key)))\n (assert (thing (name blue-chest) (location t7-7) (on-top-of ceiling)))\n (assert (thing (name grapes) (location t7-8) (on-top-of ceiling)))\n (assert (chest (name blue-chest) (contents bananas) (unlocked-by blue-key)))\n (assert (thing (name blue-couch) (location t8-8) (weight heavy)))\n (assert (thing (name green-chest) (location t8-8) (on-top-of ceiling)))\n (assert (chest (name green-chest) (contents blue-key) (unlocked-by red-key)))\n (assert (thing (name red-key) (location t1-3)))\n (assert (goal-is-to (action eat) (argument-1 bananas)))\n )\n\n(defglobal ?*time* = (time))\n(set-reset-globals FALSE)\n\n(deffunction run-mab (?n)\n (bind ?start (time))\n (while (> ?n 0) do\n (reset)\n (run)\n (bind ?n (- ?n 1)))\n (printout t \"Elapsed time: \"\n (- (time) ?start) crlf))\n\n;;(run-n-times 256)\n;;(run-n-times 1)\n;;(printout t \"Elapsed time: \" (integer (- (time) ?*time*)) crlf)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'misc\/mab-slow.clp' did not match any file(s) known to git\n","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"eb3da7e88528f0bb5cefac829ff6bbc9c31563b4","subject":"Fixed an issue with the macro-expand rule in wavefront-scheduling","message":"Fixed an issue with the macro-expand rule in wavefront-scheduling\n\nThe to field was marked for wavefront (the old name of the pass) instead of\nwavefront-scheduling. This was preventing the pass from firing correctly\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront-scheduling)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6a2a0003e8e45977ea6ad1f66ec3f6e66035b0b3","subject":"Fixed more bugs in GLConstantConversion.clp","message":"Fixed more bugs in GLConstantConversion.clp\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9dfee53d5d9420597388439f6b2b821c4dee50d7","subject":"Fixed up fixed size array support","message":"Fixed up fixed size array support\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%d]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t?self:array-size)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(retract ?msg)\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-fixed-size-array-argument\n\t\t\t(declare (salience 2))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \"[\" ?size \"]\" ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))\n\t\t\t\t\t\t\t\t(array-size ?size)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments-generic\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (format t \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t (if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t ?self:argument-type\n\t\t\t\t\t\t\t\t\t (if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t ?self:argument-name))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(retract ?msg)\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(send ?obj reconstitute)\n\t\t\t(printout t crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6d995fb752d42ccb4c4876ed450f1a7df58a13b3","subject":"Sorting exercices by puntuation","message":"Sorting exercices by puntuation\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n; Tue May 10 12:51:58 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -5 5)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -5 5)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Tue May 10 12:51:58 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -1)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 2)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 1)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 2)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 3)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 3)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 4)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\t\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (send ?dieta get-abuso+de+sal))\n (bind ?picar (send ?dieta get-picar+entre+horas))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar) 100) ?fruta ?fitness)) ;(sal+picar)*100+fruta+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 1)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 1)))\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","old_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n; Tue May 10 12:51:58 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -5 5)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -5 5)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Tue May 10 12:51:58 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -1)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 2)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 1)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 2)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 3)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 3)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 1)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 4)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\t\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (send ?dieta get-abuso+de+sal))\n (bind ?picar (send ?dieta get-picar+entre+horas))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t\n\t(bind ?fitness (+(*(+ ?sal ?picar) 100) ?fruta ?fitness))\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"cf0ec2d2dca53354613bfbe6f500712d47a7a10b","subject":"Finished the first version of the GLConstantConversion expert system","message":"Finished the first version of the GLConstantConversion expert system\n\nThis expert system now correctly does constant-conversion\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n; Alright, we now need to build a corresponding procedure from each heading\n; There are several ways to do this. The easiest would be to just do it\n; procedurally in a single rule fire. \n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\")) {\" \n (if ?if then \"if\" else \"else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)\n \"}\"))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-constant-conversion-procedure\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (> (length$ $?entries) 0))\n =>\n (unmake-instance ?obj)\n (bind ?target (format nil \"\/\/%s\" ?group))\n (bind ?header \"extern GLenum To????(char* input) {\")\n (bind ?first (to-conditional-field (nth$ 1 (first$ ?entries)) TRUE))\n (bind ?result (create$ ?target ?header ?first))\n (progn$ (?e (rest$ ?entries))\n (bind ?result \n (create$ ?result (to-conditional-field ?e FALSE))))\n (bind ?result (create$ ?result \"else {\" \"return 0;\" \"}\" \"}\"))\n (progn$ (?r ?result) (printout t ?r crlf))\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule grouping-update::skip-constant-conversion\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (= (length$ $?entries) 0))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (object (is-a heading-span)\n (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"450742b955fb4d6b5cedd09374c092c113576d55","subject":"Added a doc string to TaggedObject.clp","message":"Added a doc string to TaggedObject.clp\n\nIt should be a little clearer what the function does.\n","repos":"DrItanium\/LibExpertSystem,DrItanium\/LibExpertSystem","old_file":"clips\/Types\/TaggedObject.clp","new_file":"clips\/Types\/TaggedObject.clp","new_contents":"(defclass TaggedObject (is-a USER)\n \"Supertype of all objects used in wavefront scheduling and the Knowlege\n Construction Engine. It uses the ID field instead of the name field to get\n around a matching issue. Plus I didn't know the name field existed until I was\n nearly done implementing wavefront scheduling.... The Parent field is used to\n describe the parent of the given object. It is a nifty way of being able to\n jump around the contents of a function within the confines of an expert\n system.\"\n (slot Class (visibility public) (type SYMBOL))\n (slot ID (visibility public) (type SYMBOL))\n (slot Parent (visibility public) (default-dynamic nil)))\n\n(defmessage-handler TaggedObject init after ()\n (bind ?self:ID (instance-name-to-symbol (instance-name ?self)))\n (bind ?self:Class (class ?self)))\n\n","old_contents":"(defclass TaggedObject (is-a USER)\n (slot Class (visibility public) (type SYMBOL))\n (slot ID (visibility public) (type SYMBOL))\n (slot Parent (visibility public) (default-dynamic nil)))\n\n(defmessage-handler TaggedObject init after ()\n (bind ?self:ID (instance-name-to-symbol (instance-name ?self)))\n (bind ?self:Class (class ?self)))\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c0b13f8318171aa6a820e77ec8fd9eb0f0441a3f","subject":"Added a check to make sure that redefinition does not occur of the Path class","message":"Added a check to make sure that redefinition does not occur of the Path class\n\nThis is done because there are two passes that load the given class. Thus it is\neasy to check to make sure that the class does not already exist in the source\nfile that contains the code.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/common\/Path.clp","new_file":"lib\/durandal\/passes\/path\/common\/Path.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n; since multiple passes use this type it's necessary to prevent redefinition of\n; this type\n;------------------------------------------------------------------------------\n(if (not (class-existsp types::Path)) then\n (defclass types::Path \n\t (is-a ParentedHint)\n\t (slot exit (type SYMBOL))\n\t (slot closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n (defmessage-handler types::Path init after\n\t\t\t\t\t\t\t ()\n\t\t\t\t\t\t\t (bind ?self:type Path))\n;------------------------------------------------------------------------------\n )\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n(defclass types::Path \n (is-a ParentedHint)\n (slot exit (type SYMBOL))\n (slot closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Path init after\n ()\n (bind ?self:type Path))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5fcc068d48e9ba682794db24094effef72321456","subject":"Fixed name bugs in WavefrontDeterminantLogic.clp","message":"Fixed name bugs in WavefrontDeterminantLogic.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::InstanceFrequencyCounter\n\t\t\t\"Creates a frequency counter hint for basic blocks\"\n\t\t\t(declare (salience 2))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region))\n\t\t\t(not (exists (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t\t\t(parent ?p))))\n\t\t\t=>\n\t\t\t(make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::IncrementFrequencyCounter-BasicBlock\n\t\t\t\"Goes through a given Region counting the number of basic blocks found\n\t\t\twithin the region. Valid blocks are blocks that contain more than one \n\t\t\tinstruction as we don't want to count JS nodes as they don't usually \n\t\t\tcontain code.\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region) \n\t\t\t\t\t (contents $? ?t $?))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?t) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (contents $?insts&:(> (length$ $?insts) 1)))\n\t\t\t?wa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p))\n\t\t\t=>\n\t\t\t(send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::ImplyEnoughBlocks\n\t\t\t\"There are enough blocks within the target region to make it a \n\t\t\tcandidate for wavefront scheduling. Make a hint that says this.\"\n\t\t\t?fa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t(frequency ?z&:(and (< ?z 100) (> ?z 1))))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?p)\n\t\t\t\t\t\t\t\t\t (class Region))\n\t\t\t=>\n\t\t\t(unmake-instance ?fa)\n\t\t\t(assert (message (to wavefront-scheduling)\n\t\t\t\t\t\t\t\t (action can-wavefront-schedule)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t\t\t (message (to path-conditional)\n\t\t\t\t\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::InstanceFrequencyCounter\n\t\t\t\"Creates a frequency counter hint for basic blocks\"\n\t\t\t(declare (salience 2))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region))\n\t\t\t(not (exists (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t\t\t(parent ?p))))\n\t\t\t=>\n\t\t\t(make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::IncrementFrequencyCounter-BasicBlock\n\t\t\t\"Goes through a given Region counting the number of basic blocks found\n\t\t\twithin the region. Valid blocks are blocks that contain more than one \n\t\t\tinstruction as we don't want to count JS nodes as they don't usually \n\t\t\tcontain code.\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region) \n\t\t\t\t\t (contents $? ?t $?))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?t) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (contents $?insts&:(> (length$ $?insts) 1)))\n\t\t\t?wa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p))\n\t\t\t=>\n\t\t\t(send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::ImplyEnoughBlocks\n\t\t\t\"There are enough blocks within the target region to make it a \n\t\t\tcandidate for wavefront scheduling. Make a hint that says this.\"\n\t\t\t?fa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t(frequency ?z&:(and (< ?z 100) (> ?z 1))))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?p)\n\t\t\t\t\t\t\t\t\t (class Region))\n\t\t\t=>\n\t\t\t(unmake-instance ?fa)\n\t\t\t(assert (message (to wavefront-scheduling)\n\t\t\t\t\t\t\t\t (action can-wavefront-schedule)\n\t\t\t\t\t\t\t\t (argument ?p))\n\t\t\t\t\t (message (to path-conditional)\n\t\t\t\t\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"165c9e842150252fe019a811dbec47ecb336267d","subject":"update beerex.clp","message":"update beerex.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beerex.clp","new_file":"clips\/beerex.clp","new_contents":"\n;;;==========================================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink with a meal.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===========================================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (default 100.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clips\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?a1 ?a2)\n (< (fact-slot-value ?a1 certainty) (fact-slot-value ?a2 certainty)))\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clips\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clips\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (\/ (- (* (+ ?certainty1 ?certainty2) 100) (* ?certainty1 ?certainty2)) 100))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule remove-poor-beer-choices\n ?f <- (attribute (name beer) (certainty ?certainty&:(< ?certainty 50)))\n =>\n (retract ?f))\n\n(defrule print-results\n (declare (salience ?*low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (do-for-all-facts ((?a attribute)) (neq ?a:name beer) (retract ?a))\n (bind ?beers \"\")\n (bind ?attributes (find-all-facts ((?a attribute)) (eq ?a:name beer)))\n (bind ?attributes (sort sort-certainties ?attributes))\n (progn$ (?a ?attributes)\n (bind ?beers (str-cat ?beers (format nil \"%s with certainty %-2d%% %n\"\n (fact-slot-value ?a value) (fact-slot-value ?a certainty))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n\" \"*\u2705 Done. I have selected these beer styles for you.*\") ?beers))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))","old_contents":"\n;;;==========================================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink with a meal.\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===========================================================\n\n\n;;**************\n;;* DEFGLOBALS *\n;;**************\n\n(defglobal\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000)\n\n;;****************\n;;* DEFTEMPLATES *\n;;****************\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot help)\n (slot why)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (default 100.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;************\n;;* DEFFACTS *\n;;************\n\n(deffacts startup\n (state-list))\n\n(defrule load-beer-styles-list\n =>\n (load-facts clips\/beer-styles.fct))\n\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction sort-certainties (?a1 ?a2)\n (< (fact-slot-value ?a1 certainty) (fact-slot-value ?a2 certainty)))\n\n;;*****************\n;;* INITIAL STATE *\n;;*****************\n\n(defrule start\n =>\n (set-strategy random)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))\n\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n(defrule load-beer-question-rules\n =>\n (load clips\/beer-questions.clp))\n\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n(defrule load-beer-knowledge-rules\n =>\n (load clips\/beer-knowledge.clp))\n\n;;********************************\n;;* BEER SELECTION & PRINT RULES *\n;;********************************\n\n(defrule combine-certainties\n ?f1 <- (attribute (name ?name) (value ?value) (certainty ?certainty1))\n ?f2 <- (attribute (name ?name) (value ?value) (certainty ?certainty2))\n (test (neq ?f1 ?f2))\n =>\n (retract ?f1)\n (modify ?f2 (certainty (\/ (- (* (+ ?certainty1 ?certainty2) 100) (* ?certainty1 ?certainty2)) 100))))\n\n(defrule generate-beers\n (declare (salience ?*medium-low-priority*))\n (or (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-style) (value ?beer-style) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (link ?link))\n (attribute (name best-name) (value ?beer-name) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (alcohol $? ?alcohol $?) (link ?link))\n (attribute (name best-alcohol) (value ?alcohol) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (color $? ?color $?) (link ?link))\n (attribute (name best-color) (value ?color) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (flavor $? ?flavor $?) (link ?link))\n (attribute (name best-flavor) (value ?flavor) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (fermentation $? ?fermentation $?) (link ?link))\n (attribute (name best-fermentation) (value ?fermentation) (certainty ?certainty)))\n (and (beer (style ?beer-style) (name ?beer-name) (carbonation $? ?carbonation $?) (link ?link))\n (attribute (name best-carbonation) (value ?carbonation) (certainty ?certainty))))\n =>\n (assert (attribute (name beer)\n (value (format nil \"\ud83c\udf7a [%s - %s](%s)\" ?beer-style ?beer-name ?link))\n (certainty ?certainty))))\n\n(defrule remove-poor-beer-choices\n ?f <- (attribute (name beer) (certainty ?certainty&:(< ?certainty 50)))\n =>\n (retract ?f))\n\n(defrule print-results\n (declare (salience ?*medium-low-priority*))\n (UI-state (id ?id))\n (state-list (current ?id))\n =>\n (do-for-all-facts ((?a attribute)) (neq ?a:name beer) (retract ?a))\n (bind ?beers \"\")\n (bind ?attributes (find-all-facts ((?a attribute)) (eq ?a:name beer)))\n (bind ?attributes (sort sort-certainties ?attributes))\n (progn$ (?a ?attributes)\n (bind ?beers (str-cat ?beers (format nil \"%s with certainty %-2d%% %n\"\n (fact-slot-value ?a value) (fact-slot-value ?a certainty))))\n (retract ?a))\n (if (neq ?beers \"\")\n then (bind ?results (str-cat (format nil \"%s %n%n\" \"*\u2705 Done. I have selected these beer styles for you.*\") ?beers))\n else (bind ?results (format nil \"%s %n%n%s\" \"*\ud83d\udeab Sorry! I could not select any beer style for you. \ud83d\ude1e\"\n \"Please, try again! \ud83d\udcaa\ud83c\udffb*\")))\n (assert (UI-state (display ?results)\n (state final))))\n\n;;*************************\n;;* GUI INTERACTION RULES *\n;;*************************\n\n(defrule ask-question\n (declare (salience ?*medium-high-priority*))\n (UI-state (id ?id))\n ?f <- (state-list (sequence $?s&:(not (member$ ?id ?s))))\n =>\n (modify ?f (current ?id) (sequence ?id ?s))\n (halt))\n\n(defrule handle-next-no-change-none-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-response-none-end-of-chain\n (declare (salience ?*high-priority*))\n ?f <- (next ?id)\n (state-list (sequence ?id $?))\n (UI-state (id ?id) (relation-asserted ?relation))\n =>\n (retract ?f)\n (assert (add-response ?id)))\n\n(defrule handle-next-no-change-middle-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n ?f2 <- (state-list (current ?id) (sequence $? ?nid ?id $?))\n (UI-state (id ?id) (response ?response))\n =>\n (retract ?f1)\n (modify ?f2 (current ?nid))\n (halt))\n\n(defrule handle-next-change-middle-of-chain\n (declare (salience ?*high-priority*))\n (next ?id ?response)\n ?f1 <- (state-list (current ?id) (sequence ?nid $?b ?id $?e))\n (UI-state (id ?id) (response ~?response))\n ?f2 <- (UI-state (id ?nid))\n =>\n (modify ?f1 (sequence ?b ?id ?e))\n (retract ?f2))\n\n(defrule handle-next-response-end-of-chain\n (declare (salience ?*high-priority*))\n ?f1 <- (next ?id ?response)\n (state-list (sequence ?id $?))\n ?f2 <- (UI-state (id ?id) (response ?expected) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (if (neq ?response ?expected)\n then (modify ?f2 (response ?response)))\n (assert (add-response ?id ?response)))\n\n(defrule handle-add-response\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id ?response)\n =>\n (if (eq (str-index \" \" ?response) FALSE)\n then (str-assert (str-cat \"(\" ?relation \" \" ?response \")\"))\n else (str-assert (str-cat \"(\" ?relation \" \" \"\\\"\" ?response \"\\\"\" \")\")))\n (retract ?f))\n\n(defrule handle-add-response-none\n (declare (salience ?*high-priority*))\n (UI-state (id ?id) (relation-asserted ?relation))\n ?f <- (add-response ?id)\n =>\n (str-assert (str-cat \"(\" ?relation \")\"))\n (retract ?f))\n\n(defrule handle-prev\n (declare (salience ?*high-priority*))\n ?f1 <- (prev ?id)\n (UI-state (id ?id) (state ?state))\n ?f2 <- (state-list (sequence $?b ?id ?pid $?e))\n (UI-state (id ?pid) (relation-asserted ?relation))\n =>\n (retract ?f1)\n (modify ?f2 (current ?pid))\n (do-for-fact ((?r ?relation)) (neq ?relation start) (retract ?r))\n (if (eq ?state final)\n then (progn$ (?rule (get-defrule-list))\n (if (neq (str-index \"determine-best-beer-attributes\" ?rule) FALSE)\n then (refresh ?rule))))\n (halt))","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"102c15602e74b63c73d87fc66d2bd2bca9b71db4","subject":"Modified the PassHeader of wavefront-scheduling to load the rest of pass code","message":"Modified the PassHeader of wavefront-scheduling to load the rest of pass code\n\nThis includes the construction folder and the scheduler folder\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/PassHeader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/PassHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(batch* \"passes\/wavefront-scheduling\/common\/TypeLoader.clp\")\n(load* \"passes\/wavefront-scheduling\/Init.clp\")\n(load* \"passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp\")\n(load* \"passes\/wavefront-scheduling\/constructor\/WavefrontInitialization.clp\")\n(batch* \"passes\/wavefront-scheduling\/scheduler\/Loader.clp\")\n;TODO: More files to include\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(batch* \"passes\/wavefront-scheduling\/common\/TypeLoader.clp\")\n(load* \"passes\/wavefront-scheduling\/Init.clp\")\n(load* \"passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp\")\n;TODO: More files to include\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fa35b567f63554479f6ff6fc035262cc64310891","subject":"Added the load* statement for the Functions in wavefront-scheduling","message":"Added the load* statement for the Functions in wavefront-scheduling\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/TypeLoader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/TypeLoader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(load* \"passes\/wavefront-scheduling\/common\/CompensationPathVector.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/Wavefront.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/FrequencyAnalysis.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/PathAggregate.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/Functions.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(load* \"passes\/wavefront-scheduling\/common\/CompensationPathVector.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/Wavefront.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/FrequencyAnalysis.clp\")\n(load* \"passes\/wavefront-scheduling\/common\/PathAggregate.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"33e10aafb9da443711672c49f9f4631075524e16","subject":"waltz part running about 1 minute","message":"waltz part running about 1 minute\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltz\/waltz_1minute.clp","new_file":"clipsfiles\/waltz\/waltz_1minute.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n; ;;; #################################################################\n; ;;; Deffunctions\n; ;;;\n; ;;; In the OPS5 version of this program, the following deffunctions\n; ;;; were implemented in C code that needed to be linked with the OPS5\n; ;;; interpreter. Using deffunctions allows the benchmark to be run\n; ;;; without having to recompile and relink CLIPS with the C code used\n; ;;; in the original benchmark. The performance impact of using\n; ;;; deffunctions for this benchmark rather than C code is minimal.\n; ;;; #################################################################\n\n; (defglobal ?*MOD-NUM* = 100)\n\n; ;;; *****\n; ;;; atan2\n; ;;; *****\n\n; (deffunction atan2 (?y ?x)\n; (if (> ?x 0)\n; then\n; (return (atan (\/ ?y ?x))))\n\n; (if (< ?x 0)\n; then\n; (return (- (atan (\/ ?y ?x)) (pi))))\n\n; (if (> ?y 0) then\n; then\n; (return (pi)))\n\n; (if (< ?y 0)\n; then\n; (return (- 0 (pi))))\n\n; (return undefined))\n\n; ;;; *****\n; ;;; get-y\n; ;;; *****\n\n; (deffunction get-y (?val)\n; (mod ?val ?*MOD-NUM*))\n\n; ;;; *****\n; ;;; get-x\n; ;;; *****\n\n; (deffunction get-x (?val)\n; (integer (\/ ?val ?*MOD-NUM*)))\n\n; ;;; *********\n; ;;; get-angle\n; ;;; *********\n\n; (deffunction get-angle (?p1 ?p2)\n; (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n; (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n; (if (= ?delta-x 0)\n; then\n; (if (> ?delta-y 0)\n; \t\t then (return (\/ (pi) 2))\n; \t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n; else\n; (if (= ?delta-y 0)\n; then\n; (if (> ?delta-x 0)\n; then (return 0.0)\n; \t\t else (if (< ?delta-x 0) then return (pi)))\n; else\n; (return (atan2 ?delta-y ?delta-x)))))\n\n; ;;; ***************\n; ;;; inscribed-angle\n; ;;; ***************\n\n; (deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n; \t;; Get the angle between line #1 and the origin and the angle\n; \t;; between line #2 and the origin, and then subtract these values.\n\n; (bind ?angle1 (get-angle ?basepoint ?p1))\n; (bind ?angle2 (get-angle ?basepoint ?p2))\n; (bind ?temp (- ?angle1 ?angle2))\n\n; (if (< ?temp 0)\n; then (bind ?temp (- 0 ?temp)))\n\n; ;; We always want the smaller of the two angles inscribed, so\n; ;; if the answer is greater than 180 degrees, calculate the\n; ;; smaller angle and return it.\n\n; (if (> ?temp (pi))\n; then\n; (bind ?temp (- (* 2 (pi)) ?temp)))\n\n; (if (< ?temp 0)\n; then (return (- 0 ?temp)))\n\n; (return ?temp))\n\n; ;;; ***************\n; ;;; make-3-junction\n; ;;; ***************\n\n; (deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n; (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n; (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n; (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n; (bind ?sum1213 (+ ?angle12 ?angle13))\n; (bind ?sum1223 (+ ?angle12 ?angle23))\n; (bind ?sum1323 (+ ?angle13 ?angle23))\n\n; (if (< ?sum1213 ?sum1223)\n; then\n; (if (< ?sum1213 ?sum1323)\n; then\n; (bind ?sum ?sum1213)\n; (bind ?shaft ?p1)\n; (bind ?barb1 ?p2)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2))\n; else\n; (if (< ?sum1223 ?sum1323)\n; then\n; (bind ?sum ?sum1223)\n; (bind ?shaft ?p2)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2)))\n\n; (bind ?delta (- ?sum (pi)))\n; (if (< ?delta 0)\n; then (bind ?delta (- 0 ?delta)))\n\n; (if (< ?delta 0.001)\n; then (bind ?jtype tee)\n; else\n; (if (> ?sum (pi))\n; then (bind ?jtype fork)\n; else (bind ?jtype arrow)))\n\n; (assert (junction (p1 (integer ?barb1))\n; (p2 (integer ?shaft))\n; (p3 (integer ?barb2))\n; (base_point (integer ?basepoint))\n; (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrules\n(label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n)\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'clipsfiles\/waltz\/waltz_1minute.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"d5b01ce65788a9ce83d1dab98f834568cb331916","subject":"Added construction\/WavefrontInitialization.clp","message":"Added construction\/WavefrontInitialization.clp\n\nThis file contains the rules originally found in the WavefrontInit stage.\n\nThis code has been rewritten so that the wavefront objects are created first.\nThis has the side effect of being able to figure out which regions are capable\nof being wavefront scheduled because there is a wavefront object associated\nwith it.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/construction\/WavefrontInitialization.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/construction\/WavefrontInitialization.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::generate-wavefront-object\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (argument ?p))\n (not (exists (object (is-a Wavefront) (parent ?p))))\n =>\n (retract ?msg)\n (make-instance of Wavefront (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::retract-wavefront-creation-action\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (argument ?p))\n (exists (object (is-a Wavefront) (parent ?p)))\n =>\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-block-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) (parent ?r))\n (object (is-a Region) (id ?r) (Entrances $? ?e $?))\n (object (is-a BasicBlock) (id ?e) (parent ?r))\n =>\n (assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-region-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) (parent ?r))\n (object (is-a Region) (id ?r) (Entrances $? ?e $?))\n (object (is-a BasicBlock) (id ?e) (parent ~?r))\n (object (is-a Region) (parent ?r) (Entrances $? ?e $?) (id ?q))\n =>\n (assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single-single=>multi\n (declare (salience 1))\n ;(Stage WavefrontInit $?)\n ?f0 <- (Add ?v0 to wavefront for ?r)\n ?f1 <- (Add ?v1&~?v0 to wavefront for ?r)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-multi-multi=>multi\n (declare (salience 1))\n ?f0 <- (In wavefront ?r add $?a)\n ?f1 <- (In wavefront ?r add $?b)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n =>\n (retract ?f0)\n (assert (In wavefront ?r add ?v0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::construct-wavefront-for-region\n (declare (salience -1))\n ?f <- (In wavefront ?r add $?w)\n ?wave <- (object (is-a Wavefront) (parent ?r))\n =>\n (retract ?f)\n (modify-instance ?wave (contents $?w)))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/passes\/wavefront-scheduling\/construction\/WavefrontInitialization.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"e1601181c543f925becebe5c65b1b56b1cd6f0c0","subject":"Sample rules for examining Jess behavior","message":"Sample rules for examining Jess behavior\n","repos":"Ramarren\/lisa","old_file":"misc\/sample.clp","new_file":"misc\/sample.clp","new_contents":"(deftemplate rocky\n (slot name))\n\n(deftemplate boris\n (slot name))\n\n(defrule schtum\n (rocky (name \"rocky\"))\n (boris (name \"boris\"))\n =>\n (printout t \"schtum!\" crlf))\n\n(defrule schtum-shared\n (boris (name \"boris\"))\n =>\n (printout t \"schtum-shared!\" crlf))\n\n(reset)\n(assert (rocky (name \"rocky\")))\n(assert (boris (name \"boris\")))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'misc\/sample.clp' did not match any file(s) known to git\n","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"682855ab6fc1b9c51a220805fe2f2035ebf1ea28","subject":"Fixed a bug in LoopRegionMerging.clp","message":"Fixed a bug in LoopRegionMerging.clp\n\nI found that I was not retracting finished facts correctly because the match\nwas looking for the word 'for' instead of '=>'. I also reformatted the code to\nbe far cleaner and took advantage of modify and delete where appropriate.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n \"Creates a flat representation of the contents of the given region\"\n (object (is-a Region) \n (id ?id) \n (contents $?z))\n (not (exists (object (is-a FlatList) \n (parent ?id))))\n =>\n (make-instance of FlatList (parent ?id)) \n (assert (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => $?z))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => ?first $?rest))\n ?o <- (object (is-a FlatList) \n (parent ?id))\n (object (is-a BasicBlock) \n (id ?first))\n =>\n (slot-insert$ ?o values 1 ?first)\n (modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => ?first $?rest))\n ?o <- (object (is-a FlatList) \n (parent ?id))\n (object (is-a Region) \n (id ?first))\n (object (is-a FlatList) \n (parent ?first) \n (id ?name))\n =>\n ;Add the reference to FlatList for the time being until we have\n ;finished constructing an entire flat list\n (slot-insert$ ?o values 1 ?name)\n (modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id =>))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n \"Takes a flat list and expands one of the elements of the contents if \n it turns out that element is another flat list\"\n ?id <- (object (is-a FlatList) \n (values $?a ?b $?c))\n (object (is-a FlatList) \n (id ?b) \n (values $?j))\n =>\n (modify-instance ?id (values $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n \"Asserts that a region owns another through a subset check. The first \n flat list is checked to see if it is a _proper_ subset of the second\"\n ?f0 <- (object (is-a FlatList) \n (id ?i0) \n (values $?c0) \n (parent ?p0))\n ?f1 <- (object (is-a FlatList) \n (id ?i1&~?i0) \n (values $?c1) \n (parent ?p1))\n (test (and (subsetp ?c0 ?c1) \n (> (length$ ?c1) \n (length$ ?c0))))\n =>\n (assert (message (to loop-region-merging) \n (action claim-owns) \n (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n \"This rule is used to assert ownership claims on basic blocks\"\n ?f0 <- (object (is-a FlatList) \n (parent ?p) \n (values $? ?b $?))\n (object (is-a BasicBlock) \n (id ?b))\n =>\n (assert (message (to loop-region-merging) \n (action claim-owns) \n (arguments ?p => ?b))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n \"Asserts that two regions are equivalent if one flat list contains the\n same elements as a second one.\"\n ?f0 <- (object (is-a FlatList) \n (id ?i0) \n (values $?c0) \n (parent ?p0))\n ?f1 <- (object (is-a FlatList) \n (id ?i1&~?i0) \n (values $?c1) \n (parent ?p1))\n (test (and (subsetp ?c0 ?c1) \n (= (length$ ?c1) \n (length$ ?c0))))\n =>\n (assert (message (to loop-region-merging)\n (action claim-equivalent) \n (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n \"It is possible for two facts of equivalence to actually be the same \n fact\"\n (declare (salience -1))\n ?f0 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?a => ?b))\n ?f1 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?b => ?a))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?a => ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n \"If we find an equivalence then it means that a loop and a region \n contain the same elements. Therefore the loop persists and the region \n dies. The loop is the first entry.\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action claim-equivalent) \n (arguments ?a => ?b))\n (object (is-a Loop) \n (id ?a))\n (object (is-a Region&~Loop) \n (id ?b))\n =>\n (duplicate ?f0 (action delete-region)\n (arguments ?b))\n (modify ?f0 (action replace)\n (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n \"If we find an equivalence then it means that a loop and a region \n contain the same elements. Therefore the loop persists and the region\n dies. The loop is the second entry.\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?b => ?a))\n (object (is-a Loop) \n (id ?a))\n (object (is-a Region&~Loop) \n (id ?b))\n =>\n (duplicate ?f0 (action delete-region)\n (arguments ?b))\n (modify ?f0 (action replace)))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n \"We target claims of ownership that deal with a given region that has \n to be replaced by another due to equivalence\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ?old => ?new))\n ?f1 <- (message (to loop-region-merging)\n (action claim-owns) \n (arguments ?old => ?other))\n =>\n (modify ?f0)\n (modify ?f1 (arguments ?new => ?other)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ?old => ?new))\n ?f1 <- (message (to loop-region-merging)\n (action claim-owns)\n (arguments ?other => ?old))\n =>\n (modify ?f0)\n (modify ?f1 (arguments ?other => ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n \"Retract replacement facts because there are no more claims to worry \n about\"\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ? => ?))\n =>\n (retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::DeleteTargetRegion\n \"Deletes the target region slated for deletion\"\n ?f0 <- (message (to loop-region-merging)\n (action delete-region)\n (arguments ?r0))\n ?region <- (object (is-a Region) \n (id ?r0))\n =>\n (retract ?f0)\n (unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::initiate-deletion\n \"Retracts the initial fact for this module and asserts local facts for\n deleting flat lists and ownership determinants\"\n ?f <- (message (from pipeline)\n (to loop-region-merging-cleanup-merger)\n (action initial-fact))\n =>\n (retract ?f)\n (assert (delete ownership-determinants)\n (delete flat-lists)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::DeleteFlatLists \n \"Deletes all of the flat lists in a single rule fire\"\n ?f0 <- (delete flat-lists)\n =>\n (retract ?f0)\n (progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n\t\t\t\"Creates a flat representation of the contents of the given region\"\n\t\t\t(object (is-a Region) (id ?id) (contents $?z))\n\t\t\t(not (exists (object (is-a FlatList) (parent ?id))))\n\t\t\t=>\n\t\t\t(make-instance of FlatList (parent ?id)) \n\t\t\t(assert (Populate FlatList of ?id with $?z)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a BasicBlock) (id ?first))\n\t\t\t=>\n\t\t\t(slot-insert$ ?o values 1 ?first)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n\t\t\t?f <- (Populate FlatList of ?id with ?first $?rest)\n\t\t\t?o <- (object (is-a FlatList) (parent ?id))\n\t\t\t(object (is-a Region) (id ?first))\n\t\t\t(object (is-a FlatList) (parent ?first) (id ?name))\n\t\t\t=>\n\t\t\t;Add the reference to FlatList for the time being until we have\n\t\t\t;finished constructing an entire flat list\n\t\t\t(slot-insert$ ?o values 1 ?name)\n\t\t\t(retract ?f)\n\t\t\t(assert (Populate FlatList of ?id with $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n\t\t\t?f <- (Populate FlatList of ? with)\n\t\t\t=>\n\t\t\t(retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n\t\t\t\"Takes a flat list and expands one of the elements of the contents if \n\t\t\tit turns out that element is another flat list\"\n\t\t\t?id <- (object (is-a FlatList) (values $?a ?b $?c))\n\t\t\t(object (is-a FlatList) (id ?b) (values $?j))\n\t\t\t=>\n\t\t\t(modify-instance ?id (values $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n\t\t\t\"Asserts that a region owns another through a subset check. The first \n\t\t\tflat list is checked to see if it is a _proper_ subset of the second\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (values $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (values $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (> (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n\t\t\t\"This rule is used to assert ownership claims on basic blocks\"\n\t\t\t?f0 <- (object (is-a FlatList) (parent ?p) (values $? ?b $?))\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?p => ?b))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n\t\t\t\"Asserts that two regions are equivalent if one flat list contains the\n\t\t\tsame elements as a second one.\"\n\t\t\t?f0 <- (object (is-a FlatList) (id ?i0) (values $?c0) (parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) (id ?i1&~?i0) (values $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (subsetp ?c0 ?c1) (= (length$ ?c1) (length$ ?c0))))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n\t\t\t\"It is possible for two facts of equivalence to actually be the same \n\t\t\tfact\"\n\t\t\t(declare (salience -1))\n\t\t\t?f0 <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))\n\t\t\t?f1 <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?b => ?a))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region \n\t\t\tdies. The loop is the first entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action delete-region) \n\t\t\t\t\t\t\t\t (arguments ?b))\n\t\t\t\t\t (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action replace) \n\t\t\t\t\t\t\t\t (arguments ?b => ?a))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region\n\t\t\tdies. The loop is the second entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging) \n\t\t\t\t(action claim-equivalent) \n\t\t\t\t(arguments ?b => ?a))\n\t\t\t(object (is-a Loop) (id ?a))\n\t\t\t(object (is-a Region&~Loop) (id ?b))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action delete-region) \n\t\t\t\t\t\t\t\t (arguments ?b))\n\t\t\t\t\t (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action replace) \n\t\t\t\t\t\t\t\t (arguments ?b => ?a))))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n\t\t\t\"We target claims of ownership that deal with a given region that has \n\t\t\tto be replaced by another due to equivalence\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t(action replace)\n\t\t\t\t(arguments ?old => ?new))\n\t\t\t?f1 <- (message (to loop-region-merging)\n\t\t\t\t(action claim-owns) \n\t\t\t\t(arguments ?old => ?other))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to loop-region-merging)\n\t\t\t\t\t\t (action claim-owns)\n\t\t\t\t\t\t\t\t (arguments ?new => ?other))\n\t\t\t (message (to loop-region-merging)\n\t\t\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ?old => ?new))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ?old => ?new))\n\t\t\t?f1 <- (message (to loop-region-merging)\n\t\t\t\t (action claim-owns)\n\t\t\t\t\t\t\t\t (arguments ?other => ?old))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to loop-region-merging)\n\t\t\t\t\t\t (action claim-owns)\n\t\t\t\t\t\t\t\t (arguments ?other => ?new))\n\t\t\t (message (to loop-region-merging)\n\t\t\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ?old => ?new))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n\t\t\t\"Retract replacement facts because there are no more claims to worry \n\t\t\tabout\"\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t (action replace)\n\t\t\t\t (arguments ?old with ?new))\n\t\t\t=>\n\t\t\t(retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::DeleteTargetRegion\n\t\t\t\"Deletes the target region slated for deletion\"\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t (action delete-region)\n\t\t\t\t\t\t\t\t (arguments ?r0))\n\t\t\t?region <- (object (is-a Region) (id ?r0))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::initiate-deletion\n \"Retracts the initial fact for this module and asserts local facts for\n deleting flat lists and ownership determinants\"\n\t?f <- (message (from pipeline)\n\t\t (to loop-region-merging-cleanup-merger)\n\t\t\t\t\t\t(action initial-fact))\n\t=>\n\t(retract ?f)\n\t(assert (delete ownership-determinants)\n\t (delete flat-lists)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::DeleteFlatLists \n\t\t\t\"Deletes all of the flat lists in a single rule fire\"\n\t\t\t?f0 <- (delete flat-lists)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n\t\t\t\t\t (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fe474e4e4945226816798b2f5f95c298da91ca5c","subject":"Fixed a bug in merge-three-line-headers","message":"Fixed a bug in merge-three-line-headers\n\nI had put UNKNONW instead of UNKNOWN for one of the templates to match\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?contents *\/)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (contents \/* $? *\/) (type UNKNOWN))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (contents #define ?name ?) (type UNKNOWN))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4d704c23c18bf5422dbd75050b1f52a5e23213ef","subject":"Cambiar las reglas y las funciones.","message":"Cambiar las reglas y las funciones.\n\nHemos quitado las reglas de avanzar lo d\u00edas para poner una funci\u00f3n que\nlo hace autom\u00e1ticamente. Tambi\u00e9n hemos a\u00f1adido una funci\u00f3n para avanzar\nel los cursos.\n","repos":"RubenAgudo\/InteligenciaArtificial","old_file":"src\/CLIPS\/EjercicioFinal\/rules.clp","new_file":"src\/CLIPS\/EjercicioFinal\/rules.clp","new_contents":"(defrule asignar\n (cursoActual ?cursoActual)\n ?as<-(asignatura \n\t\t(nombre ?nombre) \n\t\t(horasSemanales ?horasSemanales) \n\t\t(horasRestantes ?horasRestantes) \n\t\t(profesor ?profe) \n\t\t(curso ?cursoActual)\n\t)\n\t(test (> ?horasRestantes 0))\n (diaActual ?dia)\n\t?h<- (horaActual ?horaInicio)\n\t(test (< ?horaInicio 14))\n\t\n\t(not (exists (clase (curso ?) (nombre ?) (diaSemana ?dia) (profe ?profe) (horaInicio ?horaInicio) (horaFin ?))))\n\t\n\t=>\n\t\n (assert \n (clase\n (curso ?cursoActual)\n (nombre ?nombre)\n (diaSemana ?dia)\n (profe ?profe)\n (horaInicio ?horaInicio)\n (horaFin (+ ?horaInicio 1))\n )\n )\n\t(retract ?h)\n\t(assert (horaActual (+ ?horaInicio 1)))\n\t(modify ?as (horasRestantes (- ?horasRestantes 1)))\n \n)\n\n(deffunction avanzardia (?dia)\n\t(bind ?var ?dia)\n\t(switch ?var\n\t(case LUNES then (bind ?var MARTES))\n\t(case MARTES then (bind ?var MIERCOLES))\n\t(case MIERCOLES then (bind ?var JUEVES))\n\t(case JUEVES then (bind ?var VIERNES))\n\t(case VIERNES then (bind ?var LUNES)))\n)\n\n(deffunction avanzarannio (?dia)\n\t(bind ?var ?dia)\n\t(switch ?var\n\t(case LUNES then (bind ?var 0))\n\t(case MARTES then (bind ?var 0))\n\t(case MIERCOLES then (bind ?var 0))\n\t(case JUEVES then (bind ?var 0))\n\t(case VIERNES then (bind ?var 1)))\n)\n\n\n(defrule avanzar\n\t?d<-(diaActual ?dia)\n\t?h <-(horaActual 14)\n\t?c<-(cursoActual ?cursoActual)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(retract ?c)\n\t(assert (cursoActual (+ ?cursoActual (avanzarannio ?dia))))\n\t(assert (diaActual (avanzardia ?dia)))\n\t(assert (horaActual 8))\n)\n\n","old_contents":"(defrule asignar\n (cursoActual ?cursoActual)\n ?as<-(asignatura \n\t\t(nombre ?nombre) \n\t\t(horasSemanales ?horasSemanales) \n\t\t(horasRestantes ?horasRestantes) \n\t\t(profesor ?profe) \n\t\t(curso ?cursoActual)\n\t)\n\t(test (> ?horasRestantes 0))\n (diaActual ?dia)\n\t?h<- (horaActual ?horaInicio)\n\t(test (< ?horaInicio 14))\n\t\n\t(not (exists (clase (curso ?) (nombre ?) (diaSemana ?dia) (profe ?profe) (horaInicio ?horaInicio) (horaFin ?))))\n\t\n\t=>\n\t\n (assert \n (clase\n (curso ?cursoActual)\n (nombre ?nombre)\n (diaSemana ?dia)\n (profe ?profe)\n (horaInicio ?horaInicio)\n (horaFin (+ ?horaInicio 1))\n )\n )\n\t(retract ?h)\n\t(assert (horaActual (+ ?horaInicio 1)))\n\t(modify ?as (horasRestantes (- ?horasRestantes 1)))\n \n)\n\n(defrule avanzarDeLunesAMartes\n\t?d<-(diaActual LUNES)\n\t?h <-(horaActual 14)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(assert (diaActual MARTES))\n\t(assert (horaActual 8))\n)\n\n(defrule avanzarDeMartesAMiercoles\n\t?d<-(diaActual MARTES)\n\t?h <-(horaActual 14)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(assert (diaActual MIERCOLES))\n\t(assert (horaActual 8))\n)\n\n(defrule avanzarDeMiercolesAJueves\n\t?d<-(diaActual MIERCOLES)\n\t?h <-(horaActual 14)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(assert (diaActual JUEVES))\n\t(assert (horaActual 8))\n)\n\n(defrule avanzarDeJuevesAViernes\n\t?d<-(diaActual JUEVES)\n\t?h <-(horaActual 14)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(assert (diaActual VIERNES))\n\t(assert (horaActual 8))\n)\n\n(defrule avanzarDeViernesALunes\n\t?d<-(diaActual VIERNES)\n\t?h <-(horaActual 14)\n\t?c<-(cursoActual ?cursoActual)\n\t=>\n\t(retract ?d)\n\t(retract ?h)\n\t(retract ?c)\n\t(assert (diaActual LUNES))\n\t(assert (cursoActual (+ 1 ?cursoActual)))\n\t(assert (horaActual 8))\n)\n\n(defrule forzar-avanzar-de-curso\n\t?c<-(cursoActual ?cursoActual)\n\t?d<-(diaActual ?)\n\t?h <-(horaActual ?)\n\t(asignatura \n\t\t(nombre ?) \n\t\t(horasSemanales ?) \n\t\t(horasRestantes 0) \n\t\t(profesor ?) \n\t\t(curso ?cursoActual))\n\t=>\n\t(retract ?c)\n\t(assert (diaActual LUNES))\n\t(assert (cursoActual (+ 1 ?cursoActual)))\n\t(assert (horaActual 8))\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"f329bf1c93e86434c7da544d35832b07d7136b33","subject":"Add task2 for chapter4","message":"Add task2 for chapter4\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter4\/task2.clp","new_file":"ssu-ai-level-2\/chapter4\/task2.clp","new_contents":"(deffacts tovars\n (tovar TV 200 4 2015 Russia)\n (tovar Watch 199 5 2017 USA)\n (tovar Linkorn 1000 1 2010 Russia)\n (tovar IceCream 10 99 2017 Ukraine)\n (tovar Book 1 1 2001 Vanuatu)\n)\n\n(defrule ucenk\n (tovar ?name ?cost ?count ?year ?country)\n\n (test (or (?year < 2010)\n (?count < 4)\n )\n )\n =>\n (assert (ucenka ?name (* ?cost 0.15)))\n)","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter4\/task2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"5f1129934b58890a6c4058610951646a5e463c93","subject":"Changed the paths in Header.clp","message":"Changed the paths in Header.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"src\/clips\/modules\/engine\/Header.clp","new_file":"src\/clips\/modules\/engine\/Header.clp","new_contents":"; Header.clp Describes the header for the engine module\n; See LICENSE for license details\n; Written by Joshua Scoggins\n\n(defmodule engine (export ?ALL))\n\n(load* \"src\/clips\/modules\/engine\/Object.clp\")\n(load* \"src\/clips\/modules\/engine\/Screen.clp\")\n(load* \"src\/clips\/modules\/engine\/Entity.clp\")\n(load* \"src\/clips\/modules\/engine\/Resource.clp\")\n(load* \"src\/clips\/modules\/engine\/ResourceEntry.clp\")\n(load* \"src\/clips\/modules\/engine\/MusicResource.clp\")\n(load* \"src\/clips\/modules\/engine\/SoundResource.clp\")\n","old_contents":"; Header.clp Describes the header for the engine module\n; See LICENSE for license details\n; Written by Joshua Scoggins\n\n(defmodule engine (export ?ALL))\n\n(load* \"src\/engine\/Object.clp\")\n(load* \"src\/engine\/Screen.clp\")\n(load* \"src\/engine\/Entity.clp\")\n(load* \"src\/engine\/Resource.clp\")\n(load* \"src\/engine\/ResourceEntry.clp\")\n(load* \"src\/engine\/MusicResource.clp\")\n(load* \"src\/engine\/SoundResource.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"980b3abe8d699e17c769944a2004c1632745ad90","subject":"Undid the breaking code found in WavefrontScheduling.clp","message":"Undid the breaking code found in WavefrontScheduling.clp\n\nNow a call to instance-address is all that is needed to get things rolling\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (instance-address * (symbol-to-instance-name\n ?cpv)))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-address * (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"e549c90d58ed08e1278f5a5cb6cc2311e1a65136","subject":"Started porting WavefrontAdvancement.clp","message":"Started porting WavefrontAdvancement.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (contents $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (contents $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (slot-delete$ ?wave DeleteNodes 1 1)\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (Add into ?id blocks $?npe))))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-Match\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage AdvanceEnd $?)\n ?fct <- (Add into ?id blocks ?next $?rest)\n ?wave <- (object (is-a Wavefront) (ID ?id))\n =>\n (retract ?fct)\n ;I know that this is procedural but I really want to get this done\n (assert (Add into ?id blocks $?rest))\n (if (not (member$ ?next (send ?wave get-Contents))) then\n (slot-insert$ ?wave Contents 1 ?next)))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-NoMoreElements\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage AdvanceEnd $?)\n ?fct <- (Add into ? blocks)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:contents) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule MoveContentsToDeleteNodes\n\t\t\t\"Moves blocks out of the contents into the closed list\"\n\t\t\t(declare (salience 2701))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage AdvanceInit $?)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?z) (Parent ?r) \n\t\t\t\t\t\t\t\t (Contents $?c) (Closed $?cl))\n\t\t\t(test (or (> (length$ ?c) 0) (> (length$ ?cl) 0)))\n\t\t\t=>\n\t\t\t(slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule MarkShouldStayOnWavefront\n\t\t\t(declare (salience 343))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage AdvanceIdentify $?)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?q) (Parent ?r) \n\t\t\t\t\t\t\t\t (DeleteNodes $?a ?b $?c))\n\t\t\t?bb <- (object (is-a Diplomat) (ID ?b) (NextPathElements ?s))\n\t\t\t(object (is-a Diplomat) (ID ?s) (PreviousPathElements $?ppe))\n\t\t\t(test (not (subsetp ?ppe (send ?wave get-DeleteNodes)))) \n\t\t\t?agObj <- (object (is-a PathAggregate) (Parent ?b))\n\t\t\t=>\n (object-pattern-match-delay\n\t\t\t(if (not (member$ ?b (send ?wave get-Closed))) then\n\t\t\t (bind ?ind (member$ ?b (send ?wave get-Contents)))\n\t\t\t (slot-delete$ ?wave Contents ?ind ?ind)\n\t\t\t (slot-insert$ ?wave Closed 1 ?b))\n\t\t\t(modify-instance ?wave (DeleteNodes $?a $?c))))\n;------------------------------------------------------------------------------\n(defrule DeleteElementFromWavefront\n\t\t\t(declare (salience 180))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Advance $?)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?id) (Parent ?r) \n\t\t\t\t\t\t\t\t (DeleteNodes ?a $?))\n\t\t\t(object (is-a Diplomat) (ID ?a) (NextPathElements $?npe))\n\t\t\t=>\n (object-pattern-match-delay\n\t\t\t(bind ?ind (member$ ?a (send ?wave get-Contents)))\n\t\t\t(bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n\t\t\t(slot-delete$ ?wave DeleteNodes 1 1)\n\t\t\t(if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n\t\t\t(if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n\t\t\t(assert (Add into ?id blocks $?npe))))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-Match\n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage AdvanceEnd $?)\n\t\t\t?fct <- (Add into ?id blocks ?next $?rest)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?id))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t;I know that this is procedural but I really want to get this done\n\t\t\t(assert (Add into ?id blocks $?rest))\n\t\t\t(if (not (member$ ?next (send ?wave get-Contents))) then\n\t\t\t (slot-insert$ ?wave Contents 1 ?next)))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-NoMoreElements\n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage AdvanceEnd $?)\n\t\t\t?fct <- (Add into ? blocks)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule PonderRestartOfWavefrontScheduling\n\t\t\t(declare (salience -512))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t?fct <- (Substage Update $?)\n\t\t\t=>\n\t\t\t(bind ?instances (find-all-instances ((?wave Wavefront)) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (> (length$ ?wave:Contents) 0)))\n\t\t\t(if (> (length$ ?instances) 0) then\n\t\t\t (retract ?fct)\n\t\t\t (assert (Substage Init \n\t\t\t\t\t\t\t\t\t Identify \n\t\t\t\t\t\t\t\t\t PhiIdentify \n\t\t\t\t\t\t\t\t\t PhiNode \n\t\t\t\t\t\t\t\t\t PhiNodeUpdate \n\t\t\t\t\t\t\t\t\t Pathing \n\t\t\t\t\t\t\t\t\t Strip \n\t\t\t\t\t\t\t\t\t Inject \n\t\t\t\t\t\t\t\t\t Acquire \n\t\t\t\t\t\t\t\t\t Slice \n\t\t\t\t\t\t\t\t\t AnalyzeInit \n\t\t\t\t\t\t\t\t\t GenerateAnalyze0\n\t\t\t\t\t\t\t\t\t GenerateAnalyze\n\t\t\t\t\t\t\t\t\t Analyze \n\t\t\t\t\t\t\t\t\t SliceAnalyze \n\t\t\t\t\t\t\t\t\t MergeInit \n\t\t\t\t\t\t\t\t\t Merge \n\t\t\t\t\t\t\t\t\t MergeUpdate\n\t\t\t\t\t\t\t\t\t ReopenBlocks\n\t\t\t\t\t\t\t\t\t Ponder \n\t\t\t\t\t\t\t\t\t Rename \n\t\t\t\t\t\t\t\t\t DependencyAnalysis \n\t\t\t\t\t\t\t\t\t ;ScheduleObjectCreation \n\t\t\t\t\t\t\t\t\t ;ScheduleObjectUsage \n\t\t\t\t\t\t\t\t\t ;ResetScheduling \n\t\t\t\t\t\t\t\t\t ;InitLLVMUpdate\n\t\t\t\t\t\t\t\t\t ;LLVMUpdate \n\t\t\t\t\t\t\t\t\t AdvanceInit \n\t\t\t\t\t\t\t\t\t AdvanceIdentify\n\t\t\t\t\t\t\t\t\t Advance\n\t\t\t\t\t\t\t\t\t AdvanceEnd\n\t\t\t\t\t\t\t\t\t Update))))\n;------------------------------------------------------------------------------\n(defrule RetractUnlinkedInstructions\n\t\t\t(Stage WavefrontFinal $?)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?b) \n\t\t\t\t\t\t\t\t(UnlinkedInstructions ?i $?rest))\n\t\t\t?instruction <- (object (is-a Instruction) (ID ?i) (Parent ?b) \n\t\t\t\t\t\t\t\t\t\t\t(Pointer ?ptr))\n\t\t\t(object (is-a PathAggregate) (Parent ?b) \n\t\t\t\t\t (InstructionPropagation $? ?i ?new ?b ! $?))\n\t\t\t(object (is-a Instruction) (ID ?new) (Pointer ?nPtr))\n\t\t\t=>\n\t\t\t;this is a little gross but it is a very easy way to ensure that\n\t\t\t;things work correctly\n (object-pattern-match-delay\n\t\t\t(llvm-replace-all-uses ?ptr ?nPtr)\n\t\t\t(modify-instance ?bb (UnlinkedInstructions $?rest))\n\t\t\t(llvm-unlink-and-delete-instruction ?ptr)\n\t\t\t(unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0d336cae03146f69744aeb972009619de9627ece","subject":"Modified DeclareLibraryFunctions to be defmethods","message":"Modified DeclareLibraryFunctions to be defmethods\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"init\/DeclareLibraryFunctions.clp","new_file":"init\/DeclareLibraryFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLibraryFunctions.clp - Defines a series of functions used to\n; streamline the loading of libraries in the adventure engine\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defgeneric init::load-library \"Loads a given library header\")\n;------------------------------------------------------------------------------\n(defgeneric init::library-files \"Loads the contents of a target library\")\n;------------------------------------------------------------------------------\n(defmethod init::load-library \n \"Loads an adventure engine library from the root of the src folder\"\n (?name)\n (generic-load lib ?name Library.clp))\n;------------------------------------------------------------------------------\n(defmethod init::library-files \n \"Loads the files that make up the target library\"\n ((?offset LEXEME)\n ($?names LEXEME))\n (generic-load lib ?offset ?names))\n;------------------------------------------------------------------------------\n(defmethod init::library-files\n \"Loads the files that make up the target library\"\n ((?offset LEXEME)\n (?names LEXEME MULTIFIELD))\n (generic-load lib ?offset ?names))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLibraryFunctions.clp - Defines a series of functions used to\n; streamline the loading of libraries in the adventure engine\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-library \n \"Loads an adventure engine library from the root of the src folder\"\n (?name)\n (batch* (format nil \"lib\/%s\/Library.clp\" ?name)))\n;------------------------------------------------------------------------------\n(deffunction init::library-files \n \"Loads the files that make up the target library\"\n (?offset $?names)\n (bind ?coreOffset (format nil \"lib\/%s\/%s\" ?offset \"%s\"))\n (progn$ (?a $?names)\n (batch* (format nil ?coreOffset ?a))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"e7f1c6ba7f50fd23414c7dbf63e321cdc0426ce9","subject":"WidgetElement.clp: Removed the message-handler note for raise-event","message":"WidgetElement.clp: Removed the message-handler note for raise-event\n\nThis will be handled through the use of objects that are events\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"src\/lib\/widget\/WidgetElement.clp","new_file":"src\/lib\/widget\/WidgetElement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER))\n (multislot children (type SYMBOL))\n (slot width (type NUMBER))\n (slot height (type NUMBER)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER))\n (multislot children (type SYMBOL))\n (slot width (type NUMBER))\n (slot height (type NUMBER))\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9f3b9eab5ab66c4a65686f096a72a0040ad1c4b1","subject":"Start chapter three implementation","message":"Start chapter three implementation\n","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter-3.clp","new_file":"ssu-ai-level-2\/chapter-3.clp","new_contents":"(deftemplate client\n\t(slot name)\n\t(slot number)\n\t(slot city (default Saratov))\n)\n\n(client (name Ivanov) (number 1) (city Saratov))\n(client (name Petrov) (number 2) (city Saratov))\n(client (name Zaizev) (number 3) (city Vorones))\n\n(modify 1 (city Samara))\n(modify 2 (name Lelyakin))\n(dublicate 3 (number 4))\n\n(assert client (name Kefalic) (number 5) (city Moscow))\n(assert client (name Marmonm) (number 6) (city Kazan))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter-3.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"a6ba17fcb0b235ee3008d0f86d00ddf35b425da0","subject":"Added the Hint type","message":"Added the Hint type\n\nIt is a useful class that can be used in a wide variety of situations.\nIt has a reference count field and associated message-handlers to increment and\ndecrement it\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/Hint.clp","new_file":"modules\/core\/Hint.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Hint.clp - An object used to signify something is a hint. It also has the\n; ability to be reference counted if necessary\n;------------------------------------------------------------------------------\n(defclass core::Hint \n \"An object that makes it easy to create temporary entities.\"\n (is-a core::Object)\n (multislot values (visibility public))\n (slot reference-count (type NUMBER) (visibility public))\n (slot type (visibility public) (type SYMBOL))\n (slot point (visibility public) (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint increment-reference-count ($?by)\n\"Incrementes the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \nincremented by. If more than one parameter is given then those numbers are \nadded together and then added to the current reference count\"\n\t\t\t\t\t\t (bind ?len (length$ ?by))\n\t\t\t\t\t\t (switch (length$ ?by)\n\t\t\t\t\t\t\t\t\t (case 0 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(+ 1 ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (case 1 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(+ (first$ ?by) ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (default \n\t\t\t\t\t\t\t\t\t\t(bind ?v (eval (format nil \"(+ %s)\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (implode$ ?by))))\n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(+ ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint decrement-reference-count \n\"Decrements the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \ndecremented by. If more than one parameter is given then those numbers are \nadded together and then subtracted from the current reference count\"\n\t\t\t\t\t\t ($?by)\n\t\t\t\t\t\t (bind ?len (length$ ?by))\n\t\t\t\t\t\t (switch (length$ ?by)\n\t\t\t\t\t\t\t\t\t (case 0 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(- 1 ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (case 1 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(- (first$ ?by) ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (default \n\t\t\t\t\t\t\t\t\t\t;add all of the element together so that the\n\t\t\t\t\t\t\t\t\t\t;subtraction is correct\n\t\t\t\t\t\t\t\t\t\t(bind ?v (eval (format nil \"(+ %s)\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (implode$ ?by))))\n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(- ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/core\/Hint.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9b33289ee8de7d337b994490c841300ca61b9280","subject":"Added the ParentedObject class","message":"Added the ParentedObject class\n\nThis class adds a parent field to the standard object class.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/Object.clp","new_file":"modules\/core\/Object.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Base class of all objects \n;------------------------------------------------------------------------------\n(defclass core::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visiblity public) (access initialize-only))\n (slot class (type SYMBOL) (visiblity public) (access initialize-only)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Object init around \n\t\t\t\t\t\t \"Initializes the object, setting the id and class of the \n\t\t\t\t\t\t object\" ()\n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;we want to set this information as the last thing before \n\t\t\t\t\t\t ;we return \n\t\t\t\t\t\t (bind ?self:id (instance-name-to-symbol \n\t\t\t\t\t\t\t\t\t\t\t\t (instance-name ?self)))\n\t\t\t\t\t\t (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n(defclass core::ParentedObject \n \"An object that has a parent field.\" \n (is-a core::Object)\n (slot parent (type SYMBOL) (visibility public)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Base class of all objects \n;------------------------------------------------------------------------------\n(defclass core::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visiblity public) (access initialize-only))\n (slot class (type SYMBOL) (visiblity public) (access initialize-only)))\n\n(defmessage-handler core::Object init around \n\t\t\t\t\t\t \"Initializes the object, setting the id and class of the \n\t\t\t\t\t\t object\" ()\n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;we want to set this information as the last thing before \n\t\t\t\t\t\t ;we return\n\t\t\t\t\t\t (bind ?self:id (instance-name-to-symbol \n\t\t\t\t\t\t\t\t\t\t\t\t(instance-name ?self)))\n\t\t\t\t\t\t (bind ?self:class (class ?self)))\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3a0e4a50562c0f21611a6a81fe55b08a154df702","subject":"Create task6.clp","message":"Create task6.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task6.clp","new_file":"ssu-ai-level-2\/chapter7\/task6.clp","new_contents":"(deffunction reflect (?s)\n (bind ?s1 \"\")\n (bind ?n (length ?s))\n (loop-for-count (?i 0 ?n) do\n (bind ?c (sub-string (- ?n ?i) (- ?n ?i) ?s))\n (bind ?s1 (str-cat ?s1 ?c)))\n ?s1)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task6.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"246c1d0b26e989787317e9fcce3bf6c0f7e6825f","subject":"Made LLVMObject a ParentedObject","message":"Made LLVMObject a ParentedObject\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/LLVMObject.clp","new_file":"modules\/llvm\/LLVMObject.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMObject.clp - Base class for most LLVM objects in the llvm module\n;------------------------------------------------------------------------------\n(defclass llvm::LLVMObject \n (is-a core::Object core::InteropObject core::ParentedObject)\n (slot Name (visibility public))\n (multislot WritesTo (visibility public))\n (multislot ReadsFrom (visibility public)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMObject.clp - Base class for most LLVM objects in the llvm module\n;------------------------------------------------------------------------------\n(defclass llvm::LLVMObject (is-a core::Object core::InteropObject)\n (slot Name (visibility public))\n (multislot WritesTo (visibility public))\n (multislot ReadsFrom (visibility public)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3844d406b3779ec69b13aa3f36620f71cd1f45c4","subject":"Finished updating WavefrontAdvancement.clp","message":"Finished updating WavefrontAdvancement.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontAdvancement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (contents $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (contents $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?rest))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (modify-instance ?wave (DeleteNodes $?rest))\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => $?npe)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-Match\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id => ?next $?rest))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (contents $?contents))\n =>\n (modify ?fct (arguments ?id => $?rest))\n (if (not (member$ ?next $?contents)) then\n (modify-instance ?wave (contents $?contents ?next))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-end::PutSuccessorsOntoWavefront-NoMoreElements\n ?fct <- (message (to wavefront-scheduling)\n (action add-blocks-into)\n (arguments ?id =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:contents) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-advance-init::MoveContentsToDeleteNodes\n \"Moves blocks out of the contents into the closed list\"\n (declare (salience 2701))\n ?wave <- (object (is-a Wavefront) \n (id ?z) \n (parent ?r) \n (contents $?c) \n (Closed $?cl))\n (test (or (> (length$ ?c) 0) \n (> (length$ ?cl) 0)))\n =>\n (slot-insert$ ?wave DeleteNodes 1 ?c ?cl))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance-identify::MarkShouldStayOnWavefront\n (declare (salience 343))\n ?wave <- (object (is-a Wavefront) \n (id ?q) \n (parent ?r) \n (DeleteNodes $?a ?b $?c)\n (Closed $?clos)\n (contents $?contents))\n\n ?bb <- (object (is-a Diplomat) \n (id ?b) \n (NextPathElements ?s))\n (object (is-a Diplomat) \n (id ?s) \n (PreviousPathElements $?ppe))\n (test (not (subsetp ?ppe (create$ ?a ?b ?c))))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b))\n =>\n (object-pattern-match-delay\n (if (not (member$ ?b $?clos)) then\n (bind ?ind (member$ ?b $?contents))\n (slot-delete$ ?wave Contents ?ind ?ind)\n (modify-instance ?wave (Closed $?clos ?b)\n (DeleteNodes $?a $?c))\n else\n (modify-instance ?wave (DeleteNodes $?a $?c)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-schedule-advance::DeleteElementFromWavefront\n (declare (salience 180))\n ?wave <- (object (is-a Wavefront) \n (id ?id) \n (parent ?r) \n (DeleteNodes ?a $?))\n (object (is-a Diplomat) \n (id ?a) \n (NextPathElements $?npe))\n =>\n ;TODO: Continue to port here\n (object-pattern-match-delay\n (bind ?ind (member$ ?a (send ?wave get-Contents)))\n (bind ?ind2 (member$ ?a (send ?wave get-Closed)))\n (slot-delete$ ?wave DeleteNodes 1 1)\n (if ?ind then (slot-delete$ ?wave Contents ?ind ?ind))\n (if ?ind2 then (slot-delete$ ?wave Closed ?ind2 ?ind2))\n (assert (Add into ?id blocks $?npe))))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-Match\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage AdvanceEnd $?)\n ?fct <- (Add into ?id blocks ?next $?rest)\n ?wave <- (object (is-a Wavefront) (ID ?id))\n =>\n (retract ?fct)\n ;I know that this is procedural but I really want to get this done\n (assert (Add into ?id blocks $?rest))\n (if (not (member$ ?next (send ?wave get-Contents))) then\n (slot-insert$ ?wave Contents 1 ?next)))\n;------------------------------------------------------------------------------\n(defrule PutSuccessorsOntoWavefront-NoMoreElements\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage AdvanceEnd $?)\n ?fct <- (Add into ? blocks)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-update::PonderRestartOfWavefrontScheduling\n ?fct <- (message (to wavefront-scheduling-update)\n (from pipeline)\n (action initial-fact))\n ?obj <- (object (is-a pass-description) \n (passes $?passes))\n =>\n (retract ?fct)\n (bind ?instances (find-all-instances ((?wave Wavefront)) \n (> (length$ ?wave:contents) 0)))\n (if (> (length$ ?instances) 0) then\n (modify-instance ?obj \n (passes wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n $?passes))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-final::RetractUnlinkedInstructions\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (UnlinkedInstructions ?i $?rest))\n ?instruction <- (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (pointer ?ptr))\n (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $? ?i ?new ?b ! $?))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n =>\n ;this is a little gross but it is a very easy way to ensure that\n ;things work correctly so that the LLVM ModuleVerifier doesn't come\n ;down like a hammer on what we're doing\n (object-pattern-match-delay\n (llvm-replace-all-uses ?ptr ?nPtr)\n (modify-instance ?bb (UnlinkedInstructions $?rest))\n (llvm-unlink-and-delete-instruction ?ptr)\n (unmake-instance ?instruction)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3673bf6acd024126acfbdeee40978873cf41e119","subject":"Added support for printing out the many different constant checks","message":"Added support for printing out the many different constant checks\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (heading-span (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n;(defrule grouping-update::\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0ecb7a3215ae630186b552b7132f7427a435f395","subject":"Create task2.clp","message":"Create task2.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task2.clp","new_file":"ssu-ai-level-2\/chapter7\/task2.clp","new_contents":";Get string, replace all spaces by \"_\"\n(defrule replace\n =>\n (bind ?str (readline))\n (bind ?a \" \")\n (bind ?b \"_\")\n (bind ?n (str-length ?str))\n (bind ?res \"\")\n (loop-for-count (?i 1 ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n (bind ?d (str-compare ?c1 ?a))\n\n (if (= ?d 0) then\n (bind ?res (str-cat ?res ?b)))\n\n (if (<> ?d 0) then\n (bind ?res (str-cat ?res ?c1))))\n\n (printout t \"result=\" ?res crlf) \n )\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"31b7e37c8b0068530538dc25aa211e81032c3e65","subject":"Added the ModuleHeader for the core module","message":"Added the ModuleHeader for the core module\n\nThis file acts as the entry point to the module\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/ModuleHeader.clp","new_file":"modules\/core\/ModuleHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the core module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n(defmodule core \n ; Modify this export to add more classes\n ; Just remember that these three classes are pretty critical to the rest of\n ; the optimization\n (export defclass Object InteropObject Hint)\n ; Modify this export to add more functions to be exposed\n ; I would advise against removing these functions\n (export deffunction superset equal$ has-common-element disjoint) \n\n(load* \"modules\/core\/Object.clp\")\n(load* \"modules\/core\/InteropObject.clp\")\n(load* \"modules\/core\/Hint.clp\")\n; Add more defclasses here\n; The programmer is responsible for ordering the load statements so that\n; class dependencies are met\n(load* \"modules\/core\/SetExtensions.clp\")\n; Add more deffunctions here\n; The programmer is responsible for ordering the load statements so that\n; function dependencies are met\n\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/core\/ModuleHeader.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"41ecc304d723df0dd17936b2a022988ccadd1a85","subject":"Added a load statement for LLVMType into the llvm module header","message":"Added a load statement for LLVMType into the llvm module header\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/llvm\/ModuleHeader.clp","new_file":"modules\/llvm\/ModuleHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the llvm module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n; Path is modules\/llvm\/\n(defmodule llvm \n (import core defclass ?ALL)\n (import core deffunction ?ALL) \n (export defclass ?ALL)\n (export deffunction ?ALL))\n\n; DO NOT MESS WITH THE ORDER OF THESE COMMANDS\n; BAD THINGS CAN HAPPEN\n; Class loaders\n(load* \"modules\/llvm\/LLVMObject.clp\")\n(load* \"modules\/llvm\/LLVMType.clp\")\n(load* \"modules\/llvm\/LLVMValue.clp\")\n(load* \"modules\/llvm\/LLVMUser.clp\")\n(load* \"modules\/llvm\/Diplomat.clp\")\n\n; Function loaders\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ModuleHeader.clp - Contains the entry point into the llvm module. \n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n; Path is modules\/llvm\/\n(defmodule llvm \n (import core defclass ?ALL)\n (import core deffunction ?ALL) \n (export defclass ?ALL)\n (export deffunction ?ALL))\n\n; DO NOT MESS WITH THE ORDER OF THESE COMMANDS\n; BAD THINGS CAN HAPPEN\n; Class loaders\n(load* \"modules\/llvm\/LLVMObject.clp\")\n(load* \"modules\/llvm\/LLVMValue.clp\")\n(load* \"modules\/llvm\/LLVMUser.clp\")\n(load* \"modules\/llvm\/Diplomat.clp\")\n\n; Function loaders\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"49198926f18636b854ac97b451d6a6d473996ba9","subject":"WidgetElement.clp: Added support for raising and registering events","message":"WidgetElement.clp: Added support for raising and registering events\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine","old_file":"src\/lib\/widget\/WidgetElement.clp","new_file":"src\/lib\/widget\/WidgetElement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER))\n (slot width (type NUMBER))\n (slot height (type NUMBER))\n (slot reference-count (type NUMBER) (range 0 ?VARIABLE))\n (multislot children (type SYMBOL))\n (multislot valid-events (type SYMBOL))\n (message-handler declare-handler primary)\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n(defmessage-handler widget::WidgetElement declare-handler primary \n (?name ?fn)\n (bind ?we-name (gensym*))\n (make-instance ?we-name of WidgetEvent \n (event-name ?name)\n (function-to-call ?fn)\n (parent ?self:id)\n (reference-count 1))\n (bind ?result (member$ ?name ?self:valid-events))\n (if (not ?result) then\n (slot-direct-insert$ valid-events 1 ?name ?we-name )\n else\n (printout werror \"ERROR: Firing of multiple events not supported yet\" crlf)\n (halt))\n (return ?we-name))\n;------------------------------------------------------------------------------\n(defmessage-handler widget::WidgetElement raise-event primary\n (?name $?args)\n (bind ?offset (member$ ?name ?self:valid-events))\n (if (not ?offset) then\n (printout werror \"ERROR: given event \" ?name \n \" does not exist. Halting\" crlf)\n (halt)\n else\n (send (instance-address * (symbol-to-instance-name \n (nth$ (+ 1 ?offset)\n ?self:valid-events)))\n raise-event $?args)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER))\n (multislot children (type SYMBOL))\n (slot width (type NUMBER))\n (slot height (type NUMBER)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"002485f886ecf2fc0b0b7f10aaf9546ede3c63ee","subject":"Added the post-ponder module","message":"Added the post-ponder module\n\nThis module executes marks blocks as closed on the wavefront. This divergence\nfrom the original code was necessary because the modification of next pass set\nrequires that we get back to the pipeline first. In the original code, the\nchanging of the substage fact would preclude execution of\nFinishedSchedulingIntoBlock. However, in the module version it is necessary to\npush FinishedSchedulingIntoBlock into its own module instead.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pathing\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-node\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-node-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-strip\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-acquire\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-inject\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-acquire\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-slice\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-analyze-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-generate-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-generate-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-slice-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-reopen-blocks\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-ponder\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-rename\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-dependency-analysis\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-end\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-post-ponder\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-code::macro-expand\n ?msg <- (message (from pipeline) \n (to wavefront-scheduling-code)\n (action initial-fact))\n ?p <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?msg)\n (modify-instance ?p (passes \n wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-post-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n ;TODO: add more modules\n $?passes)))\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pathing\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-node\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-phi-node-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-strip\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-acquire\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-inject\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-acquire\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-slice\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-analyze-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-generate-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-generate-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-slice-analyze\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-merge-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-reopen-blocks\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-ponder\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-rename\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-dependency-analysis\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-advance-end\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-update\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-code::macro-expand\n ?msg <- (message (from pipeline) \n (to wavefront-scheduling-code)\n (action initial-fact))\n ?p <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?msg)\n (modify-instance ?p (passes \n wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-phi-identify\n wavefront-scheduling-phi-node \n wavefront-scheduling-phi-node-update\n wavefront-scheduling-pathing\n wavefront-scheduling-strip \n wavefront-scheduling-inject \n wavefront-scheduling-acquire \n wavefront-scheduling-slice \n wavefront-scheduling-analyze-init \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n wavefront-scheduling-rename \n wavefront-scheduling-dependency-analysis \n wavefront-scheduling-advance-init\n wavefront-scheduling-advance-identify\n wavefront-scheduling-advance\n wavefront-scheduling-advance-end\n wavefront-scheduling-update\n ;TODO: add more modules\n $?passes)))\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"21d75c68be15d19402bd40c59c2f3c8aa6d8aba9","subject":"Updated the pass manager to define wavefront-scheduling","message":"Updated the pass manager to define wavefront-scheduling\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/PassRegistry.clp","new_file":"lib\/durandal\/passes\/PassRegistry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ([loop-region-merging] of Pass\n (entry-point \"passes\/loop-region-merging\/PassHeader.clp\")\n (pass-name loop-region-merging)\n (pass-description \"Merges the loops and regions of a given function into a single logical CFG.\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes loop-region-merging)\n (required loops regions))\n ([dependency-analysis] of Pass\n (entry-point \"passes\/dependency-analysis\/PassHeader.clp\")\n (pass-name dependency-analysis)\n (pass-description \"Performs dependency analysis between instructions in a function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes dependency-analysis)\n (required loops regions))\n ([wavefront-scheduling] of Pass\n (entry-point \"passes\/wavefront-scheduling\/PassHeader.clp\")\n (pass-name wavefront-scheduling)\n (pass-description \"Performs wavefront scheduling on a target function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes wavefront-scheduling)\n (required loops regions))\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; If you want to define a group of passes to be executed without reset being\n; called in between then define a pass but do not provide an entry point and a\n; set of passes to execute in the passes multislot\n;------------------------------------------------------------------------------\n\n(definstances PersistentPassRegistry\n ([test] of Pass\n (entry-point \"passes\/test\/PassHeader.clp\")\n (pass-name test)\n (pass-description \"A test of the indirect pass system\")\n (pass-type Module)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes test)\n (required loops regions)\n (preserves-cfg TRUE)\n (preserves-all TRUE))\n ([paths] of Pass\n (entry-point \"passes\/path\/all\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n ([paths-conditional] of Pass\n (entry-point \"passes\/path\/conditional\/PassHeader.clp\")\n (pass-name paths-conditional)\n (pass-description \"Generate the set of paths through a set of target regions\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths-conditional)\n (required loops regions))\n ([loop-region-merging] of Pass\n (entry-point \"passes\/loop-region-merging\/PassHeader.clp\")\n (pass-name loop-region-merging)\n (pass-description \"Merges the loops and regions of a given function into a single logical CFG.\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes loop-region-merging)\n (required loops regions))\n ([dependency-analysis] of Pass\n (entry-point \"passes\/dependency-analysis\/PassHeader.clp\")\n (pass-name dependency-analysis)\n (pass-description \"Performs dependency analysis between instructions in a function\")\n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes dependency-analysis)\n (required loops regions))\n\n ;Add more passes here\n)\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"575cd3952aa709e808d55630915694205694d4c7","subject":"Updated DeclareLogicFunctions to use generic-load","message":"Updated DeclareLogicFunctions to use generic-load\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"init\/DeclareLogicFunctions.clp","new_file":"init\/DeclareLogicFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLogicFunctions.clp - Defines functions to load code from the\n; logic folder \n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(defgeneric init::load-logic)\n;------------------------------------------------------------------------------\n(defgeneric init::logic-files)\n;------------------------------------------------------------------------------\n(defmethod init::load-logic\n \"Loads logic\/\/Entry.clp.\" \n ((?folder-name LEXEME))\n (generic-load logic ?folder-name Entry.clp))\n;------------------------------------------------------------------------------\n(defmethod init::logic-files\n \"Loads a series of logic files from the specified path\"\n ((?offset LEXEME) \n ($?files LEXEME))\n (generic-load logic ?offset ?files))\n;------------------------------------------------------------------------------\n(defmethod init::logic-files\n \"Loads a series of logic files from the specified path\"\n ((?offset LEXEME) \n (?files LEXEME MULTIFIELD))\n (generic-load logic ?offset ?files))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLogicFunctions.clp - Defines functions to load code from the\n; logic folder \n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-logic\n \"Loads logic\/\/Entry.clp.\" \n (?folder-name)\n (batch* (format nil \"logic\/%s\/Entry.clp\" ?folder-name)))\n;------------------------------------------------------------------------------\n(deffunction init::logic-files\n \"Loads a series of logic files from the specified path\"\n (?offset $?files)\n (bind ?coreOffset (format nil \"logic\/%s\/%s\" ?offset \"%s\"))\n (progn$ (?a $?files)\n (batch* (format nil ?coreOffset ?a))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"413c03a326fb3b7fd8aafa937b46829fafa353e3","subject":"Fixed bugs in GLAPIConversion prototype expert system","message":"Fixed bugs in GLAPIConversion prototype expert system\n\nI fixed the issue with the argument splitting where the positions of some\narguments were being incorrectly calcluated\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n (modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"0040ed4ba83f8c8cced2619e3cf9011aab92a832","subject":"Update chapter-2.clp","message":"Update chapter-2.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter2\/chapter-2.clp","new_file":"ssu-ai-level-2\/chapter2\/chapter-2.clp","new_contents":"\/\/ First task\n\/\/ Students\n(deffacts students\n (student LelyakinMA 4)\n (student ArutunyaAS 4)\n (student KefalicsAI 1)\n (student BelokobylskySA 2)\n)\n\n(reset)\n(facts)\n\n(retract 2)\n(retract 3)\n\n(assert (student KefalicsAI 2))\n\n(facts)\n\n\n\/\/ Trains\n(deffacts trains\n (train 11 Saratov 11)\n (train 22 Engels 21)\n (train 33 Kazan 22)\n)\n\n(reset)\n(assert (train 44 Samara 10))\n(assert (train 55 Volgograd 08))\n\n(retract 1 4)\n\n(retract 2 3)\n\n(assert (train 22 Moscow 01))\n(assert (train 33 Kazan 00))\n\n\n\/\/ Employees\n(assert (sotrudnik LelyakinMA 1)\n (sotrudnik GerasimovVD 2)\n (sotrudnik VonnegutKG 3)\n (sotrudnik PushkinAS 3)\n)\n\n(reset)\n(retract 1)\n\n(retract 3)\n(assert (sotrudnik VasilevKD 3))\n\n\n\/\/ Products\n(assert (IceCream Russia 10 1)\n\t\t(ApelsineJuce Russia 20 2)\n\t\t(WaterMelone Russia 30 3)\n\t\t(Liberty USA 1000 99)\n)\n\n(reset)\n(facts)\n\n(retract 2)\n(ApelsineJuce Russia 19 2)\n\n(retract 4)\n(Liberty USA 0 99)\n","old_contents":"\/\/ First task\n\/\/ Students\n(deffacts students\n (student LelyakinMA 4)\n (student ArutunyaAS 4)\n (student KefalicsAI 1)\n (student BelokobylskySA 2)\n)\n\n(facts)\n\n(retract 2)\n(retract 3)\n\n(assert (student KefalicsAI 2))\n\n(facts)\n\n\n\/\/ Trains\n(deffacts trains\n (train 11 Saratov 11)\n (train 22 Engels 21)\n (train 33 Kazan 22)\n)\n\n\n(assert (train 44 Samara 10))\n(assert (train 55 Volgograd 08))\n\n(retract 1 4)\n\n(retract 2 3)\n\n(assert (train 22 Moscow 01))\n(assert (train 33 Kazan 00))\n\n\n\/\/ Employees\n(assert (sotrudnik LelyakinMA 1)\n (sotrudnik GerasimovVD 2)\n (sotrudnik VonnegutKG 3)\n (sotrudnik PushkinAS 3)\n)\n\n(retract 1)\n\n(retract 3)\n(assert (sotrudnik VasilevKD 3))\n\n\n\/\/ Products\n(assert (IceCream Russia 10 1)\n\t\t(ApelsineJuce Russia 20 2)\n\t\t(WaterMelone Russia 30 3)\n\t\t(Liberty USA 1000 99)\n)\n\n(facts)\n\n(retract 2)\n(ApelsineJuce Russia 19 2)\n\n(retract 4)\n(Liberty USA 0 99)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"35aab6e41832302c58dc365781721bf3a6bb39c9","subject":"Removed the is-macro slot from the Pass class.","message":"Removed the is-macro slot from the Pass class.\n\nThis keeps the logic of the pipeline really simple while forcing the programmer\nto pick up the slack.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (> (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n ; this slot will allow us to expand passes that consist of multiple modules\n ; before changing focus to that module. This can be set to false even if\n ; there are submodules so that the programmer can control the process\n ; themselves. This is a convience feature more than anything else.\n (slot is-macro (type SYMBOL) (allowed-symbols FALSE TRUE))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (> (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d68e1d601a0b2ba02241a10bdd1ebf8ca259263c","subject":"Simplified the pointer field in Environment","message":"Simplified the pointer field in Environment\n\nThis was done to take advantage of the composite source fact\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (role concrete)\n (slot pointer (source composite) (access initialize-only)\n (visibility public) (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"e537077835dde0ad9180b27a66936a2b77ce27dd","subject":"Modulized the GLConstantConversion expert system","message":"Modulized the GLConstantConversion expert system\n\nThis makes the set of rules cleaner by not continually relying on salience\nvalues to order the rules. The modules to it instead\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"138c298025ead62dfbf69ff646487047a344e26d","subject":"cfp and propose are now in capital letters.","message":"cfp and propose are now in capital letters.\n\n","repos":"ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror","old_file":"src\/examples\/jess\/JadeAgent.clp","new_file":"src\/examples\/jess\/JadeAgent.clp","new_contents":";\/*****************************************************************\n;JADE - Java Agent DEvelopment Framework is a framework to develop \n;multi-agent systems in ;compliance with the FIPA specifications.\n;Copyright (C) 2000 CSELT S.p.A. \n;\n;GNU Lesser General Public License\n;\n;This library is free software; you can redistribute it and\/or\n;modify it under the terms of the GNU Lesser General Public\n;License as published by the Free Software Foundation, \n;version 2.1 of the License. \n;\n;This library is distributed in the hope that it will be useful,\n;but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;Lesser General Public License for more details.\n;\n;You should have received a copy of the GNU Lesser General Public\n;License along with this library; if not, write to the\n;Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n;Boston, MA 02111-1307, USA.\n;*****************************************************************\/\n\n;\/**\n;\n;@author Fabio Bellifemine - CSELT S.p.A\n;@version $Date$ $Revision$\n;*\/\n;\n; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) \n; (slot encoding) (multislot reply-to) (slot reply-by))\n; refer to Fipa2000 (www.fipa.org) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n; (send (assert (ACLMessage (communicative-act PROPOSE) (receiver ?s) (content ?c) )))\n (assert (ACLMessage (communicative-act PROPOSE) (sender ?r) (receiver ?s) (content ?c) ))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(watch all)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","old_contents":";\/*****************************************************************\n;JADE - Java Agent DEvelopment Framework is a framework to develop \n;multi-agent systems in ;compliance with the FIPA specifications.\n;Copyright (C) 2000 CSELT S.p.A. \n;\n;GNU Lesser General Public License\n;\n;This library is free software; you can redistribute it and\/or\n;modify it under the terms of the GNU Lesser General Public\n;License as published by the Free Software Foundation, \n;version 2.1 of the License. \n;\n;This library is distributed in the hope that it will be useful,\n;but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;Lesser General Public License for more details.\n;\n;You should have received a copy of the GNU Lesser General Public\n;License along with this library; if not, write to the\n;Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n;Boston, MA 02111-1307, USA.\n;*****************************************************************\/\n\n;\/**\n;\n;@author Fabio Bellifemine - CSELT S.p.A\n;@version $Date$ $Revision$\n;*\/\n;\n; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) \n; (slot encoding) (multislot reply-to) (slot reply-by))\n; refer to Fipa2000 (www.fipa.org) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n (send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n; (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"cc907f89d1e1c96fba4b2d3666adaddb719649e3","subject":"no message","message":"no message\n\n","repos":"ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror","old_file":"src\/examples\/jess\/JadeAgent.clp","new_file":"src\/examples\/jess\/JadeAgent.clp","new_contents":";\/*****************************************************************\n;JADE - Java Agent DEvelopment Framework is a framework to develop multi-agent systems in ;compliance with the FIPA specifications.\n;Copyright (C) 2000 CSELT S.p.A. \n;\n;GNU Lesser General Public License\n;\n;This library is free software; you can redistribute it and\/or\n;modify it under the terms of the GNU Lesser General Public\n;License as published by the Free Software Foundation, \n;version 2.1 of the License. \n;\n;This library is distributed in the hope that it will be useful,\n;but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;Lesser General Public License for more details.\n;\n;You should have received a copy of the GNU Lesser General Public\n;License along with this library; if not, write to the\n;Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n;Boston, MA 02111-1307, USA.\n;*****************************************************************\/\n\n;\/**\n;\n;@author Fabio Bellifemine - CSELT S.p.A\n;@version $Date$ $Revision$\n;*\/\n;\n; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n (send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n; (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","old_contents":";\/*****************************************************************\n;JADE - Java Agent DEvelopment Framework is a framework to develop multi-agent systems in ;compliance with the FIPA specifications.\n;Copyright (C) 2000 CSELT S.p.A. \n;\n;GNU Lesser General Public License\n;\n;This library is free software; you can redistribute it and\/or\n;modify it under the terms of the GNU Lesser General Public\n;License as published by the Free Software Foundation, \n;version 2.1 of the License. \n;\n;This library is distributed in the hope that it will be useful,\n;but WITHOUT ANY WARRANTY; without even the implied warranty of\n;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;Lesser General Public License for more details.\n;\n;You should have received a copy of the GNU Lesser General Public\n;License along with this library; if not, write to the\n;Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n;Boston, MA 02111-1307, USA.\n;*****************************************************************\/\n\n;\/**\n;Javadoc documentation for the file\n;@author Giovanni Rimassa - Universita` di Parma\n;@version $Date$ $Revision$\n;*\/\n;\n; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n (send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n; (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"514be0edee6584c623fef32d61272f8fe5c67b70","subject":"Added parsing support for glu.h","message":"Added parsing support for glu.h\n\nI have already tested the code and each file is generates itself separately.\nThis is due to the \"continuation\" behavior that the MAIN module demonstrates\nthrough the use of the focus command. The MAIN module is pushed onto the stack\nfirst before the other modules. This allows any other parse facts to be\nprocessed and the procedure to occur again.\n\nThis make the process of conversion very automated.\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/RunGLAPIConverter.clp","new_file":"src\/tools\/conv\/gl\/RunGLAPIConverter.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunGLAPIConversion.clp - Runs the GLAPIConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n(batch* GLAPIConversionEntry.clp)\n(reset)\n;Input format is the same as the constant conversion expert system\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\")\n\t\t (parse constant file \"\/usr\/include\/GL\/glu.h\"))\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; RunGLAPIConversion.clp - Runs the GLAPIConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(clear)\n(batch* GLAPIConversionEntry.clp)\n(reset)\n;Input format is the same as the constant conversion expert system\n(assert (parse constant file \"\/usr\/include\/GL\/gl.h\"))\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"a3d380e73acb60239619b5ed9c21d135b56e2ba9","subject":"Added a existence check to MarkNonLocalDependencies to prevent an infinite loop","message":"Added a existence check to MarkNonLocalDependencies to prevent an infinite loop\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (if (not (member$ ?o $?nld)) then\n (modify-instance ?inst (NonLocalDependencies $?nld ?o))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"49067a7b5227e4cb41986a629c2b49b365c965c6","subject":"Fixed some compilation errors in GLAPIConversion.clp","message":"Fixed some compilation errors in GLAPIConversion.clp\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defrule types::FunctionBuilder\n\t\t\t\"Builds C functions\"\n\t\t\t(is-a Object)\n\t\t\t(multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-contents ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n (declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t (parent ?p) \n\t\t\t\t\t\t\t (index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t(parent ?p)\n\t\t\t\t(contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n ?fct <- (message (to grouping-update)\n\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"2e037b5f450cd6e0c2455b14d51576921c28b87c","subject":"update knowledge","message":"update knowledge\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \ud83c\udf76\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n \"Classic topping pizzas pair well with crisp and clean beers.\"\n \"Meat topping pizzas pair well with hoppy and bitter beers.\"\n \"Vegetables.\"\n \"Cheese topping pizzas pair well with fruity and spicy beers.\"))\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and\n \"have a very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \ud83e\uddc0\")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \ud83e\uddc0\")\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entr\u00e9e-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83d\udc1f\ud83e\udd90 _Fish_ pair well with the bitterness of the \"\n \"English-Style Bitter and the sweetness of the \"\n \"English-Style Pale Ale.\")\n (str-cat \"\ud83e\udd69\ud83c\udf56 _Meat_ pairs well with Scottish-Style Ales.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd5c With _fats_ strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entr\u00e9e-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd51 _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entr\u00e9e-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \"\ud83c\udf31 _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \"\ud83c\udf46\ud83e\udd66 _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \"\ud83e\udd51 _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \ud83e\udd91\ud83d\udc19\ud83e\udd90\ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \ud83e\udd91\ud83d\udc19\")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \ud83e\udd90\")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers <=18 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \ud83c\udf76\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 _Fresh_ cheeses have not been aged, or are very slightly cured. These \"\n \"cheeses have a high moisture content and are usually mild and have a \"\n \"very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \ud83e\uddc0\")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \ud83e\uddc0\")\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entr\u00e9e-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entr\u00e9e-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entr\u00e9e-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83c\udf3e Complementary _grain_ flavors balance hops while remaining light on the \"\n \"palate.\")\n (str-cat \"\ud83c\udf31 _Beans_ add richness to the beer while balancing salt and acidity.\")\n (str-cat \"\ud83e\udd90\ud83e\udd80 With _shellfish_ foods beers need to bring out salinity and natural \"\n \"sweetness while cleansing the palate.\")\n (str-cat \"\ud83e\udd69\ud83e\udd55 _Rich_ _meats_ and _root_ _vegetables_ flavors brings out umami and adds earthy \"\n \"notes that rest on the center of the palate.\")\n (str-cat \"\ud83e\udd86\ud83e\udd83 _Game_ _birds_ roastiness and fat coats help neutralize hop bitterness. \")\n (str-cat \"\ud83e\udd5c With _fats_ strong flavors, beer balances and allows for a complex finish.\")\n (str-cat \"\ud83c\udf46\ud83c\udf44 _Grilled_ _vegetables_ brings out umami and balances sweetnees and richness.\")\n (str-cat \"\ud83e\uddc0 Beer complements the natural flavor and textures of _cheese_ while cutting \"\n \"through fat, cleansing the palate.\")\n (str-cat \"\ud83e\udd58\ud83c\udf6b With _braised_ _meats_ and _chocolate_, beer highlights the roasted character.\")\n (str-cat \"\ud83c\udf56 The intensity of the _pork_ fat stands up to the strong beer characteristics.\")\n (str-cat \"\ud83c\udf68\ud83c\udf6e Beer balances richness on the palate so the _dessert_ doesn't finish cloyingly.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \ud83e\udd91\ud83d\udc19\ud83e\udd90\ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \ud83e\udd91\ud83d\udc19\")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \ud83e\udd90\")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse non-animal fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n\n;(defrule determine-predominant-dish-taste\n; (start)\n; =>\n; (assert (UI-state (display \"Which is the predominant taste of the dish?\")\n; (relation-asserted predominant-dish-taste)\n; (valid-answers sweet acid spice umami \"not tasted yet\"))))\n\n;(defrule determine-dish-cooking-method\n; (start)\n; =>\n; (assert (UI-state (display (str-cat \"Is the dish cooking method dry-heat (broiling, grilling, roasting, baking, \"\n; \"saut\u00e9ing, pan-frying, deep-frying), moist-heat (poaching, simmering, boiling, \"\n; \"steaming) or it is a combination of both (braising, stewing)?\"))\n; (relation-asserted dish-cooking-method)\n; (valid-answers dry-heat moist-heat combination \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"0685ff004c7fb6d9815e0b70e5820ec83c798e98","subject":"No use","message":"No use\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"nouse.clp","new_file":"nouse.clp","new_contents":"sdfsdfdgdfgdgdfgdf\ngsd\ngfsdf\nsd\nfsdf\nsdfsdfdgdfgdgdfgdfsdgfsd\n\ndfgd\ngdfgd\nfgdf\ngdfgddf\n\ndfgsdf\ndfgsdfdfgd\n\ndgdfg\ndfgsdfdfgddfg\ndfgsdfdfgddfggd\nfgdfdsf","old_contents":"","returncode":1,"stderr":"error: pathspec 'nouse.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"75dd9a3893b3f27b1cfe5675ae8c6f2131d6aa7d","subject":"Create task2.clp","message":"Create task2.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task2.clp","new_file":"ssu-ai-level-2\/chapter6\/task2.clp","new_contents":"(deffunction triangle (?a ?b ?c)\n (bind ?p (\/ (+ ?a ?b ?c) 2))\n (sqrt (* ?p (- ?p ?a) (- ?p ?b) (- ?p ?c)))\n)\n\n\n\n;(deffunction compare-triangles (?a1 ?b1 ?c1 ?a2 ?b2 ?c2)\n; (> (triangle ?a1 ?b1 ?c1) (triangle ?a2 ?b2 ?c2))\n;)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"93a5aa6744c862a34eef7d92b8fd334f383acb29","subject":"adding a new sample to test assert and retract.","message":"adding a new sample to test assert and retract.\n\npeter\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@518 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/join_sample15.clp","new_file":"samples\/join_sample15.clp","new_contents":"(deftemplate transaction\r\n (slot accountId (type STRING))\r\n (slot buyPrice (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n (slot currentPrice (type DOUBLE))\r\n (slot cusip (type INTEGER))\r\n (slot exchange (type STRING))\r\n (slot industryGroupID (type INTEGER))\r\n (slot industryID (type INTEGER))\r\n (slot issuer (type STRING))\r\n (slot lastPrice (type DOUBLE))\r\n (slot purchaseDate (type STRING))\r\n (slot sectorID (type INTEGER))\r\n (slot shares (type DOUBLE))\r\n (slot subIndustryID (type INTEGER))\r\n (slot total (type DOUBLE))\r\n)\r\n(deftemplate account\r\n (slot accountId (type STRING))\r\n (slot cash (type DOUBLE))\r\n (slot fixedIncome (type DOUBLE))\r\n (slot stocks (type DOUBLE))\r\n (slot countryCode (type STRING))\r\n)\r\n(deftemplate rating\r\n (slot cusip (type INTEGER))\r\n (slot issuer (type STRING))\r\n)\r\n(defrule joinrule2\r\n (transaction\r\n (accountId ?accid)\r\n (countryCode \"US\")\r\n (issuer ?iss)\r\n )\r\n (rating\r\n (issuer ?iss)\r\n )\r\n (account\r\n (accountId ?accid)\r\n )\r\n=>\r\n (printout t \"joinrule2 was fired\" )\r\n)\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101015)(issuer \"MSFT\") ) )\r\n(assert (rating (cusip 10101025)(issuer \"MSFT\") ) )\r\n(assert (transaction (accountId \"acc1\")(countryCode \"US\")(total 1298.00)(cusip 10101010)(issuer \"IBM\") ) )\r\n(assert (rating (cusip 10101020)(issuer \"IBM\") ) )\r\n(assert (account (accountId \"acc1\")(cash 1200000) ) )\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/join_sample15.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"eaf210208e8de523a6ba21f92a2790a932f3e1e5","subject":"Improved performance of redraw mechanism","message":"Improved performance of redraw mechanism\n\nOnly the tiles that have been modified are updated. I also added support for\nvariable resolution sizes.\n","repos":"DrItanium\/catharsis","old_file":"worldly.clp","new_file":"worldly.clp","new_contents":"; Entry point into worldly \n; Modify this to fit your system.\n(batch* (proton: \/lib\/core.clp))\n(batch* (proton: \/lib\/neutron.clp))\n; begin worldly \n(defclass pixel\n \"Represents a location on a map\"\n (is-a USER)\n (slot update\n (type SYMBOL)\n (storage local)\n (allowed-symbols FALSE TRUE))\n (slot position-x\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot position-y\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot type \n (type SYMBOL)\n (allowed-symbols empty solid))\n (slot color\n (type SYMBOL)\n (default-dynamic black)))\n\n(defglobal MAIN\n ?*block-width* = 32\n ?*block-height* = 32\n ?*screen-width* = (screen\/dimensions\/width)\n ?*screen-height* = (screen\/dimensions\/height)\n ?*blocks-wide* = (div ?*screen-width* ?*block-width*)\n ?*blocks-tall* = (div ?*screen-height* ?*block-height*)\n ?*block-count* = (* ?*blocks-wide* ?*blocks-tall*))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit))\n (bind ?*screen-width* (screen\/dimensions\/width))\n (bind ?*screen-height* (screen\/dimensions\/height))\n (bind ?*blocks-wide* (div ?*screen-width* ?*block-width*))\n (bind ?*blocks-tall* (div ?*screen-height* ?*block-height*))\n (bind ?*block-count* (* ?*blocks-wide* ?*blocks-tall*))\n (do-for-all-instances ((?pixel pixel)) \n (and (<= 0 (send ?pixel get-position-x)\n (- ?*blocks-wide* 1))\n (<= 0 (send ?pixel get-position-y) ?*blocks-tall*))\n (send ?pixel put-update TRUE))\n (modify-instance [screen-dim] (bx ?*screen-width*) (by ?*screen-height*))\n (send [screen-dim] build-pointer)\n (screen\/draw [screen-dim] [screen] [ZP])\n (assert (layout pixels)))\n\n\n\n(definstances screen-pieces \n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (screen-dim of rectangle (x 0) (y 0) \n (bx ?*screen-width*) \n (by ?*screen-height*))\n (block of rectangle (x 0) (y 0) \n (bx ?*block-width*) \n (by ?*block-height*))\n (screen of image (rectangle [screen-dim])\n (replicate TRUE)\n (color (get-standard-color grey)))\n (solid-pixel of image \n (rectangle [block])\n (replicate TRUE)\n (color (get-standard-color black)))\n (empty-pixel of image \n (rectangle [block])\n (replicate TRUE)\n (color (get-standard-color blue))))\n(deffacts query-operation\n (query input)\n (screen ?*blocks-wide* ?*blocks-tall*))\n\n\n(defrule setup-pixels\n \"Create the pixels we are going to use to represent the screen\"\n (declare (salience 10000))\n ?f <- (screen ?w ?h)\n =>\n (retract ?f)\n (loop-for-count (?x 0 (- ?w 1)) do\n (loop-for-count (?y 0 ?h) do\n (make-instance of pixel \n (position-x ?x)\n (position-y ?y)\n (type (if (= ?x ?y 0) then empty else solid))))))\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:left\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys LEFT))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (> ?x 0))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-x ?bx&:(= ?bx (- ?x 1)))\n (position-y ?y))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid)\n (update TRUE))\n (modify-instance ?next (type empty)\n (update TRUE))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:right\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys RIGHT))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (< ?x ?*blocks-wide*))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-x ?bx&:(= ?bx (+ ?x 1)))\n (position-y ?y))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid)\n (update TRUE))\n (modify-instance ?next (type empty)\n (update TRUE))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (> ?y 0))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-y ?by&:(= ?by (- ?y 1)))\n (position-x ?x))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid) (update TRUE))\n (modify-instance ?next (type empty) (update TRUE))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (< ?y ?*blocks-tall*))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-y ?by&:(= ?by (+ ?y 1)))\n (position-x ?x))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid) (update TRUE))\n (modify-instance ?next (type empty) (update TRUE))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n(defrule relayout:image\n (declare (salience 9999))\n (layout pixels)\n ?pixel <- (object (is-a pixel)\n (update TRUE)\n (type ?z)\n (position-x ?x)\n (position-y ?y))\n (object (is-a rectangle)\n (name [block])\n (bx ?bx)\n (by ?by))\n =>\n (send ?pixel put-update FALSE)\n (modify-instance [scratch-rect] \n (x (* ?bx ?x))\n (y (* ?by ?y))\n (bx (* ?bx (+ ?x 1)))\n (by (* ?by (+ ?y 1))))\n (send [scratch-rect] build-pointer)\n (screen\/draw [scratch-rect] \n (symbol-to-instance-name (sym-cat ?z -pixel)) [ZP]))\n\n(defrule relayout:image:done\n (declare (salience 9998))\n ?f <- (layout pixels)\n =>\n (retract ?f))\n\n(batch* (proton: \/lib\/reset-run-exit.clp))\n","old_contents":"; Entry point into worldly \n; Modify this to fit your system.\n(batch* (proton: \/lib\/core.clp))\n(batch* (proton: \/lib\/neutron.clp))\n; begin worldly \n(defclass pixel\n \"Represents a location on a map\"\n (is-a USER)\n (slot position-x\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot position-y\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot type \n (type SYMBOL)\n (allowed-symbols empty solid))\n (slot color\n (type SYMBOL)\n (default-dynamic black)))\n\n(defglobal MAIN\n ?*block-width* = 32\n ?*block-height* = 32\n ?*screen-width* = 512\n ?*screen-height* = 384\n ?*blocks-wide* = (\/ ?*screen-width* ?*block-width*)\n ?*blocks-tall* = (\/ ?*screen-height* ?*block-height*)\n ?*block-count* = (* ?*blocks-wide* ?*blocks-tall*))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit))\n (screen\/draw [screen-dim] [screen] [ZP])\n (assert (layout pixels)))\n\n\n\n(definstances screen-pieces \n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (screen-dim of rectangle (x 0) (y 0) \n (bx ?*screen-width*) \n (by ?*screen-height*))\n (block of rectangle (x 0) (y 0) \n (bx ?*block-width*) \n (by ?*block-height*))\n (screen of image (rectangle [screen-dim])\n (replicate TRUE)\n (color (get-standard-color grey)))\n (solid-pixel of image \n (rectangle [block])\n (replicate TRUE)\n (color (get-standard-color black)))\n (empty-pixel of image \n (rectangle [block])\n (replicate TRUE)\n (color (get-standard-color blue))))\n(deffacts query-operation\n (query input)\n (screen ?*blocks-wide* ?*blocks-tall*))\n\n\n(defrule setup-pixels\n \"Create the pixels we are going to use to represent the screen\"\n (declare (salience 10000))\n ?f <- (screen ?w ?h)\n =>\n (retract ?f)\n (loop-for-count (?x 0 (- ?w 1)) do\n (loop-for-count (?y 0 ?h) do\n (make-instance of pixel \n (position-x ?x)\n (position-y ?y)\n (type (if (= ?x ?y 0) then empty else solid))))))\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:left\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys LEFT))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (> ?x 0))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-x ?bx&:(= ?bx (- ?x 1)))\n (position-y ?y))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid))\n (modify-instance ?next (type empty))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:right\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys RIGHT))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (< ?x ?*blocks-wide*))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-x ?bx&:(= ?bx (+ ?x 1)))\n (position-y ?y))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid))\n (modify-instance ?next (type empty))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (> ?y 0))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-y ?by&:(= ?by (- ?y 1)))\n (position-x ?x))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid))\n (modify-instance ?next (type empty))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?old <- (object (is-a pixel)\n (type empty)\n (position-x ?x)\n (position-y ?y))\n (test (< ?y ?*blocks-tall*))\n ?next <- (object (is-a pixel)\n (type solid)\n (position-y ?by&:(= ?by (+ ?y 1)))\n (position-x ?x))\n\n =>\n (retract ?f)\n (modify-instance ?old (type solid))\n (modify-instance ?next (type empty))\n (assert (query keyboard)\n (layout pixels)))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n(defrule relayout:image\n (declare (salience 9999))\n (layout pixels)\n (object (is-a pixel)\n (type ?z)\n (position-x ?x)\n (position-y ?y))\n (object (is-a rectangle)\n (name [block])\n (bx ?bx)\n (by ?by))\n =>\n (modify-instance [scratch-rect] \n (x (* ?bx ?x))\n (y (* ?by ?y))\n (bx (* ?bx (+ ?x 1)))\n (by (* ?by (+ ?y 1))))\n (send [scratch-rect] build-pointer)\n (screen\/draw [scratch-rect] \n (symbol-to-instance-name (sym-cat ?z -pixel)) [ZP]))\n\n(defrule relayout:image:done\n (declare (salience 9998))\n ?f <- (layout pixels)\n =>\n (retract ?f))\n\n(batch* (proton: \/lib\/reset-run-exit.clp))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"ebc740e61630317bdcf146ec88e25f1c6677122c","subject":"update beer-knowledge.clp","message":"update beer-knowledge.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-knowledge.clp","new_file":"clips\/beer-knowledge.clp","new_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-which-sex-is-male\n (declare (salience ?*medium-low-priority*))\n (which-sex male)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-color) (value brown) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-color) (value dark) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're a man, so you'll appreciate more alcoholic \"\n \"beers, maybe with a stronger flavor, such as bitter and sour.\")))))\n\n(defrule determine-best-beer-attributes-if-which-sex-is-female\n (declare (salience ?*medium-low-priority*))\n (which-sex female)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-color) (value amber) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-color) (value pale) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're a woman, so you'll appreciate beers with less \"\n \"noticeable alcohol, maybe with a cleaner or sweeter flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-18-23\n (declare (salience ?*medium-low-priority*))\n (which-age 18-23)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Being so young, you should not appreciate strong \"\n \"flavors or high quantities of alcohol, so I bet you won't be disappointed with these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-24-29\n (declare (salience ?*medium-low-priority*))\n (which-age 24-29)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Your age let me choose between a variety of beers \"\n \"with high tolerance in every aspect.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-more-or-equal-than-30\n (declare (salience ?*medium-low-priority*))\n (which-age >=30)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Your palate could be very demanding: I bet you would \"\n \"try out something peculiar.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-autumn\n (declare (salience ?*medium-low-priority*))\n (which-season autumn)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Cold and rainy days are perfect to taste a little \"\n \"more alcoholic beer than the average, with a more particular flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-spring\n (declare (salience ?*medium-low-priority*))\n (which-season spring)\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Spring days are perfect to taste beers with clean \"\n \"or spicy flavor, without the clash of too much alcohol.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-summer\n (declare (salience ?*medium-low-priority*))\n (which-season summer)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Hotter days are perfect to taste beers with a slight \"\n \"sense of alcohol, with a clean fresh flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-winter\n (declare (salience ?*medium-low-priority*))\n (which-season winter)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Frosty days are perfect to taste something sweet or \"\n \"roasty, that strongly change your palate. Also, high alcoholic beers can heat you up.\")))))\n\n(defrule determine-best-beer-attributes-if-he-is-not-a-regular-beer-drinker\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're supposed to start with standard aromas; \"\n \"afterwards, you'll be ready for something more peculiar.\")))))\n\n(defrule determine-best-beer-attributes-if-he-is-going-to-smoke\n (declare (salience ?*medium-low-priority*))\n (smoker yes)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name best-color) (value pale) (certainty 0.07)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Beers with a cleaner flavor may be the good choice \"\n \"while smoking, because the beer may alter the taste of tobacco. Anyway, strong beers pair well with tobacco \"\n \"flavor.\")))))\n\n; determine best beer attributes for personal preferences recognized\n\n(defrule preferred-color-is-pale\n (declare (salience ?*medium-low-priority*))\n (preferred-color pale)\n =>\n (assert (attribute (name best-color) (value pale) (certainty 0.2)))\n (assert (attribute (name best-color) (value brown) (certainty -0.1)))\n (assert (attribute (name best-color) (value dark) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You prefer a pale beer.\"))))\n\n(defrule preferred-color-is-amber\n (declare (salience ?*medium-low-priority*))\n (preferred-color amber)\n =>\n (assert (attribute (name best-color) (value amber) (certainty 0.2)))\n (assert (attribute (name best-color) (value dark) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You prefer an amber beer.\"))))\n\n(defrule preferred-color-is-brown\n (declare (salience ?*medium-low-priority*))\n (preferred-color brown)\n =>\n (assert (attribute (name best-color) (value brown) (certainty 0.2)))\n (assert (attribute (name best-color) (value pale) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You prefer a brown beer.\"))))\n\n(defrule preferred-color-is-dark\n (declare (salience ?*medium-low-priority*))\n (preferred-color dark)\n =>\n (assert (attribute (name best-color) (value dark) (certainty 0.2)))\n (assert (attribute (name best-color) (value amber) (certainty -0.1)))\n (assert (attribute (name best-color) (value pale) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You prefer a dark beer.\"))))\n\n\n(defrule preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty -0.1)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You chose a low alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You chose a medium alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You chose a high alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value mild) (certainty -0.1)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You chose a very high alcoholic beer.\"))))\n\n(defrule preferred-carbonation-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation low)\n =>\n (assert (attribute (name best-carbonation) (value low) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value high) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a low carbonated beer.\"))))\n\n(defrule preferred-carbonation-is-medium\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation medium)\n =>\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a medium carbonated beer.\"))))\n\n(defrule preferred-carbonation-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation high)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value low) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a high carbonated beer.\"))))\n\n(defrule preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a clean flavor.\"))))\n\n(defrule preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a sweet flavor.\"))))\n\n(defrule preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a bitter flavor.\"))))\n\n(defrule preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a roasty flavor.\"))))\n\n(defrule preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (or (preferred-flavor fruity)\n (preferred-flavor spicy))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a fruity flavor.\"))))\n\n(defrule preferred-flavor-is-sour\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sour)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a sour flavor.\"))))\n\n; determine best beer attributes for meal type recognized\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (pizza-topping classic)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a classic pizza: the best way to enjoy \"\n \"it is pair that with beers that have a very delicate impact on the palate and can sometimes produce a \"\n \"feeling of dryness in the mouth, creating an overall delicate outcome.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with meat: the best way to \"\n \"enjoy it is pair that with beers with a bitter flavor, because of the bitterness of the hops that pleasantly \"\n \"cleanses the mouth.\")))))\n\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with spicy meat: the best way \"\n \"to enjoy it is pair that with beers with a sweet flavor, thanks to the prevalent sense of maltiness on the \"\n \"palate.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with vegetables: the best way \"\n \"to enjoy it is pair that with beers with a sour flavor, because of the pronounced acidity blended on the \"\n \"palate with the addition of fruity aromas.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with roasted vegetables: the \"\n \"best way to enjoy it is pair that with beers with a roasty flavor, thanks to the roast of the malt that \"\n \"comes through strong and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-cheese\n (declare (salience ?*medium-low-priority*))\n (pizza-topping cheese)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with cheese: the best way to \"\n \"enjoy it is pair that with beers with a spicy flavor, derived from the yeast and dominated by notes of fruit \"\n \"and spice like tart apple, pear, peach, orange, lemon, apricot and clove, pepper, vanilla, coriander, \"\n \"cinnamon, nutmeg, bay leaf.\")))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fresh cheeses are light cheeses \"\n \"which pair excellently with naturally and spontaneously fermented beers with important sweetnees and \"\n \"sourness characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because semi-soft cheeses can be paired \"\n \"with many different craft beers, best of all beers which presents caramel or toasted malt flavor, and also \"\n \"medium to high bitterness.\")))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 0.8)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because firm\/hard cheeses are easily \"\n \"paired with beers that typically have an extremely rich malty flavor and aroma with full, sweet malt \"\n \"character. Perception of hop bitterness is medium to high; roasted malt, caramel-like and chocolate-like \"\n \"characters could also be perceived.\")))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because blue cheeses are stronger-flavored \"\n \"cheeses which are most successfully balanced with stonger-flavored bolder beers with a roasty flavor, thanks \"\n \"to the roast of the malt that comes through strong and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because natural rind cheeses pair well \"\n \"with many different craft beers, best of all beers which presents caramel or toffee malt character, and also \"\n \"medium to high bitterness.\")))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Creme\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because washed rind cheeses, while \"\n \"potentially pungent, are often creamy and can be paired with beers that presents caramel or toasted malt \"\n \"aromas, with fruity or spicy characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e grain)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because grain pair generally well with \"\n \"beers that have a very delicate impact on the palate and can sometimes produce a feeling of dryness in the \"\n \"mouth, creating an overall delicate outcome.\")))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e legumes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because legumes pair generally well with \"\n \"a sweet flavor, thanks to the prevalent sense of maltiness on the palate.\")))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fish pair generally well with \"\n \"beers which presents medium to high hop bitterness, flavor and aroma in order to cleanse the mouth.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because meat pair well with beers that \"\n \"typically have malt-forward character, with a rich and dominant sweet, caramel-like malt flavor and aroma.\")))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method braised)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5)))\n (assert (attribute (name explanation-specific-meal) (value (str-cat \"Moreover, rich meats comes together with beers \"\n \"that presents pronounced acidity.\")))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich pork)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name explanation-specific-meal) (value (str-cat \"Moreover, game birds pair excellently well with \"\n \"beers which presents medium to high hop bitterness, flavor and aroma in order to cleanse the mouth.\")))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e vegetables)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because vegetables pair generally well \"\n \"with beers that are characterized by malty aroma and slight malt sweetness with caramel-like and \"\n \"chocolate-like characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fats)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fats pair generally well with \"\n \"beers with a bitter flavor, because of the bitterness of the hops that pleasantly cleanses the mouth, and \"\n \"also with beers characterized by a roasty flavor, thanks to the roast of the malt that comes through strong \"\n \"and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (which-fats vegetable)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.5)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value low) (certainty -0.5))))\n\n(defrule determine-best-beer-attributes-if-creamy-dessert-is-fruit\n (declare (salience ?*medium-low-priority*))\n (creamy-dessert-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because desserts pair particularly well \"\n \"with beers that presents an overwhelmingly malty, rich and dominant sweet malt flavor and aroma and soft \"\n \"and chewy mouthfeel.\")))))\n\n(defrule determine-best-beer-attributes-if-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (which-dessert chocolate)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because chocolate pair well with beers \"\n \"with a sweet flavor, thanks to the prevalent sense of maltiness on the palate, and also with beers which \"\n \"presents a roasty flavor, thanks to the roast of the malt that comes through strong and can produce a \"\n \"delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter\n (declare (salience ?*medium-low-priority*))\n (which-chocolate unsweetened\/bitter)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))","old_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-which-sex-is-male\n (declare (salience ?*medium-low-priority*))\n (which-sex male)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-color) (value brown) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-color) (value dark) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're a man, so you'll appreciate more alcoholic \"\n \"beers, maybe with a stronger flavor, such as bitter and sour.\")))))\n\n(defrule determine-best-beer-attributes-if-which-sex-is-female\n (declare (salience ?*medium-low-priority*))\n (which-sex female)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-color) (value amber) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-color) (value pale) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're a woman, so you'll appreciate beers with less \"\n \"noticeable alcohol, maybe with a cleaner or sweeter flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-18-23\n (declare (salience ?*medium-low-priority*))\n (which-age 18-23)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Being so young, you should not appreciate strong \"\n \"flavors or high quantities of alcohol, so I bet you won't be disappointed with these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-24-29\n (declare (salience ?*medium-low-priority*))\n (which-age 24-29)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Your age let me choose between a variety of beers \"\n \"with high tolerance in every aspect.\")))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-more-or-equal-than-30\n (declare (salience ?*medium-low-priority*))\n (which-age >=30)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Your palate could be very demanding: I bet you would \"\n \"try out something peculiar.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-autumn\n (declare (salience ?*medium-low-priority*))\n (which-season autumn)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Cold and rainy days are perfect to taste a little \"\n \"more alcoholic beer than the average, with a more particular flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-spring\n (declare (salience ?*medium-low-priority*))\n (which-season spring)\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Spring days are perfect to taste beers with clean \"\n \"or spicy flavor, without the clash of too much alcohol.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-summer\n (declare (salience ?*medium-low-priority*))\n (which-season summer)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Hotter days are perfect to taste beers with a slight \"\n \"sense of alcohol, with a clean fresh flavor.\")))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-winter\n (declare (salience ?*medium-low-priority*))\n (which-season winter)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Frosty days are perfect to taste something sweet or \"\n \"roasty, that strongly change your palate. Also, high alcoholic beers can heat you up.\")))))\n\n(defrule determine-best-beer-attributes-if-he-is-not-a-regular-beer-drinker\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"You're supposed to start with standard aromas; \"\n \"afterwards, you'll be ready for something more peculiar.\")))))\n\n(defrule determine-best-beer-attributes-if-he-is-going-to-smoke\n (declare (salience ?*medium-low-priority*))\n (smoker yes)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name best-color) (value pale) (certainty 0.07)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.05)))\n (assert (attribute (name explanation-scenario) (value (str-cat \"Beers with a cleaner flavor may be the good choice \"\n \"while smoking, because the beer may alter the taste of tobacco. Anyway, strong beers pair well with tobacco \"\n \"flavor.\")))))\n\n; determine best beer attributes for personal preferences recognized\n\n(defrule preferred-color-is-pale\n (declare (salience ?*medium-low-priority*))\n (preferred-color pale)\n =>\n (assert (attribute (name best-color) (value pale) (certainty 0.2)))\n (assert (attribute (name best-color) (value brown) (certainty -0.1)))\n (assert (attribute (name best-color) (value dark) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You prefere a pale beer.\"))))\n\n(defrule preferred-color-is-amber\n (declare (salience ?*medium-low-priority*))\n (preferred-color amber)\n =>\n (assert (attribute (name best-color) (value amber) (certainty 0.2)))\n (assert (attribute (name best-color) (value dark) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You prefere an amber beer.\"))))\n\n(defrule preferred-color-is-brown\n (declare (salience ?*medium-low-priority*))\n (preferred-color brown)\n =>\n (assert (attribute (name best-color) (value brown) (certainty 0.2)))\n (assert (attribute (name best-color) (value pale) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You prefere a brown beer.\"))))\n\n(defrule preferred-color-is-dark\n (declare (salience ?*medium-low-priority*))\n (preferred-color dark)\n =>\n (assert (attribute (name best-color) (value dark) (certainty 0.2)))\n (assert (attribute (name best-color) (value amber) (certainty -0.1)))\n (assert (attribute (name best-color) (value pale) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You prefere a dark beer.\"))))\n\n\n(defrule preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty -0.1)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You chose a low alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You chose a medium alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty -0.1)))\n (assert (attribute (name explanation-preference) (value \"You chose a high alcoholic beer.\"))))\n\n(defrule preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.2)))\n (assert (attribute (name best-alcohol) (value mild) (certainty -0.1)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You chose a very high alcoholic beer.\"))))\n\n(defrule preferred-carbonation-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation low)\n =>\n (assert (attribute (name best-carbonation) (value low) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value high) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a low carbonated beer.\"))))\n\n(defrule preferred-carbonation-is-medium\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation medium)\n =>\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a medium carbonated beer.\"))))\n\n(defrule preferred-carbonation-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation high)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value low) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"It's a high carbonated beer.\"))))\n\n(defrule preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a clean flavor.\"))))\n\n(defrule preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a sweet flavor.\"))))\n\n(defrule preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a bitter flavor.\"))))\n\n(defrule preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a roasty flavor.\"))))\n\n(defrule preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (or (preferred-flavor fruity)\n (preferred-flavor spicy))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.2)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a fruity flavor.\"))))\n\n(defrule preferred-flavor-is-sour\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sour)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.2)))\n (assert (attribute (name explanation-preference) (value \"You desire a beer with a sour flavor.\"))))\n\n; determine best beer attributes for meal type recognized\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (pizza-topping classic)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a classic pizza: the best way to enjoy \"\n \"it is pair that with beers that have a very delicate impact on the palate and can sometimes produce a \"\n \"feeling of dryness in the mouth, creating an overall delicate outcome.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with meat: the best way to \"\n \"enjoy it is pair that with beers with a bitter flavor, because of the bitterness of the hops that pleasantly \"\n \"cleanses the mouth.\")))))\n\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with spicy meat: the best way \"\n \"to enjoy it is pair that with beers with a sweet flavor, thanks to the prevalent sense of maltiness on the \"\n \"palate.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with vegetables: the best way \"\n \"to enjoy it is pair that with beers with a sour flavor, because of the pronounced acidity blended on the \"\n \"palate with the addition of fruity aromas.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with roasted vegetables: the \"\n \"best way to enjoy it is pair that with beers with a roasty flavor, thanks to the roast of the malt that \"\n \"comes through strong and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-cheese\n (declare (salience ?*medium-low-priority*))\n (pizza-topping cheese)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"You're eating a pizza with cheese: the best way to \"\n \"enjoy it is pair that with beers with a spicy flavor, derived from the yeast and dominated by notes of fruit \"\n \"and spice like tart apple, pear, peach, orange, lemon, apricot and clove, pepper, vanilla, coriander, \"\n \"cinnamon, nutmeg, bay leaf.\")))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fresh cheeses are light cheeses \"\n \"which pair excellently with naturally and spontaneously fermented beers with important sweetnees and \"\n \"sourness characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because semi-soft cheeses can be paired \"\n \"with many different craft beers, best of all beers which presents caramel or toasted malt flavor, and also \"\n \"medium to high bitterness.\")))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 0.8)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because firm\/hard cheeses are easily \"\n \"paired with beers that typically have an extremely rich malty flavor and aroma with full, sweet malt \"\n \"character. Perception of hop bitterness is medium to high; roasted malt, caramel-like and chocolate-like \"\n \"characters could also be perceived.\")))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because blue cheeses are stronger-flavored \"\n \"cheeses which are most successfully balanced with stonger-flavored bolder beers with a roasty flavor, thanks \"\n \"to the roast of the malt that comes through strong and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because natural rind cheeses pair well \"\n \"with many different craft beers, best of all beers which presents caramel or toffee malt character, and also \"\n \"medium to high bitterness.\")))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Creme\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because washed rind cheeses, while \"\n \"potentially pungent, are often creamy and can be paired with beers that presents caramel or toasted malt \"\n \"aromas, with fruity or spicy characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e grain)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because grain pair generally well with \"\n \"beers that have a very delicate impact on the palate and can sometimes produce a feeling of dryness in the \"\n \"mouth, creating an overall delicate outcome.\")))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e legumes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because legumes pair generally well with \"\n \"a sweet flavor, thanks to the prevalent sense of maltiness on the palate.\")))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fish pair generally well with \"\n \"beers which presents medium to high hop bitterness, flavor and aroma in order to cleanse the mouth.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because meat pair well with beers that \"\n \"typically have malt-forward character, with a rich and dominant sweet, caramel-like malt flavor and aroma.\")))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method braised)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5)))\n (assert (attribute (name explanation-specific-meal) (value (str-cat \"Moreover, rich meats comes together with beers \"\n \"that presents pronounced acidity.\")))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty -0.5)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich pork)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name explanation-specific-meal) (value (str-cat \"Moreover, game birds pair excellently well with \"\n \"beers which presents medium to high hop bitterness, flavor and aroma in order to cleanse the mouth.\")))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e vegetables)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.8)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because vegetables pair generally well \"\n \"with beers that are characterized by malty aroma and slight malt sweetness with caramel-like and \"\n \"chocolate-like characters.\")))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fats)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because fats pair generally well with \"\n \"beers with a bitter flavor, because of the bitterness of the hops that pleasantly cleanses the mouth, and \"\n \"also with beers characterized by a roasty flavor, thanks to the roast of the malt that comes through strong \"\n \"and can produce a delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (which-fats vegetable)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.5)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2)))\n (assert (attribute (name best-carbonation) (value low) (certainty -0.5))))\n\n(defrule determine-best-beer-attributes-if-creamy-dessert-is-fruit\n (declare (salience ?*medium-low-priority*))\n (creamy-dessert-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because desserts pair particularly well \"\n \"with beers that presents an overwhelmingly malty, rich and dominant sweet malt flavor and aroma and soft \"\n \"and chewy mouthfeel.\")))))\n\n(defrule determine-best-beer-attributes-if-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (which-dessert chocolate)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty -0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty -0.5)))\n (assert (attribute (name explanation-main-meal) (value (str-cat \"That's it because chocolate pair well with beers \"\n \"with a sweet flavor, thanks to the prevalent sense of maltiness on the palate, and also with beers wich \"\n \"presents a roasty flavor, thanks to the roast of the malt that comes through strong and can produce a \"\n \"delicate bitterness in these beers.\")))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter\n (declare (salience ?*medium-low-priority*))\n (which-chocolate unsweetened\/bitter)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"18e55e20db291b5ae3a79961d54ed7a7aee0abcb","subject":"Ya pregunta al usuario si le fue bien o mal con su campeon","message":"Ya pregunta al usuario si le fue bien o mal con su campeon\n","repos":"yzaguirre\/P1IA","old_file":"src\/run.clp","new_file":"src\/run.clp","new_contents":"(deftemplate campeon\n\t(slot nombre (type STRING))\n (multislot tiene-rols)\n\t(slot salud (type INTEGER))\n\t(slot ataque (type INTEGER))\n\t(slot hechizo (type INTEGER))\n\t(slot dificultad (type INTEGER))\n\t(slot fecha (type STRING))\n\t(slot puntosip (type INTEGER))\n\t(slot puntosrp (type INTEGER))\n\t(slot prioridad (type INTEGER))\n (multislot ga)\n (multislot ba)\n (multislot gw)\n (slot ban (type INTEGER))\n)\n(deftemplate prioridad\n (slot tipo (type STRING))\n (slot champ1 (type STRING))\n (slot champ2 (type STRING))\n (slot flag (type INTEGER))\n)\n; Aatrox\n(defglobal ?*equipo* = 0) ; equipo que pertenece el jugador de abajo que representa al usuario\n(defglobal ?*player* = 0) ; eleccion de # jugador que representa al usuario\n(defglobal ?*candidatos* = 0) ; lista de candidatos ordenado segun prioridad de la lista de abajo\n(defglobal ?*prioridades* = 0) ; lista de prioridades de campeones de arriba en orden descendente\n\n(defglobal ?*campeones* = 0) ; lista de jugadores elegidos ordenado segun reglas de elecci\u00f3n de campeon\n(defglobal ?*equipos* = 0) ; equipo que pertenece el jugador que elegio el campeon en la lista de arriba\n\n;(defrule le-fue-bien\n;\t(salience 187)\n;\t(comolefue 1)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (+ prioridad 1))\n;)\n;(defrule le-fue-mal\n;\t(salience 187)\n;\t(comolefue 0)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (- prioridad 1))\n;)\n(defrule como-le-fue\n(declare (salience 186))\n (juega-con ?player ?equipo ?campeon)\n (test (and (eq ?player ?*player*) (eq ?equipo ?*equipo*)))\n ?p <- (campeon (nombre ?campeon) (prioridad ?prioridad) (ban 1))\n=>\n\t(printout t \"Ud. es el jugador #\" ?*player* \" del equipo \" ?*equipo* \". \" crlf \"Con prioridad igual a \" ?prioridad \", le fue bien a tu campeon \\\"\" ?campeon \"\\\" ? si o no: \")\n\t(bind ?comolefue (readline))\n (if (eq ?comolefue \"si\")\n then (modify ?p (prioridad (+ ?prioridad 1))(ban 2)) (printout t \"nueva prioridad + \" (+ ?prioridad 1) crlf)\n else (modify ?p (prioridad (- ?prioridad 1))(ban 2)) (printout t \"nueva prioridad - \" (- ?prioridad 1) crlf)\n )\n)\n; ORDEN DE ELECCION\n; 1a\n; 1m\n; 2m\n; 2a\n; 3a\n; 3m\n; 4m\n; 4a\n; 5a\n; 5m\n(defrule prioridad-gw\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"gw\") (champ1 ?campeon) (champ2 ?gw) (flag 0))\n (juega-con ?jug&~?jugador ?equipo ?gw) ; existe el gw en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Subiendo prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es gw con \" ?gw crlf)\n)\n(defrule prioridad-ga\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"ga\") (champ1 ?campeon) (champ2 ?ga) (flag 0))\n (juega-con ?jug ?equi&~?equipo ?ga) ; no existe el ga en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Subiendo prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es ga con \" ?ga crlf)\n)\n(defrule prioridad-ba\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"ba\") (champ1 ?campeon) (champ2 ?ba) (flag 0))\n (juega-con ?jug ?equi&~?equipo ?ba) ; no existe el ba en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Restando prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es ba con \" ?ba crlf)\n)\n(defrule ingreso-campeon-fase2\n (declare (salience 199)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)\n=>\n (printout t crlf \"Top 3 Campeones Recomendados:\" crlf)\n (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)\n (bind ?*candidatos* 0) ; limpiar la lista\n (bind ?*prioridades* 0) ; limpiar la lista\n (printout t \"Ingrese nombre del campeon: \")\n (bind ?campeon (readline))\n (assert (juega-con ?jugador ?equipo ?campeon))\n (if (integerp ?*campeones*)\n then ; eliminar el campo 0\n (bind ?*campeones* ?*campeones* ?campeon)\n (bind ?*equipos* ?*equipos* ?equipo)\n (bind ?*campeones* (delete$ ?*campeones* 1 1))\n (bind ?*equipos* (delete$ ?*equipos* 1 1))\n else ; ingreso normal\n (bind ?*campeones* ?*campeones* ?campeon)\n (bind ?*equipos* ?*equipos* ?equipo)\n )\n (assert (ban ?campeon)) ; ya no se podra elegir\n (printout t crlf)\n)\n(defrule ingreso-campeon\n (declare (salience 200)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)\n (puede-con ?pos $?rols)\n\n (campeon \n (nombre ?campeon)\n (tiene-rols ?r1 ?r2\n &:(or (member ?r1 $?rols)(member ?r2 $?rols))\n )\n (prioridad ?prioridad)\n (gw $?allgw)\n (ga $?allga)\n (ba $?allba)\n (ban 0)\n )\n=>\n (if (integerp ?*candidatos*)\n then\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n (bind ?*candidatos* (delete$ ?*candidatos* 1 1))\n (bind ?*prioridades* (delete$ ?*prioridades* 1 1))\n ;(printout t \"ELIMINANDO\" crlf)\n else ; ingrese ordenado segun prioridad\n ; antes, modificar prioridad a causa de campeones elegidos anteriormente\n (bind ?pri ?prioridad); la prioridad a modificar del candidato\n (if (not (integerp ?*campeones*)) ; por lo menos ya se ha elegido el primer campeon\n then\n (bind ?len (length$ ?*campeones*))\n (loop-for-count (?a 1 ?len); iterar los campeones ya elegidos (maximo 9)\n (bind ?chosenChamp (nth$ ?a ?*campeones*)) ; nombre de campeon elegido\n (bind ?chosenTeam (nth$ ?a ?*equipos*)) ; equipo que elegio el campeon\n (loop-for-count (?i 1 10); iterar por gw ga ba del campeon candidato\n (bind ?igw (nth$ ?i $?allgw))\n (bind ?iga (nth$ ?i $?allga))\n (bind ?iba (nth$ ?i $?allba))\n \n (if (and (eq ?igw ?chosenChamp)(eq ?chosenTeam ?equipo))\n then (bind ?pri (+ ?pri 1)); sumar prioridad\n ;(printout t \"sumando gw\" crlf)\n else \n (if (and (eq ?iga ?chosenChamp)(neq ?chosenTeam ?equipo))\n then (bind ?pri (+ ?pri 1)); sumar prioridad\n ;(printout t \"sumando ga\" crlf)\n else \n (if (and (eq ?iba ?chosenChamp)(neq ?chosenTeam ?equipo))\n then (bind ?pri (- ?pri 1)); restar prioridad\n ;(printout t \"sumando ba\" crlf)\n )\n )\n )\n )\n )\n )\n ; ahora si, el ingreso ordenado\n (bind ?length (length$ ?*candidatos*))\n (bind ?nswapped True)\n (loop-for-count (?x 1 ?length)\n (bind ?prioridadLista (nth$ ?x ?*prioridades*))\n (if (>= ?pri ?prioridadLista)\n then\n ; make the swap happen :)\n (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))\n (bind ?*prioridades* (insert$ ?*prioridades* ?x ?pri))\n (bind ?nswapped False)\n ;(printout t \"ROMPIENDO\" crlf)\n (break)\n )\n )\n (if (eq ?nswapped True)\n then ; anadir al final de la lista\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?pri)\n )\n )\n ;(printout t crlf \"== \" ?jugador \" == \" ?posicion \" == \" $?rols \" == \" ?r1 \" == \" ?r2 \" == \" ?campeon \" == prioridad \" ?prioridad crlf crlf)\n)\n(defrule ingreso-5m\n (declare (salience 190))\n (jugador 5 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"m\" ?pos))\n)\n(defrule ingreso-5a\n (declare (salience 190))\n (jugador 5 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"a\" ?pos))\n (assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-4a\n (declare (salience 190))\n (jugador 4 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"a\" ?pos))\n (assert (jugador 5 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-4m\n (declare (salience 190))\n (jugador 4 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"m\" ?pos))\n (assert (jugador 4 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-3m\n (declare (salience 190))\n (jugador 3 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"m\" ?pos))\n (assert (jugador 4 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-3a\n (declare (salience 190))\n (jugador 3 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"a\" ?pos))\n (assert (jugador 3 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-2a\n (declare (salience 190))\n (jugador 2 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"a\" ?pos))\n (assert (jugador 3 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-2m\n (declare (salience 190))\n (jugador 2 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"m\" ?pos))\n (assert (jugador 2 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-1m\n (declare (salience 190))\n (jugador 1 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 1 \"m\" ?pos))\n (assert (jugador 2 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-1a\n (declare (salience 190))\n (jugador 1 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert (jugador 1 \"m\")) ; proximo jugador que elije\n (assert(con-posicion 1 \"a\" ?pos))\n)\n(defrule trato-ban\n(declare (salience 201))\n ?b <- (ban ?campeon)\n ?p <- (campeon (nombre ?campeon) (ban 0))\n=>\n (modify ?p (ban 1))\n (retract ?b)\n)\n(defrule ingreso-informacion1\n(declare (salience 201))\n (initial-fact)\n=>\t\n\t(printout t \"Modo Blind-Pick\" crlf)\n\t\n\t;(assert (flag201 1))\n (assert (ban \"Irelia\"))\n (assert (ban \"Janna\"))\n (assert (ban \"Jarvan IV\"))\n (assert (ban \"Jax\"))\n (assert (ban \"Jayce\"))\n (assert (ban \"Jinx\"))\n\n\t(printout t crlf \"Ingrese equipo a pertener, Azul o Morado: \")\n\t(bind ?*equipo* \"a\")\n\n\t(printout t crlf \"Ingrese el # de jugador (1 - 6) del equipo \" ?*equipo* \": \")\n\t(bind ?*player* 1)\n\t(printout t crlf)\n (assert (jugador 1 \"a\")) ; proximo jugador que elije\n)\n(defrule inicio\n(declare (salience 202))\n (initial-fact)\n=>\n (load-facts limited_facts.clp)\n\t;(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n)","old_contents":"(deftemplate campeon\n\t(slot nombre (type STRING))\n (multislot tiene-rols)\n\t(slot salud (type INTEGER))\n\t(slot ataque (type INTEGER))\n\t(slot hechizo (type INTEGER))\n\t(slot dificultad (type INTEGER))\n\t(slot fecha (type STRING))\n\t(slot puntosip (type INTEGER))\n\t(slot puntosrp (type INTEGER))\n\t(slot prioridad (type INTEGER))\n (multislot ga)\n (multislot ba)\n (multislot gw)\n (slot ban (type INTEGER))\n)\n(deftemplate prioridad\n (slot tipo (type STRING))\n (slot champ1 (type STRING))\n (slot champ2 (type STRING))\n (slot flag (type INTEGER))\n)\n; Aatrox\n(defglobal ?*equipo* = 0) ; equipo que pertenece el jugador de abajo que representa al usuario\n(defglobal ?*player* = 0) ; eleccion de # jugador que representa al usuario\n(defglobal ?*candidatos* = 0) ; lista de candidatos ordenado segun prioridad de la lista de abajo\n(defglobal ?*prioridades* = 0) ; lista de prioridades de campeones de arriba en orden descendente\n\n(defglobal ?*campeones* = 0) ; lista de jugadores elegidos ordenado segun reglas de elecci\u00f3n de campeon\n(defglobal ?*equipos* = 0) ; equipo que pertenece el jugador que elegio el campeon en la lista de arriba\n\n;(defrule le-fue-bien\n;\t(salience 187)\n;\t(comolefue 1)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (+ prioridad 1))\n;)\n;(defrule le-fue-mal\n;\t(salience 187)\n;\t(comolefue 0)\n;\t?p <- (campeon (nombre ?**))\n;=>\n;\t(modify ?p (- prioridad 1))\n;)\n;(defrule como-le-fue\n;(declare salience 186)\n;\t(initial-fact)\n;=>\n;\t(printout t \"Le fue bien? si o no: \")\n;\t(assert (comolefue =(readline)))\n;)\n; ORDEN DE ELECCION\n; 1a\n; 1m\n; 2m\n; 2a\n; 3a\n; 3m\n; 4m\n; 4a\n; 5a\n; 5m\n\n(defrule prioridad-gw\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"gw\") (champ1 ?campeon) (champ2 ?gw) (flag 0))\n (juega-con ?jug&~?jugador ?equipo ?gw) ; existe el gw en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Subiendo prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es gw con \" ?gw crlf)\n)\n(defrule prioridad-ga\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"ga\") (champ1 ?campeon) (champ2 ?ga) (flag 0))\n (juega-con ?jug ?equi&~?equipo ?ga) ; no existe el ga en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Subiendo prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es ga con \" ?ga crlf)\n)\n(defrule prioridad-ba\n (declare (salience 198)); mas alto que los ingreso-#equipo\n (juega-con ?jugador ?equipo ?campeon)\n ?f0 <- (prioridad (tipo \"ba\") (champ1 ?campeon) (champ2 ?ba) (flag 0))\n (juega-con ?jug ?equi&~?equipo ?ba) ; no existe el ba en su equipo\n ?f1 <- (campeon (nombre ?campeon) (prioridad ?prioridad))\n=>\n (modify ?f0 (flag 1))\n (modify ?f1 (prioridad (+ ?prioridad 1)))\n (printout t \"Restando prioridad a \" ?campeon \" de jugador \" ?jugador \" y equipo \" ?equipo \" porque es ba con \" ?ba crlf)\n)\n(defrule ingreso-campeon-fase2\n (declare (salience 199)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)\n=>\n (printout t crlf \"Top 3 Campeones Recomendados:\" crlf)\n (printout t (implode$ (subseq$ ?*candidatos* 1 3)) crlf)\n (bind ?*candidatos* 0) ; limpiar la lista\n (bind ?*prioridades* 0) ; limpiar la lista\n (printout t \"Ingrese nombre del campeon: \")\n (bind ?campeon (readline))\n (assert (juega-con ?jugador ?equipo ?campeon))\n (if (integerp ?*campeones*)\n then ; eliminar el campo 0\n (bind ?*campeones* ?*campeones* ?campeon)\n (bind ?*equipos* ?*equipos* ?equipo)\n (bind ?*campeones* (delete$ ?*campeones* 1 1))\n (bind ?*equipos* (delete$ ?*equipos* 1 1))\n else ; ingreso normal\n (bind ?*campeones* ?*campeones* ?campeon)\n (bind ?*equipos* ?*equipos* ?equipo)\n )\n (assert (ban ?campeon)) ; ya no se podra elegir\n (printout t crlf)\n)\n(defrule ingreso-campeon\n (declare (salience 200)); mas alto que los ingreso-#equipo\n (con-posicion ?jugador ?equipo ?pos)(tiene-codigo ?posicion ?pos)\n (puede-con ?pos $?rols)\n\n (campeon \n (nombre ?campeon)\n (tiene-rols ?r1 ?r2\n &:(or (member ?r1 $?rols)(member ?r2 $?rols))\n )\n (prioridad ?prioridad)\n (gw $?allgw)\n (ga $?allga)\n (ba $?allba)\n (ban 0)\n )\n ;(juega-con ? ?&~?nombre)\n=>\n (if (integerp ?*candidatos*)\n then\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?prioridad)\n (bind ?*candidatos* (delete$ ?*candidatos* 1 1))\n (bind ?*prioridades* (delete$ ?*prioridades* 1 1))\n ;(printout t \"ELIMINANDO\" crlf)\n else ; ingrese ordenado segun prioridad\n ; antes, modificar prioridad a causa de campeones elegidos anteriormente\n (bind ?pri ?prioridad); la prioridad a modificar del candidato\n (if (not (integerp ?*campeones*)) ; por lo menos ya se ha elegido el primer campeon\n then\n (bind ?len (length$ ?*campeones*))\n (loop-for-count (?a 1 ?len); iterar los campeones ya elegidos (maximo 9)\n (bind ?chosenChamp (nth$ ?a ?*campeones*)) ; nombre de campeon elegido\n (bind ?chosenTeam (nth$ ?a ?*equipos*)) ; equipo que elegio el campeon\n (loop-for-count (?i 1 10); iterar por gw ga ba del campeon candidato\n (bind ?igw (nth$ ?i $?allgw))\n (bind ?iga (nth$ ?i $?allga))\n (bind ?iba (nth$ ?i $?allba))\n \n (if (and (eq ?igw ?chosenChamp)(eq ?chosenTeam ?equipo))\n then (bind ?pri (+ ?pri 1)); sumar prioridad\n ;(printout t \"sumando gw\" crlf)\n else \n (if (and (eq ?iga ?chosenChamp)(neq ?chosenTeam ?equipo))\n then (bind ?pri (+ ?pri 1)); sumar prioridad\n ;(printout t \"sumando ga\" crlf)\n else \n (if (and (eq ?iba ?chosenChamp)(neq ?chosenTeam ?equipo))\n then (bind ?pri (- ?pri 1)); restar prioridad\n ;(printout t \"sumando ba\" crlf)\n )\n )\n )\n )\n )\n )\n ; ahora si, el ingreso ordenado\n (bind ?length (length$ ?*candidatos*))\n (bind ?nswapped True)\n (loop-for-count (?x 1 ?length)\n (bind ?prioridadLista (nth$ ?x ?*prioridades*))\n (if (>= ?pri ?prioridadLista)\n then\n ; make the swap happen :)\n (bind ?*candidatos* (insert$ ?*candidatos* ?x ?campeon))\n (bind ?*prioridades* (insert$ ?*prioridades* ?x ?pri))\n (bind ?nswapped False)\n ;(printout t \"ROMPIENDO\" crlf)\n (break)\n )\n )\n (if (eq ?nswapped True)\n then ; anadir al final de la lista\n (bind ?*candidatos* ?*candidatos* ?campeon)\n (bind ?*prioridades* ?*prioridades* ?pri)\n )\n )\n ;(printout t crlf \"== \" ?jugador \" == \" ?posicion \" == \" $?rols \" == \" ?r1 \" == \" ?r2 \" == \" ?campeon \" == prioridad \" ?prioridad crlf crlf)\n)\n(defrule ingreso-5m\n (declare (salience 190))\n (jugador 5 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"m\" ?pos))\n)\n(defrule ingreso-5a\n (declare (salience 190))\n (jugador 5 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 5 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 5 \"a\" ?pos))\n (assert (jugador 5 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-4a\n (declare (salience 190))\n (jugador 4 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"a\" ?pos))\n (assert (jugador 5 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-4m\n (declare (salience 190))\n (jugador 4 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 4 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 4 \"m\" ?pos))\n (assert (jugador 4 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-3m\n (declare (salience 190))\n (jugador 3 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"m\" ?pos))\n (assert (jugador 4 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-3a\n (declare (salience 190))\n (jugador 3 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 3 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 3 \"a\" ?pos))\n (assert (jugador 3 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-2a\n (declare (salience 190))\n (jugador 2 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"a\" ?pos))\n (assert (jugador 3 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-2m\n (declare (salience 190))\n (jugador 2 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 2 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 2 \"m\" ?pos))\n (assert (jugador 2 \"a\")) ; proximo jugador que elije\n)\n(defrule ingreso-1m\n (declare (salience 190))\n (jugador 1 \"m\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Morado, Elija su posicion: \")\n (bind ?pos (read))\n (assert(con-posicion 1 \"m\" ?pos))\n (assert (jugador 2 \"m\")) ; proximo jugador que elije\n)\n(defrule ingreso-1a\n (declare (salience 190))\n (jugador 1 \"a\")\n=>\n (printout t crlf \"ELECCION DE POSICION\" crlf \"Posiciones disponibles:\" crlf \n \"1. Top\" crlf \"2. Mid\" crlf \"3. ADC\" crlf \"4. Support\" crlf \"5. Jungle\" crlf \n \"Jugador 1 de Equipo Azul, Elija su posicion: \")\n (bind ?pos (read))\n (assert (jugador 1 \"m\")) ; proximo jugador que elije\n (assert(con-posicion 1 \"a\" ?pos))\n)\n(defrule trato-ban\n(declare (salience 201))\n ?b <- (ban ?campeon)\n ?p <- (campeon (nombre ?campeon) (ban 0))\n=>\n (modify ?p (ban 1))\n (retract ?b)\n)\n(defrule ingreso-informacion1\n(declare (salience 201))\n (initial-fact)\n=>\t\n\t(printout t \"Modo Blind-Pick\" crlf)\n\t\n\t;(assert (flag201 1))\n (assert (ban \"Irelia\"))\n (assert (ban \"Janna\"))\n (assert (ban \"Jarvan IV\"))\n (assert (ban \"Jax\"))\n (assert (ban \"Jayce\"))\n (assert (ban \"Jinx\"))\n\n\t(printout t crlf \"Ingrese equipo a pertener, Azul o Morado: \")\n\t(bind ?*equipo* Azul)\n\n\t(printout t crlf \"Ingrese el # de jugador (1 - 6) del equipo \" ?*equipo* \": \")\n\t(bind ?*player* 1)\n\t(printout t crlf)\n (assert (jugador 1 \"a\")) ; proximo jugador que elije\n)\n(defrule inicio\n(declare (salience 202))\n (initial-fact)\n=>\n (load-facts limited_facts.clp)\n\t;(printout t \" Exito!!, Se cargaron los datos correctamente\" crlf crlf )\n)","returncode":0,"stderr":"","license":"mpl-2.0","lang":"CLIPS"} {"commit":"fd49d47760e93c54e57089abba31a65236cdc830","subject":"application\/tools\/conv\/gl\/common\/Application.clp: Fixed imports","message":"application\/tools\/conv\/gl\/common\/Application.clp: Fixed imports\n\nAll of the modules have had (import init ?ALL) added to include support for the\ninit module features\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"application\/tools\/conv\/gl\/common\/Application.clp","new_file":"application\/tools\/conv\/gl\/common\/Application.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; CommonConversionEntry.clp - Entry point into the generic backend for the\n; conversion expert systems\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n; Load cortex\n;------------------------------------------------------------------------------\n(defmodule types \n (import init ?ALL)\n (import cortex ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import init ?ALL)\n (import cortex ?ALL)\n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(load-library \"tools\/conv\/gl\/common\")\n(load-logic \"tools\/conv\/gl\/common\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; CommonConversionEntry.clp - Entry point into the generic backend for the\n; conversion expert systems\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n; Load cortex\n;------------------------------------------------------------------------------\n(defmodule types \n (import cortex ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import cortex ?ALL)\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import cortex ?ALL)\n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(load-library \"tools\/conv\/gl\/common\")\n(load-logic \"tools\/conv\/gl\/common\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"7b0cc0545a2abdb39bbed347a70b40def58fcad5","subject":"Ignore previous timer when it is reset.","message":"Ignore previous timer when it is reset.\n\n-> Implemented a few rules to ignore a timer when a new one is set.\n\t'-> The only drawback is that if the new one has a shorter time, it will still wait until the longest time ends.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/utils.clp","new_file":"CLIPS\/utils.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction str-replace\n\t(?str ?old ?new)\n\t(bind ?len (str-length ?old))\n\t(bind ?pos (str-index ?old ?str))\n\t(while (neq ?pos FALSE) do\n\t\t(bind ?str_len (str-length ?str))\n\t\t(bind ?str\n\t\t\t(str-cat\n\t\t\t\t(sub-string 1 (- ?pos 1) ?str)\n\t\t\t\t?new\n\t\t\t\t(sub-string (+ ?pos ?len) ?str_len ?str)\n\t\t\t)\n\t\t)\n\t\t(bind ?pos (str-index ?old ?str))\n\t)\n\t(return ?str)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(bind ?new_sym (gensym*))\n\t(python-call setTimer ?time ?new_sym)\n\t(assert\n\t\t(BBCLIPS_timer ?new_sym ?sym)\n\t\t(timer_sent ?sym)\n\t)\n)\n\n(defrule clear_timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule timer_alarm\n\t(declare (salience 10000))\n\t?bbt <-(BB_timer ?new_sym)\n\t?bbct <-(BBCLIPS_timer ?new_sym ?sym)\n\t(not (BBCLIPS_timer ~?new_sym ?sym))\n\t?t <-(timer_sent ?sym)\n\t=>\n\t(retract ?t ?bbt ?bbct)\n\t(assert\n\t\t(BB_timer ?sym)\n\t)\n)\n\n(defrule timer_alarm-old_timer\n\t(declare (salience 10000))\n\t?bbt <-(BB_timer ?new_sym)\n\t?bbct <-(BBCLIPS_timer ?new_sym ?sym)\n\t;(timer_sent ?sym)\n\t(BBCLIPS_timer ~?new_sym ?sym)\n\t=>\n\t(retract ?bbt ?bbct)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction stop\n\t()\n\t(log-message WARNING \"Stop function called. EXECUTION HALTED.\")\n\t(python-call stop)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(test (fact-existp ?fact))\n\t=>\n\t(retract ?f ?fact)\n)\n\n(defrule set_delete-delete_delete_flag\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(not (test (fact-existp ?fact)))\n\t=>\n\t(retract ?f)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction str-replace\n\t(?str ?old ?new)\n\t(bind ?len (str-length ?old))\n\t(bind ?pos (str-index ?old ?str))\n\t(while (neq ?pos FALSE) do\n\t\t(bind ?str_len (str-length ?str))\n\t\t(bind ?str\n\t\t\t(str-cat\n\t\t\t\t(sub-string 1 (- ?pos 1) ?str)\n\t\t\t\t?new\n\t\t\t\t(sub-string (+ ?pos ?len) ?str_len ?str)\n\t\t\t)\n\t\t)\n\t\t(bind ?pos (str-index ?old ?str))\n\t)\n\t(return ?str)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym) )\n)\n\n(defrule clear_timers\n\t(declare (salience -9501))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer_sent\n\t(declare (salience 10000))\n\t(BB_timer ?sym)\n\t?t <-(timer_sent ?sym)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_timer\n\t(declare (salience -9501))\n\t?t <-(BB_timer ?sym)\n\t(not (timer_sent ?sym))\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction stop\n\t()\n\t(log-message WARNING \"Stop function called. EXECUTION HALTED.\")\n\t(python-call stop)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(test (fact-existp ?fact))\n\t=>\n\t(retract ?f ?fact)\n)\n\n(defrule set_delete-delete_delete_flag\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t(not (test (fact-existp ?fact)))\n\t=>\n\t(retract ?f)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"ba53d67e5efa1a010cdca8836021b7029e8fcefb","subject":"Update task2.clp","message":"Update task2.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter4\/task2.clp","new_file":"ssu-ai-level-2\/chapter4\/task2.clp","new_contents":"(deffacts tovars\n (tovar TV 200 4 2015 Russia)\n (tovar Watch 199 5 2017 USA)\n (tovar Linkorn 1000 1 2010 Armenia)\n (tovar IceCream 10 99 2017 Ukraine)\n (tovar Book 1 1 2001 Vanuatu)\n)\n\n(defrule ucenk\n (tovar ?name ?cost ?count ?year ?country)\n\n (test (or (< ?year 2010)\n (< ?count 4)\n )\n )\n =>\n (assert (ucenka ?name (* ?cost 0.15)))\n)\n\n(defrule nacenk\n (tovar ?name ?cost ?count ?year ?country)\n\n (test (and (= 0 (str-compare ?country Russia))\n (= ?year 2017)\n )\n )\n =>\n (assert (nacenka ?name (* ?cost 0.07)))\n)\n\n(defrule russian\n (tovar ?name ?cost ?count ?year ?country)\n\n (exists (test (= 0 (str-compare ?country Russia))))\n =>\n (printout t \"There are Russian production\" crlf)\n)\n","old_contents":"(deffacts tovars\n (tovar TV 200 4 2015 Russia)\n (tovar Watch 199 5 2017 USA)\n (tovar Linkorn 1000 1 2010 Russia)\n (tovar IceCream 10 99 2017 Ukraine)\n (tovar Book 1 1 2001 Vanuatu)\n)\n\n(defrule ucenk\n (tovar ?name ?cost ?count ?year ?country)\n\n (test (or (?year < 2010)\n (?count < 4)\n )\n )\n =>\n (assert (ucenka ?name (* ?cost 0.15)))\n)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"b777a722b0da83a74ea3f41d9bd4749a2888d10c","subject":"Modified the slots of Path to be lower case","message":"Modified the slots of Path to be lower case\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/Path.clp","new_file":"lib\/durandal\/passes\/path\/Path.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n(defclass types::Path \n (is-a ParentedHint)\n (slot exit (type SYMBOL))\n (slot closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Path init after\n ()\n (bind ?self:Type Path))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n(defclass types::Path \n (is-a ParentedHint)\n (slot Exit (type SYMBOL))\n (slot Closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Path init after\n ()\n (bind ?self:Type Path))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d839b4046ef0957f45bd3c5d0ed5c629ef12e3b7","subject":"Added a control fact to each rule in PathTraversal.clp","message":"Added a control fact to each rule in PathTraversal.clp\n\nThis control fact is used to traverse each path in a region as well as be\nmutated to handle path building as well.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/conditional\/PathTraversal.clp","new_file":"lib\/durandal\/passes\/path\/conditional\/PathTraversal.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathTraversal.clp - Contains rules that handle the act of traversing the\n; region during path construction. Modified to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-basicblock\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) (id ?id) \n (parent ?p) \n (closed FALSE)\n (values $?before ?curr))\n (object (is-a BasicBlock) \n (id ?curr) \n (parent ?p) \n (Successors $? ?next $?))\n (object (is-a BasicBlock) \n (id ?next) \n (parent ?p))\n (test (and (neq ?next ?curr) \n (not (member$ ?next $?before))))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action add-to-path)\n (arguments ?next => ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-basicblock\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a Region) \n (id ?curr) \n (parent ?p) \n (Exits $? ?next $?))\n (object (is-a BasicBlock) \n (id ?next) \n (parent ?p))\n (test (and (neq ?next ?curr) \n (not (member$ ?next $?before))))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action add-to-path)\n (arguments ?next => ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-region\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id)\n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a BasicBlock) \n (id ?curr) \n (parent ?p) \n (Successors $? ?s $?))\n (object (is-a Region) \n (Entrances $? ?s $?) \n (id ?next) \n (parent ?p))\n (test (and (neq ?next ?curr) \n (not (member$ ?next $?before))))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action add-to-path)\n (arguments ?next => ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-region\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a Region) \n (id ?curr) \n (parent ?p) \n (Exits $? ?e $?))\n (object (is-a Region) \n (id ?next) \n (parent ?p) \n (Entrances $? ?e $?)) \n (test (and (neq ?next ?curr) \n (not (member$ ?next $?before))))\n ; even if the entrance is part of a nested region...we really don't \n ; care it will still be accurate thanks to the way llvm does things\n =>\n (send ?path increment-reference-count)\n (modify ?f (action add-to-path)\n (arguments ?next => ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-no-exit\n \"We are at a region that doesn't have an exit...Not sure if LLVM \n allows this but let's handle it.\"\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (parent ?p) \n (closed FALSE) \n (values $? ?a))\n (object (is-a Region) \n (id ?a) \n (parent ?p) \n (Exits))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => nil)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::travseral-basicblock-no-exit\n \"We are at a basic block that has no successors...usually the end of a\n function\"\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (parent ?p) \n (closed FALSE) \n (values $? ?a))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?p) \n (Successors))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => nil)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-basicblock-cycle\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) (id ?id) \n (parent ?p) \n (values $?before ?curr) \n (closed FALSE))\n (object (is-a BasicBlock) \n (id ?curr) \n (parent ?p) \n (Successors $? ?next $?))\n (object (is-a BasicBlock) \n (id ?next) \n (parent ?p))\n (test (or (eq ?next ?curr) \n (member$ ?next $?before)))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-basicblock-cycle\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a Region) \n (id ?curr) \n (parent ?p) \n (Exits $? ?next $?))\n (object (is-a BasicBlock) \n (id ?next) \n (parent ?p))\n (test (or (eq ?next ?curr) \n (member$ ?next $?before)))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-region-cycle\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a BasicBlock) \n (id ?curr) \n (parent ?p) \n (Successors $? ?s $?))\n (object (is-a Region) \n (id ?next) \n (parent ?p) \n (Entrances $? ?s $?))\n (test (or (eq ?next ?curr) \n (member$ ?next $?before)))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-region-cycle\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $?before ?curr))\n (object (is-a Region) \n (id ?curr) \n (parent ?p) \n (Exits $? ?e $?))\n (object (is-a Region) \n (id ?next) \n (parent ?p) \n (Entrances $? ?e $?)) \n (test (or (eq ?next ?curr) \n (member$ ?next $?before)))\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?next => ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-exit\n \"Marks the current path as finished because we've reached an exit to \n the current region\"\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (parent ?p) \n (closed FALSE)\n (values $? ?curr))\n (object (is-a BasicBlock) \n (id ?curr) \n (parent ?p) \n (Successors $? ?e $?))\n (object (is-a Region) \n (id ?p) \n (Exits $? ?e $?))\n ;since the current block has an exit for this region we mark it\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => ?e)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-exit\n (declare (salience 2))\n ?f <- (message (to paths-conditional)\n (action build-path)\n (arguments ?id))\n ?path <- (object (is-a Path) \n (id ?id) \n (closed FALSE) \n (parent ?p) \n (values $? ?c))\n (object (is-a Region) \n (id ?c) \n (parent ?p) \n (Exits $? ?e $?))\n (object (is-a Region) \n (id ?p) \n (Exits $? ?e $?))\n ; both the inner and outer regions have the same exit...thus the\n ; curent nested region is a terminator for one path\n =>\n (send ?path increment-reference-count)\n (modify ?f (action close-path)\n (arguments ?id => ?e)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathTraversal.clp - Contains rules that handle the act of traversing the\n; region during path construction. Modified to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-basicblock\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr) (closed FALSE))\n\t\t\t(object (is-a BasicBlock) (id ?curr) (parent ?p) \n\t\t\t\t\t (Successors $? ?next $?))\n\t\t\t(object (is-a BasicBlock) (id ?next) (parent ?p))\n\t\t\t(test (and (neq ?next ?curr) \n\t\t\t\t\t (not (member$ ?next $?before))))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Add ?next to ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-basicblock\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id)\n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a Region) (id ?curr) (parent ?p) (Exits $? ?next $?))\n\t\t\t(object (is-a BasicBlock) (id ?next) (parent ?p))\n\t\t\t(test (and (neq ?next ?curr) \n\t\t\t\t\t (not (member$ ?next $?before))))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Add ?next to ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-region\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a BasicBlock) (id ?curr) (parent ?p) \n\t\t\t\t\t (Successors $? ?s $?))\n\t\t\t(object (is-a Region) (Entrances $? ?s $?) (id ?next) (parent ?p))\n\t\t\t(test (and (neq ?next ?curr) \n\t\t\t\t\t (not (member$ ?next $?before))))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Add ?next to ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-region\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a Region) (id ?curr) (parent ?p) (Exits $? ?e $?))\n\t\t\t(object (is-a Region) (id ?next) (parent ?p) (Entrances $? ?e $?)) \n\t\t\t(test (and (neq ?next ?curr) \n\t\t\t\t\t (not (member$ ?next $?before))))\n\t\t\t; even if the entrance is part of a nested region...we really don't \n\t\t\t; care it will still be accurate thanks to the way llvm does things\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Add ?next to ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-no-exit\n\t\t\t\"We are at a region that doesn't have an exit...Not sure if LLVM \n\t\t\tallows this but let's handle it.\"\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (parent ?p) (id ?i) (closed FALSE) \n\t\t\t\t\t\t\t\t (values $? ?a))\n\t\t\t(object (is-a Region) (id ?a) (parent ?p) (Exits))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?i with nil)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::travseral-basicblock-no-exit\n\t\t\t\"We are at a basic block that has no successors...usually the end of a\n\t\t\tfunction\"\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (parent ?p) (id ?i) (closed FALSE) \n\t\t\t\t\t\t\t\t (values $? ?a))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?p) (Successors))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?i with nil)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-basicblock-cycle\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr) (closed FALSE))\n\t\t\t(object (is-a BasicBlock) (id ?curr) (parent ?p) \n\t\t\t\t\t (Successors $? ?next $?))\n\t\t\t(object (is-a BasicBlock) (id ?next) (parent ?p))\n\t\t\t(test (or (eq ?next ?curr) (member$ ?next $?before)))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?id with ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-basicblock-cycle\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id)\n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a Region) (id ?curr) (parent ?p) (Exits $? ?next $?))\n\t\t\t(object (is-a BasicBlock) (id ?next) (parent ?p))\n\t\t\t(test (or (eq ?next ?curr) (member$ ?next $?before)))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?id with ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-region-cycle\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a BasicBlock) (id ?curr) (parent ?p) (Successors $? ?s $?))\n\t\t\t(object (is-a Region) (id ?next) (parent ?p) (Entrances $? ?s $?))\n\t\t\t(test (or (eq ?next ?curr) (member$ ?next $?before)))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?id with ?next)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-region-cycle\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $?before ?curr))\n\t\t\t(object (is-a Region) (id ?curr) (parent ?p) (Exits $? ?e $?))\n\t\t\t(object (is-a Region) (id ?next) (parent ?p) (Entrances $? ?e $?)) \n\t\t\t(test (or (eq ?next ?curr) (member$ ?next $?before)))\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?next with ?id)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-basicblock-to-exit\n\t\t\t\"Marks the current path as finished because we've reached an exit to \n\t\t\tthe current region\"\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (parent ?p) (id ?id) (values $? ?curr) \n\t\t\t\t\t\t\t\t (closed FALSE))\n\t\t\t(object (is-a BasicBlock) (id ?curr) (parent ?p) (Successors $? ?e $?))\n\t\t\t(object (is-a Region) (id ?p) (Exits $? ?e $?))\n\t\t\t;since the current block has an exit for this region we mark it\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?id with ?e)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::traversal-region-to-exit\n\t\t\t(declare (salience 2))\n\t\t\t?path <- (object (is-a Path) (closed FALSE) (parent ?p) (id ?id) \n\t\t\t\t\t\t\t\t (values $? ?c))\n\t\t\t(object (is-a Region) (id ?c) (parent ?p) (Exits $? ?e $?))\n\t\t\t(object (is-a Region) (id ?p) (Exits $? ?e $?))\n\t\t\t; both the inner and outer regions have the same exit...thus the\n\t\t\t; curent nested region is a terminator for one path\n\t\t\t=>\n\t\t\t(send ?path increment-reference-count)\n\t\t\t(assert (Close ?id with ?e)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fe6d7737621e3346f441e20c980d14cc1d48a888","subject":"Reformatted WavefrontScheduling.clp","message":"Reformatted WavefrontScheduling.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (argument ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 (?sLen)) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (contents $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (contents $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (TargetPath ?path)\n (TargetBlock ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (TargetBlock ?e) \n (TargetPath ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (argument ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) (ID ?pv) (Contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n (Stage WavefrontSchedule $?)\n (Substage Acquire $?)\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) (ID ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 (?sLen)) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (contents $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (contents $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (TargetPath ?path) \n (TargetBlock ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (contents $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (TargetPath ?path)\n (TargetBlock ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (TargetPath ?path) \n (TargetBlock ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (contents $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (symbol-to-instance-name ?cpv))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (symbol-to-instance-name ?p))\n (bind ?o2C (send ?o2 get-contents))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-name (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (TargetBlock ?e) \n (TargetPath ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (TargetBlock ?e)\n (TargetPath ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (TargetBlock ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (contents $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance (passes \n wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-Contents))\n (modify-instance \n (symbol-to-instance-name ?child)\n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"7c4a8a81437ff60367022cf2b358d897d2966958","subject":"canviat funcio calcula_puntuacion","message":"canviat funcio calcula_puntuacion\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?e get-edad+maxima) (send ?e get-edad+maxima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","old_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 1)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 1)))\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?e get-edad+maxima) (send ?e get-edad+maxima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"f0e983e2c10cdb45b8f7561bb55a94d5f5e64c26","subject":"Dayum, arriba de ti","message":"Dayum, arriba de ti\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Sabado\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Domingo\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?lunes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?martes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 3 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 3 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?miercoles))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 4 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 4 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?jueves))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 5 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 5 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?viernes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 6 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 6 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?sabado))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 7 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 7 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?domingo))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -10))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Sabado\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Domingo\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"01c56e6dbdd034962acab65e0a15da4d6693e1a6","subject":"Fuck my life","message":"Fuck my life\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n\n\t","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness (clamp -2000 ?fitness 5000))\n\t(bind ?calorias-deseadas (\/ (+ ?fitness 2000) 7)) ;entre 0 y 1000\n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo)))\n\t)\n)\n\t\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"b99ae31114fd6cd05c6f7b98f1e9f2fa89a0f116","subject":"Added basic error checking for the assembler","message":"Added basic error checking for the assembler\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"Assembler.clp","new_file":"Assembler.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(defglobal MAIN ; human readable form\n ?*symbol-label-instruction* = label\n ?*symbol-terminate-instruction* = terminate\n ?*symbol-nop-instruction* = nop\n ?*symbol-add-instruction* = add\n ?*symbol-subtract-instruction* = sub\n ?*symbol-multiply-instruction* = mul\n ?*symbol-divide-instruction* = div\n ?*symbol-right-shift-instruction* = right-shift\n ?*symbol-left-shift-instruction* = left-shift\n ?*symbol-equal-instruction* = eq\n ?*symbol-not-equal-instruction* = neq\n ?*symbol-less-than-instruction* = lt\n ?*symbol-greater-than-instruction* = gt\n ?*symbol-and-instruction* = and\n ?*symbol-or-instruction* = or\n ?*symbol-not-instruction* = not\n ?*symbol-branch-instruction* = branch\n ?*symbol-load-instruction* = load\n ?*symbol-store-instruction* = store\n ?*symbol-set-instruction* = set\n ?*symbol-interrupt-instruction* = interrupt)\n;-------------------------------------------------------------------------------\n(deftemplate input-line\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot original-input\n (type STRING)\n (default ?NONE))\n (multislot raw-input))\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;-------------------------------------------------------------------------------\n(deftemplate instruction\n (slot tag \n (type SYMBOL))\n (slot arg-count\n (type INTEGER))\n (slot is-macro ; is it a convienience instruction\/operation?\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)))\n;-------------------------------------------------------------------------------\n(deffacts argument-conversion-counts\n (instruction (tag ?*symbol-terminate-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-nop-instruction*)\n (arg-count 0))\n (instruction (tag ?*symbol-add-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-subtract-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-multiply-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-divide-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-right-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-left-shift-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-equal-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-less-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-greater-than-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-and-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-or-instruction*)\n (arg-count 3))\n (instruction (tag ?*symbol-not-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-branch-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-load-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-store-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-set-instruction*)\n (arg-count 2))\n (instruction (tag ?*symbol-interrupt-instruction*)\n (arg-count 1))\n (instruction (tag ?*symbol-label-instruction*)\n (arg-count 1)\n (is-macro TRUE)))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n;-------------------------------------------------------------------------------\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n;-------------------------------------------------------------------------------\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n;-------------------------------------------------------------------------------\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 1)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (original-input ?input)\n (raw-input (explode$ ?input))))\n else\n (assert (translate-input))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n(defrule invalid-line-found\n (declare (salience 2))\n (input-line (line-number ?i)\n (original-input ?line)\n (raw-input $?input))\n (test (or (> (length$ $?input) 4)))\n =>\n (printout werror \"ERROR: line \" ?i \" is invalid\" crlf\n \" \" ?line crlf)\n (halt))\n\n(defrule is-invalid-instruction\n (declare (salience 2)) \n (input-line (raw-input ?op $?)\n (line-number ?l)\n (original-input ?input))\n (not (exists (instruction (tag ?op))))\n =>\n (printout werror \n (format nil \"ERROR: Instruction %s on line %d is invalid%n\" ?op ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n(defrule invalid-argument-count-for-operation\n (declare (salience 2))\n (input-line (raw-input ?operation $?rest)\n (line-number ?l)\n (original-input ?input))\n (instruction (tag ?operation)\n (arg-count ?ac&:(!= ?ac (length$ $?rest))))\n =>\n (printout werror \n (format nil \"ERROR: Invalid number of arguments for %s on line %d%n\"\n ?operation ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n\n(defrule process-input-line\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation $?rest)\n (line-number ?l))\n (instruction (tag ?operation)\n (arg-count =(length$ $?rest)))\n\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (arguments $?rest))))\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n;-------------------------------------------------------------------------------\n(reset) ; load the instruction information for our purposes\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(defglobal MAIN ; human readable form\n ?*symbol-terminate-instruction* = terminate\n ?*symbol-nop-instruction* = nop\n ?*symbol-add-instruction* = add\n ?*symbol-subtract-instruction* = sub\n ?*symbol-multiply-instruction* = mul\n ?*symbol-divide-instruction* = div\n ?*symbol-right-shift-instruction* = right-shift\n ?*symbol-left-shift-instruction* = left-shift\n ?*symbol-equal-instruction* = eq\n ?*symbol-not-equal-instruction* = neq\n ?*symbol-less-than-instruction* = lt\n ?*symbol-greater-than-instruction* = gt\n ?*symbol-and-instruction* = and\n ?*symbol-or-instruction* = or\n ?*symbol-not-instruction* = not\n ?*symbol-branch-instruction* = branch\n ?*symbol-load-instruction* = load\n ?*symbol-store-instruction* = store\n ?*symbol-set-instruction* = set\n ?*symbol-interrupt-instruction* = interrupt\n )\n;-------------------------------------------------------------------------------\n(deftemplate input-line \n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (multislot raw-input))\n\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (slot destination \n (type SYMBOL)\n (default ?NONE))\n (slot source0\n (type NUMBER INSTANCE)\n (default ?NONE))\n (slot source1\n (type INSTANCE)))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 0)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (raw-input (explode$ ?input))))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n\n(defrule process-input-line:two-input\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation ?dest ?source)\n (line-number ?l))\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (destination ?dest)\n (source0 ?source))))\n\n(defrule process-input-line:three-input\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation ?dest ?source0 ?source1)\n (line-number ?l))\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (destination ?dest)\n (source0 ?source0)\n (source1 ?source1))))\n(defrule is-invalid-instruction\n ?f <- (operation (line-number ?l)\n (operation ?operation&:(not (instruction-exists\n ?operation))))\n =>\n (\n\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"77137ab627aae36d2f5a214bde97fb06164490a2","subject":"adding a new script to test deffunctions with assert. the bug is fixed now.","message":"adding a new script to test deffunctions with assert. the bug is fixed now.\n\npeter\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@665 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/deffunction_test2.clp","new_file":"samples\/deffunction_test2.clp","new_contents":"(deftemplate wurst(slot name))\r\n\r\n(deffunction addwurst\r\n (?wurstName)\r\n (assert \r\n (wurst (name ?wurstName))\r\n )\r\n)\r\n(defrule testrule \r\n=>\r\n (bind ?x \"new Wurst\")\r\n (assert (wurst (name ?x))) \r\n (addwurst \"other new Wurst\") \r\n)\r\n(fire)\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/deffunction_test2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"3d83ad28c80cc8054df7dcf7de85ff97e1267c3c","subject":"Ported WavefrontInstructionMerging.clp to the new format","message":"Ported WavefrontInstructionMerging.clp to the new format\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::AssertScheduleCPVIntoTargetBlock \n (object (is-a Wavefront) \n (contents $? ?e $?))\n (object (is-a Diplomat) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (MovableCompensationPathVectors \n $?cpvs&:(<> 0 (length$ $?cpvs))))\n =>\n (modify-instance ?agObj (MovableCompensationPathVectors))\n (progn$ (?cpv $?cpvs)\n (assert (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsMove\n \"This rule attempts to determine if the CPV should be moved into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;the two sets are the same\n (test (equal$ ?paths ?cpvPaths))\n =>\n ;change the action...nothing more :D\n (modify ?fct (message (action move-instruction))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsCompensate\n \"This rule attempts to determine if the CPV should be copied into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted.\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;there are more paths in the CPV than in the block\n (test (subsetp ?paths ?cpvPaths))\n =>\n (modify ?fct (action clone-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::RemoveScheduleStyleForCPV\n (declare (salience 1))\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n (test (not (subsetp ?paths ?cpvPaths)))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n ;TODO: Put code in here to delete a given instruction from the target\n ; instruction list as well. \n ;\n ; Eventually, I will detect if we are in a loop. If we are then it is\n ; necessary to figure out which paths remain in the loop and those\n ; that exit. \n ;this should prevent a potential infinite loop\n ;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::MoveInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last)\n (Produces $?nBProds))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n (Class ?class))\n ?oldBlock <- (object (is-a BasicBlock) \n (id ?otherBlock) \n (Produces $?pBefore ?inst $?pRest)\n (Contents $?before ?inst $?rest))\n ;TODO: add another rule where we have to update the consumers list as\n ; well\n =>\n (object-pattern-match-delay\n ;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n (modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n (modify-instance ?oldBlock (Contents $?before $?rest) \n (Produces $?pBefore $?pRest))\n ;(modify-instance ?cpvObject (Paths))\n (modify ?fct (action remove-evidence)\n (arguments ?inst => $?niConsumers))\n (assert (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?otherBlock)))\n (if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n else\n (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?newName ?last))\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (Producers) \n (Consumers)\n (NonLocalDependencies) \n (LocalDependencies)\n (TimeIndex ?ti) \n (parent ?e))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::CloneInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst) \n (Paths $?cpvPaths))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Class ?class))\n =>\n ;we also need to update all CPVs within \n (object-pattern-match-delay\n (bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n ;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n ; \" as \" ?newName crlf)\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (ID ?newName) \n (Name ?newName)\n (Pointer ?newPtr) \n (Parent ?e)\n (TimeIndex (+ ?ti 1)))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n ;we add the original name so that we don't have to do\n ; an insane number of updates to the CPVs that follow\n ; this object\n (if (eq StoreInstruction ?class) then \n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n else\n (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n (slot-insert$ ?newBlock Produces 1 ?register)\n (modify-instance ?newBlock (contents $?blockBefore ?newName ?last))\n (slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n (slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n (slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify ?fct (action recompute-block)\n (arguments ?otherBlock))\n (assert (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv)))\n (bind ?leftOvers (create$))\n (progn$ (?z ?cpvPaths)\n (bind ?cPath (symbol-to-instance-name ?z))\n (if (not (member$ ?e (send ?cPath get-contents))) then\n (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n (modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-CLONE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-MOVE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-SCHEDULE-STYLE\n (declare (salience -768))\n (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Parent ?p)\n (Aliases $?aliases)\n (Paths $?cpvPaths))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Instruction) \n (id ?p) \n (Parent ?bb))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r) \n (Paths $?paths))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $?z) \n (Closed $?y))\n (object (is-a Region) \n (id ?r) \n (Entrances ?x $?))\n (object (is-a BasicBlock) \n (id ?x) \n (Paths $?allPaths))\n =>\n (printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n \" which is targeted for \" ?e crlf\n \"Blocks on the wavefront = \" ?z crlf\n \"Closed Blocks = \" ?y crlf\n \"For reference ?cpvPaths = \" ?cpvPaths crlf\n \"For reference aliases of ?cpv are = \" $?aliases crlf\n \"For reference ?paths = \" ?paths crlf\n \"Parent of \" ?p \" is \" ?bb crlf\n \"Printing out the path aggregate for \" ?p crlf )\n (send ?pa print)\n (progn$ (?apath ?allPaths)\n (bind ?aObj (instance-name (symbol-to-instance-name ?apath)))\n (printout t \" \" ?apath \" = \" (send ?aObj get-contents) crlf))\n (facts)\n (halt))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule AssertScheduleCPVIntoTargetBlock \n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t(object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t(object (is-a Diplomat) (ID ?e) (IsOpen TRUE))\n\t\t\t?agObj <- (object (is-a PathAggregate) (Parent ?e) \n\t\t\t\t\t\t\t\t\t(MovableCompensationPathVectors $?cpvs)) \n\t\t\t=>\n\t\t\t(if (> (length$ $?cpvs) 0) then\n\t\t\t (modify-instance ?agObj (MovableCompensationPathVectors)))\n\t\t\t(progn$ (?cpv $?cpvs)\n\t\t\t\t\t (assert (Determine schedule style for ?cpv into block ?e))))\n;------------------------------------------------------------------------------\n(defrule ScheduleStyleForCPVIsMove\n\t\t\t\"This rule attempts to determine if the CPV should be moved into the \n\t\t\tgiven block on the wavefront. If this is true then the fact to perform \n\t\t\tthis action will be asserted\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t?fct <- (Determine schedule style for ?cpv into block ?e)\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Paths $?paths))\n\t\t\t(object (is-a CompensationPathVector) (ID ?cpv)\n\t\t\t\t\t (Paths $?cpvPaths))\n\t\t\t;the two sets are the same\n\t\t\t(test (equal$ ?paths ?cpvPaths))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Move ?cpv into ?e)))\n;------------------------------------------------------------------------------\n(defrule ScheduleStyleForCPVIsCompensate\n\t\t\t\"This rule attempts to determine if the CPV should be copied into the \n\t\t\tgiven block on the wavefront. If this is true then the fact to perform \n\t\t\tthis action will be asserted.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t?fct <- (Determine schedule style for ?cpv into block ?e)\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Paths $?paths))\n\t\t\t(object (is-a CompensationPathVector) (ID ?cpv)\n\t\t\t\t\t (Paths $?cpvPaths) (Parent ?i))\n\t\t\t;there are more paths in the CPV than in the block\n\t\t\t(test (subsetp ?paths ?cpvPaths))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Clone ?cpv into ?e)))\n;------------------------------------------------------------------------------\n(defrule RemoveScheduleStyleForCPV\n\t\t\t(declare (salience 1))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t?fct <- (Determine schedule style for ?cpv into block ?e)\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Paths $?paths) (Parent ?q))\n\t\t\t(object (is-a CompensationPathVector) (ID ?cpv)\n\t\t\t\t\t (Paths $?cpvPaths) (Parent ?i))\n\t\t\t?agObj <- (object (is-a PathAggregate) (Parent ?e))\n\t\t\t(test (not (subsetp ?paths ?cpvPaths)))\n\t\t\t=>\n\t\t\t;TODO: Put code in here to delete a given instruction from the target\n\t\t\t; instruction list as well. \n\t\t\t;\n\t\t\t; Eventually, I will detect if we are in a loop. If we are then it is\n\t\t\t; necessary to figure out which paths remain in the loop and those\n\t\t\t; that exit. \n\t\t\t;this should prevent a potential infinite loop\n\t\t\t;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n\t\t\t(retract ?fct)\n\t\t\t(bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n\t\t\t(if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule MoveInstructionIntoBlock\n\t\t\t\"Moves the given object into bottom of the given block\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t?fct <- (Move ?cpv into ?e)\n\t\t\t?newBlock <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t\t\t(ID ?e) \n\t\t\t\t\t\t\t\t\t\t(Contents $?blockBefore ?last)\n (Produces $?nBProds))\n\t\t\t?agObj <- (object (is-a PathAggregate) \n\t\t\t\t\t\t\t\t\t(Parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n\t\t\t?terminator <- (object (is-a TerminatorInstruction) \n\t\t\t\t\t\t\t\t\t\t (Pointer ?tPtr) \n\t\t\t\t\t\t\t\t\t\t (ID ?last) \n\t\t\t\t\t\t\t\t\t\t (TimeIndex ?ti) \n\t\t\t\t\t\t\t\t\t\t (Parent ?e))\n\t\t\t?cpvObject <- (object (is-a CompensationPathVector) \n\t\t\t\t\t\t\t\t\t\t (ID ?cpv) \n\t\t\t\t\t\t\t\t\t\t (Parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n\t\t\t?newInst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t\t (ID ?inst) \n\t\t\t\t\t\t\t\t\t (Pointer ?nPtr) \n\t\t\t\t\t\t\t\t\t (Parent ?otherBlock) \n\t\t\t\t\t\t\t\t\t (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n\t\t\t\t\t\t\t\t\t (Class ?class))\n\t\t\t?oldBlock <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t\t\t(ID ?otherBlock) \n\t\t\t\t\t\t\t\t\t\t(Produces $?pBefore ?inst $?pRest)\n\t\t\t\t\t\t\t\t\t\t(Contents $?before ?inst $?rest))\n\t\t\t;TODO: add another rule where we have to update the consumers list as\n\t\t\t; well\n\t\t\t=>\n (object-pattern-match-delay\n\t\t\t;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n\t\t\t(modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n\t\t\t(modify-instance ?oldBlock (Contents $?before $?rest) \n\t\t\t\t\t\t\t\t (Produces $?pBefore $?pRest))\n\t\t\t;(modify-instance ?cpvObject (Paths))\n\t\t\t(assert (Remove evidence of ?inst from instructions $?niConsumers)\n\t\t\t\t\t\t\t\t ;(send ?newInst get-Consumers))\n\t\t\t\t\t (Recompute block ?otherBlock))\n\t\t\t(retract ?fct)\n\t\t\t(if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n\t\t\t ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n\t\t\t (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n\t\t\t (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n\t\t\t ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n\t\t\t ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n\t\t\t ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n\t\t\t else\n\t\t\t (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n\t\t\t ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n\t\t\t ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n\t\t\t ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n\t\t\t (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?newName ?last))\n\t\t\t (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n\t\t\t ;purge the list of producers and consumers\n\t\t\t (duplicate-instance ?inst to ?newName \n\t\t\t\t\t\t\t\t\t\t (ID ?newName) \n\t\t\t\t\t\t\t\t\t\t (Name ?newName)\n\t\t\t\t\t\t\t\t\t\t (Pointer ?newPtr) \n\t\t\t\t\t\t\t\t\t\t (Producers) \n\t\t\t\t\t\t\t\t\t\t (Consumers)\n\t\t\t\t\t\t\t\t\t\t (NonLocalDependencies) \n\t\t\t\t\t\t\t\t\t\t (LocalDependencies)\n\t\t\t\t\t\t\t\t\t\t (TimeIndex ?ti) \n\t\t\t\t\t\t\t\t\t\t (Parent ?e))\n\t\t\t (llvm-move-instruction-before ?newPtr ?tPtr)\n\t\t\t (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n\t\t\t ;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n\t\t\t ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule CloneInstructionIntoBlock\n\t\t\t\"Moves the given object into bottom of the given block\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t?fct <- (Clone ?cpv into ?e)\n\t\t\t?newBlock <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t\t\t(ID ?e) \n\t\t\t\t\t\t\t\t\t\t(Contents $?blockBefore ?last))\n\t\t\t?agObj <- (object (is-a PathAggregate) \n\t\t\t\t\t\t\t\t\t(Parent ?e))\n\t\t\t?terminator <- (object (is-a TerminatorInstruction) \n\t\t\t\t\t\t\t\t\t\t (Pointer ?tPtr) \n\t\t\t\t\t\t\t\t\t\t (ID ?last) \n\t\t\t\t\t\t\t\t\t\t (TimeIndex ?ti) \n\t\t\t\t\t\t\t\t\t\t (Parent ?e))\n\t\t\t?cpvObject <- (object (is-a CompensationPathVector) \n\t\t\t\t\t\t\t\t\t\t (ID ?cpv) \n\t\t\t\t\t\t\t\t\t\t (Parent ?inst) \n\t\t\t\t\t\t\t\t\t\t (Paths $?cpvPaths))\n\t\t\t?newInst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t\t (ID ?inst) \n\t\t\t\t\t\t\t\t\t (Pointer ?nPtr) \n\t\t\t\t\t\t\t\t\t (Parent ?otherBlock) \n\t\t\t\t\t\t\t\t\t (DestinationRegisters ?register) \n\t\t\t\t\t\t\t\t\t (Class ?class))\n\t\t\t=>\n\t\t\t;we also need to update all CPVs within \n\t\t\t(retract ?fct)\n (object-pattern-match-delay\n\t\t\t(bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n\t\t\t;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n\t\t\t; \" as \" ?newName crlf)\n\t\t\t(bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n\t\t\t;purge the list of producers and consumers\n\t\t\t(duplicate-instance ?inst to ?newName \n\t\t\t\t\t\t\t\t\t (ID ?newName) \n\t\t\t\t\t\t\t\t\t (Name ?newName)\n\t\t\t\t\t\t\t\t\t (Pointer ?newPtr) \n\t\t\t\t\t\t\t\t\t (Parent ?e)\n\t\t\t\t\t\t\t\t\t (TimeIndex (+ ?ti 1)))\n\t\t\t(llvm-move-instruction-before ?newPtr ?tPtr)\n\t\t\t;we add the original name so that we don't have to do\n\t\t\t; an insane number of updates to the CPVs that follow\n\t\t\t; this object\n\t\t\t(if (eq StoreInstruction ?class) then \n\t\t\t (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n\t\t\t else\n\t\t\t (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n\t\t\t (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n\t\t\t(slot-insert$ ?newBlock Produces 1 ?register)\n\t\t\t(modify-instance ?newBlock (Contents $?blockBefore ?newName ?last))\n\t\t\t(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n\t\t\t(slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n\t\t\t(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n\t\t\t(assert (Recompute block ?otherBlock)\n\t\t\t\t\t (Reopen blocks from ?cpv))\n\t\t\t(bind ?leftOvers (create$))\n\t\t\t(progn$ (?z ?cpvPaths)\n\t\t\t\t\t (bind ?cPath (symbol-to-instance-name ?z))\n\t\t\t\t\t (if (not (member$ ?e (send ?cPath get-Contents))) then\n\t\t\t\t\t\t (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n\t\t\t(modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule FAILURE-CLONE\n\t\t\t(declare (salience -768))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t(Clone ?cpv into ?e)\n\t\t\t(object (is-a CompensationPathVector) (ID ?cpv) (Parent ?p))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule FAILURE-MOVE\n\t\t\t(declare (salience -768))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t(Move ?cpv into ?e)\n\t\t\t(object (is-a CompensationPathVector) (ID ?cpv) (Parent ?p))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule FAILURE-SCHEDULE-STYLE\n\t\t\t(declare (salience -768))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Merge $?)\n\t\t\t(Determine schedule style for ?cpv into block ?e)\n\t\t\t?o <- (object (is-a CompensationPathVector) (ID ?cpv) (Parent ?p)\n\t\t\t\t\t\t\t (Paths $?cpvPaths))\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?e))\n\t\t\t(object (is-a Instruction) (ID ?p) (Parent ?bb))\n\t\t\t(object (is-a BasicBlock) (ID ?e) (Parent ?r) (Paths $?paths))\n\t\t\t(object (is-a Wavefront) (Parent ?r) (Contents $?z) (Closed $?y))\n\t\t\t(object (is-a Region) (ID ?r) (Entrances ?x $?))\n\t\t\t(object (is-a BasicBlock) (ID ?x) (Paths $?allPaths))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n\t\t\t\t\t\t \" which is targeted for \" ?e crlf\n\t\t\t\t\t\t \"Blocks on the wavefront = \" ?z crlf\n\t\t\t\t\t\t \"Closed Blocks = \" ?y crlf\n\t\t\t\t\t\t \"For reference ?cpvPaths = \" ?cpvPaths crlf\n\t\t\t\t\t\t \"For reference aliases of ?cpv are = \" \n\t\t\t\t\t\t (send ?o get-Aliases) crlf\n\t\t\t\t\t\t \"For reference ?paths = \" ?paths crlf\n\t\t\t\t\t\t \"Parent of \" ?p \" is \" ?bb crlf\n\t\t\t\t\t\t \"Printing out the path aggregate for \" ?p crlf )\n\t\t\t(send ?pa print)\n\t\t\t(progn$ (?apath ?allPaths)\n\t\t\t\t\t (printout t \" \" ?apath \" = \" \n\t\t\t\t\t\t\t\t\t(send (symbol-to-instance-name ?apath) \n\t\t\t\t\t\t\t\t\t\t\tget-Contents) \n\t\t\t\t\t\t\t\t\tcrlf))\n\t\t\t(facts)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0c98300be203cd843f706544695f32c3314bebf7","subject":"Added a conversion table","message":"Added a conversion table\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;\n; The functions that take in a fixed size array are easy because I can allocate\n; a static block ahead of time that I can read and write from. \n;------------------------------------------------------------------------------\n; Conversion table \n;------------------------------------------------------------------------------\n; float => all floating point types \n; int => all integer types\n; symbol => GLenum or GLboolean\n; multifield => pointer type or fixed array\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;\n; The functions that take in a fixed size array are easy because I can allocate\n; a static block ahead of time that I can read and write from. \n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"81ae4f246a2b50641a2fecb72df7ee7a25befebf","subject":"Fixed the module that the Message template belongs to","message":"Fixed the module that the Message template belongs to\n\nI made a typo and put type instead of types\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/types\/Message.clp","new_file":"lib\/durandal\/modules\/types\/Message.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Message.clp - Contains a message template useful in a wide variety of\n; situations\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Message.clp - Contains a message template useful in a wide variety of\n; situations\n;------------------------------------------------------------------------------\n(deftemplate type::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"05266519b7d2914a6347915d2d00489efb29c138","subject":"src\/lib\/cortex\/core: Added Message.clp","message":"src\/lib\/cortex\/core: Added Message.clp\n\nDefines the concept of a message for cross module communication.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/lib\/cortex\/core\/Message.clp","new_file":"src\/lib\/cortex\/core\/Message.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Message.clp - Contains the message template which is a standard way to pass\n; knowledge between modules that have no knowledge of one another.\n;\n; Use of messages also allows programmers to use modify and duplicate to cut\n; down on the amount of redundant typing which can potentially lead to a \n; reduction in the overall error rate.\n;------------------------------------------------------------------------------\n(deftemplate cortex::message\n \"Provides a communication medium between modules\"\n (slot to (type SYMBOL))\n (slot from (type SYMBOL))\n (slot action (type SYMBOL))\n (multislot arguments))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/lib\/cortex\/core\/Message.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"75ebe5fc2c576ea534cfd32e695731204d018026","subject":"branch","message":"branch\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"frame.clp","new_file":"frame.clp","new_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2\n;;howareyougit ","old_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2\n;;howareyou","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"a0bdcc8bdd920f5ce410047b08f8852bc438889f","subject":"new branch","message":"new branch\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"frame.clp","new_file":"frame.clp","new_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now","old_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9961d86656f4803adc6989cae9a7b4714b6bfdec","subject":"waltz: renamed duplicate since its a keyword in SFP","message":"waltz: renamed duplicate since its a keyword in SFP\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltz\/waltz.clp","new_file":"clipsfiles\/waltz\/waltz.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n;;; #################################################################\n;;; Deffunctions\n;;;\n;;; In the OPS5 version of this program, the following deffunctions\n;;; were implemented in C code that needed to be linked with the OPS5\n;;; interpreter. Using deffunctions allows the benchmark to be run\n;;; without having to recompile and relink CLIPS with the C code used\n;;; in the original benchmark. The performance impact of using\n;;; deffunctions for this benchmark rather than C code is minimal.\n;;; #################################################################\n\n(defglobal ?*MOD-NUM* = 100)\n\n;;; *****\n;;; atan2\n;;; *****\n\n(deffunction atan2 (?y ?x)\n (if (> ?x 0)\n then\n (return (atan (\/ ?y ?x))))\n\n (if (< ?x 0)\n then\n (return (- (atan (\/ ?y ?x)) (pi))))\n\n (if (> ?y 0) then\n then\n (return (pi)))\n\n (if (< ?y 0)\n then\n (return (- 0 (pi))))\n\n (return undefined))\n\n;;; *****\n;;; get-y\n;;; *****\n\n(deffunction get-y (?val)\n (mod ?val ?*MOD-NUM*))\n\n;;; *****\n;;; get-x\n;;; *****\n\n(deffunction get-x (?val)\n (integer (\/ ?val ?*MOD-NUM*)))\n\n;;; *********\n;;; get-angle\n;;; *********\n\n(deffunction get-angle (?p1 ?p2)\n (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n (if (= ?delta-x 0)\n then\n (if (> ?delta-y 0)\n\t\t then (return (\/ (pi) 2))\n\t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n else\n (if (= ?delta-y 0)\n then\n (if (> ?delta-x 0)\n then (return 0.0)\n\t\t else (if (< ?delta-x 0) then return (pi)))\n else\n (return (atan2 ?delta-y ?delta-x)))))\n\n;;; ***************\n;;; inscribed-angle\n;;; ***************\n\n(deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n\t;; Get the angle between line #1 and the origin and the angle\n\t;; between line #2 and the origin, and then subtract these values.\n\n (bind ?angle1 (get-angle ?basepoint ?p1))\n (bind ?angle2 (get-angle ?basepoint ?p2))\n (bind ?temp (- ?angle1 ?angle2))\n\n (if (< ?temp 0)\n then (bind ?temp (- 0 ?temp)))\n\n ;; We always want the smaller of the two angles inscribed, so\n ;; if the answer is greater than 180 degrees, calculate the\n ;; smaller angle and return it.\n\n (if (> ?temp (pi))\n then\n (bind ?temp (- (* 2 (pi)) ?temp)))\n\n (if (< ?temp 0)\n then (return (- 0 ?temp)))\n\n (return ?temp))\n\n;;; ***************\n;;; make-3-junction\n;;; ***************\n\n(deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n (bind ?sum1213 (+ ?angle12 ?angle13))\n (bind ?sum1223 (+ ?angle12 ?angle23))\n (bind ?sum1323 (+ ?angle13 ?angle23))\n\n (if (< ?sum1213 ?sum1223)\n then\n (if (< ?sum1213 ?sum1323)\n then\n (bind ?sum ?sum1213)\n (bind ?shaft ?p1)\n (bind ?barb1 ?p2)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2))\n else\n (if (< ?sum1223 ?sum1323)\n then\n (bind ?sum ?sum1223)\n (bind ?shaft ?p2)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2)))\n\n (bind ?delta (- ?sum (pi)))\n (if (< ?delta 0)\n then (bind ?delta (- 0 ?delta)))\n\n (if (< ?delta 0.001)\n then (bind ?jtype tee)\n else\n (if (> ?sum (pi))\n then (bind ?jtype fork)\n else (bind ?jtype arrow)))\n\n (assert (junction (p1 (integer ?barb1))\n (p2 (integer ?shaft))\n (p3 (integer ?barb2))\n (base_point (integer ?basepoint))\n (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","old_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n;;; #################################################################\n;;; Deffunctions\n;;;\n;;; In the OPS5 version of this program, the following deffunctions\n;;; were implemented in C code that needed to be linked with the OPS5\n;;; interpreter. Using deffunctions allows the benchmark to be run\n;;; without having to recompile and relink CLIPS with the C code used\n;;; in the original benchmark. The performance impact of using\n;;; deffunctions for this benchmark rather than C code is minimal.\n;;; #################################################################\n\n(defglobal ?*MOD-NUM* = 100)\n\n;;; *****\n;;; atan2\n;;; *****\n\n(deffunction atan2 (?y ?x)\n (if (> ?x 0)\n then\n (return (atan (\/ ?y ?x))))\n\n (if (< ?x 0)\n then\n (return (- (atan (\/ ?y ?x)) (pi))))\n\n (if (> ?y 0) then\n then\n (return (pi)))\n\n (if (< ?y 0)\n then\n (return (- 0 (pi))))\n\n (return undefined))\n\n;;; *****\n;;; get-y\n;;; *****\n\n(deffunction get-y (?val)\n (mod ?val ?*MOD-NUM*))\n\n;;; *****\n;;; get-x\n;;; *****\n\n(deffunction get-x (?val)\n (integer (\/ ?val ?*MOD-NUM*)))\n\n;;; *********\n;;; get-angle\n;;; *********\n\n(deffunction get-angle (?p1 ?p2)\n (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n (if (= ?delta-x 0)\n then\n (if (> ?delta-y 0)\n\t\t then (return (\/ (pi) 2))\n\t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n else\n (if (= ?delta-y 0)\n then\n (if (> ?delta-x 0)\n then (return 0.0)\n\t\t else (if (< ?delta-x 0) then return (pi)))\n else\n (return (atan2 ?delta-y ?delta-x)))))\n\n;;; ***************\n;;; inscribed-angle\n;;; ***************\n\n(deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n\t;; Get the angle between line #1 and the origin and the angle\n\t;; between line #2 and the origin, and then subtract these values.\n\n (bind ?angle1 (get-angle ?basepoint ?p1))\n (bind ?angle2 (get-angle ?basepoint ?p2))\n (bind ?temp (- ?angle1 ?angle2))\n\n (if (< ?temp 0)\n then (bind ?temp (- 0 ?temp)))\n\n ;; We always want the smaller of the two angles inscribed, so\n ;; if the answer is greater than 180 degrees, calculate the\n ;; smaller angle and return it.\n\n (if (> ?temp (pi))\n then\n (bind ?temp (- (* 2 (pi)) ?temp)))\n\n (if (< ?temp 0)\n then (return (- 0 ?temp)))\n\n (return ?temp))\n\n;;; ***************\n;;; make-3-junction\n;;; ***************\n\n(deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n (bind ?sum1213 (+ ?angle12 ?angle13))\n (bind ?sum1223 (+ ?angle12 ?angle23))\n (bind ?sum1323 (+ ?angle13 ?angle23))\n\n (if (< ?sum1213 ?sum1223)\n then\n (if (< ?sum1213 ?sum1323)\n then\n (bind ?sum ?sum1213)\n (bind ?shaft ?p1)\n (bind ?barb1 ?p2)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2))\n else\n (if (< ?sum1223 ?sum1323)\n then\n (bind ?sum ?sum1223)\n (bind ?shaft ?p2)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p3)\n else\n (bind ?sum ?sum1323)\n (bind ?shaft ?p3)\n (bind ?barb1 ?p1)\n (bind ?barb2 ?p2)))\n\n (bind ?delta (- ?sum (pi)))\n (if (< ?delta 0)\n then (bind ?delta (- 0 ?delta)))\n\n (if (< ?delta 0.001)\n then (bind ?jtype tee)\n else\n (if (> ?sum (pi))\n then (bind ?jtype fork)\n else (bind ?jtype arrow)))\n\n (assert (junction (p1 (integer ?barb1))\n (p2 (integer ?shaft))\n (p3 (integer ?barb2))\n (base_point (integer ?basepoint))\n (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicate)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicate))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicate))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n\n(defrule label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(defrule label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(defrule label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(defrule label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n\n(defrule label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(defrule label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(defrule label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(defrule label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"a4c5720e7af3841e54e9f6be9c9ede754620e6d9","subject":"Added basic user input prompt logic","message":"Added basic user input prompt logic\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"prompt.clp","new_file":"prompt.clp","new_contents":";The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The user input prompt, located in the USER-INPUT module\n;------------------------------------------------------------------------------\n(defmodule USER-INPUT\n (export ?ALL))\n(defclass USER-INPUT::input-state\n (is-a USER)\n (slot should-prompt\n (type SYMBOL)\n (allowed-symbols TRUE\n FALSE))\n (slot prompt\n (type STRING)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot raw-input\n (type STRING)\n (default-dynamic \"\"))\n (multislot decomposed-elements\n (visibility public)))\n\n(definstances USER-INPUT::initialization-of-input-state\n (of input-state\n (prompt \"> \")))\n\n(defrule USER-INPUT::read-input\n \"Read input from the end user\"\n ?f <- (object (is-a input-state)\n (should-prompt TRUE)\n (prompt ?prompt))\n =>\n (printout t ?prompt tab)\n (modify-instance ?f \n (should-prompt FALSE)\n (raw-input (bind ?rinput (readline)))\n (decomposed-elements (explode$ ?rinput))))\n\n(defrule USER-INPUT::reset-input\n (declare (salience -1))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE))\n =>\n (modify-instance ?f (should-prompt TRUE)))\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'prompt.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2846e4200a38ebb36ca8b77f44979a3a912d0607","subject":"added loop to get back to the main menu after the user chooses an option and finishes it","message":"added loop to get back to the main menu after the user chooses an option and finishes it\n","repos":"The4Ms\/family-knowledgebase","old_file":"UserInterface.clp","new_file":"UserInterface.clp","new_contents":"(defrule ShowMainMenu\n\t(not (Selected ?))\n=>\n\t(printout t \"- Infering relations about:\" crlf)\n\t(printout t \" 11- cousins \" crlf)\n\t(printout t \" 12- Nephews\" crlf)\n\t(printout t \" 13- Nieces\" crlf)\n\t(printout t \" 14- Uncle\" crlf)\n\t(printout t \" 15- Aunt\" crlf)\n\t(printout t \" 16- Grandfather\" crlf)\n\t(printout t \" 17- Grandmother\" crlf)\n\t(printout t \"- Familly knowledge base\" crlf)\n\t(printout t \" 21- Display a familly member by name\" crlf)\n\t(printout t \" 22- Display a familly member by parent\" crlf)\n\t(printout t \" 23- Add family member\" crlf)\n\t(printout t \" 24- Remove family member\" crlf)\n\t(printout t \"- Modify family member properties\" crlf)\n\t(printout t \" 31- Modify familly member name\" crlf)\n\t(printout t \" 32- Modify familly member gender\" crlf)\n\t(printout t \" 33- Modify familly member birthyear\" crlf)\n\t(printout t \" 34- Modify familly member height\" crlf)\n\t(printout t \" 35- Modify familly member parents\" crlf)\n\t(printout t \" 36- Modify familly member siblings\" crlf)\n\t(printout t \" 37- Modify familly member spouse\" crlf)\n\t(printout t \"- Search familly members by properties\" crlf)\n\t(printout t \" 41- Show all individuals that match a combination of properties familly knowledge base\" crlf)\n\n\t(bind ?selectedOption (read))\n\n\t(assert(Selected ?selectedOption))\n)\n\n(defrule ClearSelected\n\t(declare (salience -10000))\n\n\t?selectedIndex <- (Selected ?)\n=>\n\t(retract ?selectedIndex)\n)\n\n(defrule GetQueryData\n\t(Selected 41)\n=>\n\t(printout t \"Enter the criteria to search upon in the same order, write 'all' if you do not care about a specific property:\" crlf)\n\t\n\t(printout t \"What is the gender ? (m or f) or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryGender ?answer))\n\n\t(printout t \"What is the spouse name ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySpouse ?answer))\n\t\n\t(printout t \"What is the name of one of parents ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryParent ?answer))\n\t\n\t(printout t \"What is the name of one of siblings ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySiblings ?answer))\n\t\n\t(printout t \"What is the height range ? (equals to|greater than|less than) then press enter then input the height or write 'all'\" crlf)\n\t(bind ?type (readline))\n\t(bind ?height (read))\n\t(assert (QueryHeight ?type ?height))\n\t(printout t ?type crlf)\n\n)\n","old_contents":"(defrule ShowMainMenu\n\n=>\n\t(printout t \"- Infering relations about:\" crlf)\n\t(printout t \" 11- cousins \" crlf)\n\t(printout t \" 12- Nephews\" crlf)\n\t(printout t \" 13- Nieces\" crlf)\n\t(printout t \" 14- Uncle\" crlf)\n\t(printout t \" 15- Aunt\" crlf)\n\t(printout t \" 16- Grandfather\" crlf)\n\t(printout t \" 17- Grandmother\" crlf)\n\t(printout t \"- Familly knowledge base\" crlf)\n\t(printout t \" 21- Display a familly member by name\" crlf)\n\t(printout t \" 22- Display a familly member by parent\" crlf)\n\t(printout t \" 23- Add family member\" crlf)\n\t(printout t \" 24- Remove family member\" crlf)\n\t(printout t \"- Modify family member properties\" crlf)\n\t(printout t \" 31- Modify familly member name\" crlf)\n\t(printout t \" 32- Modify familly member gender\" crlf)\n\t(printout t \" 33- Modify familly member birthyear\" crlf)\n\t(printout t \" 34- Modify familly member height\" crlf)\n\t(printout t \" 35- Modify familly member parents\" crlf)\n\t(printout t \" 36- Modify familly member siblings\" crlf)\n\t(printout t \" 37- Modify familly member spouse\" crlf)\n\t(printout t \"- Search familly members by properties\" crlf)\n\t(printout t \" 41- Show all individuals that match a combination of properties familly knowledge base\" crlf)\n\n\t(bind ?selectedOption (read))\n\n\t(assert(Selected ?selectedOption))\n)\n\n(defrule GetQueryData\n\t(Selected 41)\n=>\n\t(printout t \"Enter the criteria to search upon in the same order, write 'all' if you do not care about a specific property:\" crlf)\n\t\n\t(printout t \"What is the gender ? (m or f) or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryGender ?answer))\n\n\t(printout t \"What is the spouse name ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySpouse ?answer))\n\t\n\t(printout t \"What is the name of one of parents ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QueryParent ?answer))\n\t\n\t(printout t \"What is the name of one of siblings ? or write 'all'\" crlf)\n\t(bind ?answer (read))\n\t(assert (QuerySiblings ?answer))\n\t\n\t(printout t \"What is the height range ? (equals to|greater than|less than) then press enter then input the height or write 'all'\" crlf)\n\t(bind ?type (readline))\n\t(bind ?height (read))\n\t(assert (QueryHeight ?type ?height))\n\t(printout t ?type crlf)\n\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9f6dfdb90d27c9f1ee0d3b3eb9b94a7b56b30b2e","subject":"Interactable.clp: Added a description slot and associate message handler","message":"Interactable.clp: Added a description slot and associate message handler\n\nThe message handler prints the description out to the screen\n","repos":"DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"src\/lib\/dendrite\/Interactable.clp","new_file":"src\/lib\/dendrite\/Interactable.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Interactable.clp - Base class of all interactable things\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n(defclass dendrite::Interactable\n \"Base class of all interactable things\"\n (is-a Object)\n (slot description (visibility public))\n (message-handler describe primary))\n;------------------------------------------------------------------------------\n(defmessage-handler dendrite::Interactable describe primary ()\n\t\t\t\t\t\t (printout t ?self:description crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Interactable.clp - Base class of all interactable things\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n(defclass dendrite::Interactable\n \"Base class of all interactable things\"\n (is-a Object))\n;TODO: Add more slots if necessary\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"9daa4a1687ac2aecc9addb1f7782b6dfd815682a","subject":"Added x.clp, the easiest way to build a library","message":"Added x.clp, the easiest way to build a library\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"x.clp","new_file":"x.clp","new_contents":"(defclass Pointer\n (is-a USER)\n (slot pointer \n (type EXTERNAL-ADDRESS)\n (access initialize-only)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot pointer-class\n (type SYMBOL)\n (storage shared)\n (create-accessor read)\n (visibility public)\n (access read-only)\n (default unknown)))\n; \/lib\/chicanery\/input.clp - Contains methods and classes for handling the\n; chicanery input layer\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n; \/lib\/chicanery\/menu.clp - Contains methods and classes to simplify accessing\n; menus\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric defmenu)\n(defgeneric translate-menu-id)\n(defclass Menu\n (is-a Pointer)\n (slot pointer-class \n (source composite)\n (default menu))\n (multislot menu-elements\n (type LEXEME)\n (storage local)\n (access initialize-only)\n (default ?NONE))\n (message-handler show-menu primary))\n\n(defmessage-handler Menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n ($?entries LEXEME))\n (defmenu ?name ?entries))\n(defmethod defmenu\n \"Constructs a Menu object and corresponding pointer\"\n ((?name SYMBOL)\n (?entries MULTIFIELD LEXEME))\n (make-instance ?name of Menu\n (pointer (quickmenu ?entries))\n (menu-elements ?entries)))\n\n(defmethod translate-menu-id\n \"If we get -1 back then return the nil symbol\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n nil)\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n(defgeneric defrectangle)\n(defgeneric quickrect)\n(defgeneric defpixel)\n(defgeneric pixel:nxn)\n(defgeneric pixel:1x1)\n\n(defclass Rectangle\n (is-a Pointer)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot bx\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Rectangle get-points () \n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n\n(defmethod defrectangle \n \"Creates a new rectangle object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (make-instance ?name of Rectangle \n (x ?x) \n (y ?y)\n (bx ?bx)\n (by ?by)\n (pointer (quickrect ?x ?y ?bx ?by))))\n(defmethod defrectangle\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (defrectangle (gensym*) ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(defmethod defpixel\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER)\n (?factor INTEGER))\n (defrectangle ?name ?x ?y (+ ?x ?factor) (+ ?y ?factor)))\n\n(defmethod pixel:nxn\n ((?x INTEGER)\n (?y INTEGER)\n (?n INTEGER))\n (quickrect ?x ?y (+ ?x ?n) (+ ?y ?n)))\n\n(defmethod pixel:nxn\n ((?n INTEGER))\n (pixel:nxn 0 0 ?n))\n\n(defmethod pixel:1x1\n ((?x INTEGER)\n (?y INTEGER))\n (pixel:nxn ?x ?y 1))\n\n(defmethod pixel:1x1 () \n (pixel:1x1 0 0))\n\n(definstances default-rect-classes\n (rect:single-pixel of Rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)\n (pointer (quickrect 0 0 1 1))))\n\n; \/lib\/chicanery\/color.clp - Routines for handling chicanery color features\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n; point.clp - classes and methods to wrap around the Point native type\n\n(defgeneric quickpoint)\n(defgeneric defpoint)\n(defgeneric to-point)\n(defclass Point\n (is-a Pointer)\n (slot pointer-class \n (source composite)\n (default Point))\n (slot x\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (access initialize-only)\n (storage local)\n (default ?NONE))\n (message-handler get-points primary))\n\n(defmessage-handler Point get-points ()\n (create$ ?self:x ?self:y))\n\n(defmethod defpoint\n \"Creates a new point object and corresponding pointer\"\n ((?name SYMBOL INSTANCE-NAME)\n (?x INTEGER)\n (?y INTEGER))\n (make-instance ?name of Point\n (x ?x)\n (y ?y)\n (pointer (quickpoint ?x ?y))))\n\n(defmethod defpoint\n ((?x INTEGER)\n (?y INTEGER))\n (defpoint (gensym*) ?x ?y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n\n(definstances default-point-classes\n (ZP of Point \n (x 0) \n (y 0)\n (pointer (quickpoint 0 0))))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'x.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"1646d84f74c0a9e19cbd2e6ef28d91f21b2791fe","subject":"Moved the delete-still-existing-elements rule to build-groups","message":"Moved the delete-still-existing-elements rule to build-groups\n\nThis was done so that I could make the following module for updating grouping\nelements and generating associated code.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n;(defrule grouping-update::\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule retract-invalid-elements\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n retract-invalid-elements)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule retract-invalid-elements::delete-still-existing-elements\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (send ?obj print)\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"3b1e1534f808152ee7aa8889b2bc3f7fd8f44f42","subject":"update beer-knowledge.clp","message":"update beer-knowledge.clp","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-knowledge.clp","new_file":"clips\/beer-knowledge.clp","new_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous classic)\n (pizza-topping-for-vegetarian classic)\n (pizza-topping-for-vegan classic))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-or-vegetarian-is-cheese\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous cheese)\n (pizza-topping-for-vegetarian cheese))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Creme\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork-or-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich pork))\n (which-meat steak))\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter-or-which-entree-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n","old_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous classic)\n (pizza-topping-for-vegetarian classic)\n (pizza-topping-for-vegan classic))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-or-vegetarian-is-cheese\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous cheese)\n (pizza-topping-for-vegetarian cheese))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Cr\u00e8me\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork-or-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich pork))\n (which-meat steak))\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter-or-which-entree-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"05b167abff85d0883d81831363dc01fa189bb563","subject":"Fixed a bug with the init after message of the wavefront class","message":"Fixed a bug with the init after message of the wavefront class\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Wavefront.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Wavefront.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass types::Wavefront \n (is-a ParentedHint)\n (multislot Open (visibility public))\n (multislot DeleteNodes (visibility public))\n (multislot Closed (visibility public)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Wavefront init after ()\n (bind ?self:type Wavefront))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass types::Wavefront \n (is-a ParentedHint)\n (multislot Open (visibility public))\n (multislot DeleteNodes (visibility public))\n (multislot Closed (visibility public)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Wavefront init after ()\n (bind ?self:Type Wavefront))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"1e610af06468bdb009ac535899118cf70c377cf9","subject":"Added the merged core.clp","message":"Added the merged core.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/core.clp","new_file":"lib\/durandal\/modules\/core\/core.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012-2015, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; All of the core functions, objects, modules, etc\n;------------------------------------------------------------------------------\n; In CLIPS, modules are defined BEFORE their corresponding contents are defined\n; so this file doubles as a loader as well. Absolute paths must be used because \n; CLIPS does not understand the concept of partial paths. \n;\n; If you want to change the layout of this module then you must update these\n; paths. Failure to do so will cause the optimization to not work correctly.\n;------------------------------------------------------------------------------\n\n(defmodule core \n ; Modify this export to add more classes\n ; Just remember that these three classes are pretty critical to the rest of\n ; the optimization\n (export defclass ?ALL) \n ; Modify this export to add more functions to be exposed\n ; I would advise against removing these functions\n (export deffunction ?ALL))\n\n;(load* \"modules\/core\/Object.clp\")\n;(load* \"modules\/core\/ParentedObject.clp\")\n;(load* \"modules\/core\/InteropObject.clp\")\n;(load* \"modules\/core\/Hint.clp\")\n;(load* \"modules\/core\/List.clp\")\n;(load* \"modules\/core\/ParentedHint.clp\")\n;(load* \"modules\/core\/ParentedList.clp\")\n;(load* \"modules\/core\/Environment.clp\")\n; Add more defclasses here\n; The programmer is responsible for ordering the load statements so that\n; class dependencies are met\n;(load* \"modules\/core\/SetExtensions.clp\")\n;(load* \"modules\/core\/DefModuleExtensions.clp\")\n; Add more deffunctions here\n; The programmer is responsible for ordering the load statements so that\n; function dependencies are met\n\n\n\n;------------------------------------------------------------------------------\n(defclass core::object \n \"Base class of all objects\"\n (is-a USER)\n (slot parent\n (type INSTANCE\n SYMBOL)\n (allowed-symbols nil)\n (storage local)\n (visibility public)))\n;------------------------------------------------------------------------------\n(defclass core::has-contents\n \"Denotes that a class has contents\"\n (is-a USER)\n (multislot contents \n (visibility public)))\n;------------------------------------------------------------------------------\n; InteropObject - An interface that exposes a pointer address. It does not\n; inherit from Object\n;------------------------------------------------------------------------------\n(defclass core::interop\n \"Interface to an item outside of the CLIPS environment\"\n (is-a USER)\n (slot pointer \n (type INTEGER \n EXTERNAL-ADDRESS) \n (visibility public)))\n\n;uncomment this code and watch the LLVM PassManager fail with a general\n;protection fault\n\n;(defmessage-handler core::interop init around \n; () \n; (call-next-handler)\n; (if (and (numberp ?self:pointer)\n; (not (= 0 ?self:pointer))) then\n; (bind ?self:pointer (to-pointer ?self:pointer))))\n;------------------------------------------------------------------------------\n; Hint.clp - An object used to signify something is a hint. It also has the\n; ability to be reference counted if necessary\n;------------------------------------------------------------------------------\n(defclass core::hint \n \"An object that makes it easy to create temporary entities.\"\n (is-a object)\n (multislot values \n (visibility public))\n (slot reference-count \n (type NUMBER) \n (visibility public))\n (slot type \n (visibility public) \n (type SYMBOL))\n (slot point \n (visibility public) \n (type SYMBOL))\n (message-handler increment-reference-count \n primary)\n (message-handler decrement-reference-count \n primary))\n;------------------------------------------------------------------------------\n(defmessage-handler core::hint increment-reference-count primary \n \"Incrementes the reference count of the given hint. If no parameters are given \n then the default is one. If a parameter is given then that is the value \n incremented by. If more than one parameter is given then those numbers are \n added together and then added to the current reference count\"\n ($?by)\n (bind ?self:reference-count \n (+ ?self:reference-count\n (expand$ (if (= (length$ ?by) 0) then\n (create$ 1)\n else\n ?by)))))\n;------------------------------------------------------------------------------\n(defmessage-handler core::hint decrement-reference-count primary\n \"Decrements the reference count of the given hint. If no parameters are given \n then the default is one. If a parameter is given then that is the value \n decremented by. If more than one parameter is given then those numbers are \n added together and then subtracted from the current reference count\"\n ($?by)\n (bind ?self:reference-count \n (- ?self:reference-count\n (expand$ (if (= (length$ ?by) 0) then\n (create$ 1)\n else\n ?by)))))\n;------------------------------------------------------------------------------\n; set functions\n;------------------------------------------------------------------------------\n(deffunction core::superset \n \"Checks to see if ?a is a superset of ?b\"\n (?a ?b)\n (and (>= (length$ ?a) \n (length$ ?b))\n (subsetp ?b \n ?a) \n (not (subsetp ?a \n ?b))))\n;------------------------------------------------------------------------------\n(deffunction core::equal$ \n \"Checks to see if the two multifields have the same contents\"\n (?a ?b)\n (and (= (length$ ?a) \n (length$ ?b))\n (subsetp ?b \n ?a) \n (subsetp ?a \n ?b)))\n;------------------------------------------------------------------------------\n(deffunction core::has-common-element \n \"Checks to see if the given multifields have an element in common\"\n (?a ?b)\n (progn$ (?c ?a)\n (if (member$ ?c ?b) then \n (return TRUE)))\n FALSE)\n;------------------------------------------------------------------------------\n(deffunction core::disjoint \n \"Checks to see if ?a and ?b have nothing in common\"\n (?a ?b)\n (not (has-common-element ?a \n ?b)))\n;------------------------------------------------------------------------------\n; defmodule functions\n;------------------------------------------------------------------------------\n(deffunction core::defmodule-exists \n \"Checks to see if the given name is a defined module\"\n (?name)\n (member$ ?name\n (get-defmodule-list))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/modules\/core\/core.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c41b338dfac7050e22eb450b8aecdad0b9f685b7","subject":"Added a docstring to list.clp","message":"Added a docstring to list.clp\n","repos":"DrItanium\/LibExpertSystem,DrItanium\/LibExpertSystem","old_file":"clips\/Types\/List.clp","new_file":"clips\/Types\/List.clp","new_contents":"(defclass List (is-a TaggedObject) \n \"An ancient class that is a remnant of when I tried to apply procedural\n aspects to expert system programming...what a dumb idea. Oh well I leave it\n here for legacy purposes. I will warn any who use this class that message\n passing is EXTREMELY slow for compiler optimizations.\"\n (slot Length (type NUMBER) (default-dynamic 0))\n (multislot Contents (visibility public)))\n\n(defmessage-handler List .Add (?element)\n (slot-direct-insert$ Contents (+ ?self:Length 1) ?element)\n (bind ?self:Length (+ ?self:Length 1)))\n\n(defmessage-handler List .AddBefore (?point ?element)\n (bind ?ind (nth$ ?point ?self:Contents))\n (slot-direct-insert$ Contents ?ind ?element)\n (bind ?self:Length (+ 1 ?self:Length)))\n \n(defmessage-handler List .AddAfter (?point ?element)\n (bind ?ind (+ 1 (nth$ ?point ?self:Contents)))\n (slot-direct-insert$ Contents ?ind ?element)\n (bind ?self:Length (+ 1 ?self:Length)))\n\n(defmessage-handler List .Remove (?element)\n (bind ?self:Length (- ?self:Length 1))\n (bind ?self:Contents (delete-member$ ?self:Contents ?element)))\n\n(defmessage-handler List .RemoveAt (?index)\n (bind ?self:Contents (- ?self:Length 1))\n (slot-direct-delete$ Contents ?index ?index))\n\n\n(defmessage-handler List .AddRangeAt (?index $?elements)\n (slot-direct-insert$ Contents ?index $?elements))\n\n(defmessage-handler List .ElementAt (?index)\n (nth$ ?index ?self:Contents))\n\n(defmessage-handler List .Contains (?item)\n (neq (member$ ?item ?self:Contents) FALSE))\n\n(defmessage-handler List .ContainsSubset ($?subset)\n (subsetp ?subset ?self:Contents))\n","old_contents":"(defclass List (is-a TaggedObject)\n (slot Length (type NUMBER) (default-dynamic 0))\n (multislot Contents (visibility public)))\n\n(defmessage-handler List .Add (?element)\n (slot-direct-insert$ Contents (+ ?self:Length 1) ?element)\n (bind ?self:Length (+ ?self:Length 1)))\n\n(defmessage-handler List .AddBefore (?point ?element)\n (bind ?ind (nth$ ?point ?self:Contents))\n (slot-direct-insert$ Contents ?ind ?element)\n (bind ?self:Length (+ 1 ?self:Length)))\n \n(defmessage-handler List .AddAfter (?point ?element)\n (bind ?ind (+ 1 (nth$ ?point ?self:Contents)))\n (slot-direct-insert$ Contents ?ind ?element)\n (bind ?self:Length (+ 1 ?self:Length)))\n\n(defmessage-handler List .Remove (?element)\n (bind ?self:Length (- ?self:Length 1))\n (bind ?self:Contents (delete-member$ ?self:Contents ?element)))\n\n(defmessage-handler List .RemoveAt (?index)\n (bind ?self:Contents (- ?self:Length 1))\n (slot-direct-delete$ Contents ?index ?index))\n\n\n(defmessage-handler List .AddRangeAt (?index $?elements)\n (slot-direct-insert$ Contents ?index $?elements))\n\n(defmessage-handler List .ElementAt (?index)\n (nth$ ?index ?self:Contents))\n\n(defmessage-handler List .Contains (?item)\n (neq (member$ ?item ?self:Contents) FALSE))\n\n(defmessage-handler List .ContainsSubset ($?subset)\n (subsetp ?subset ?self:Contents))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"4ec372813d984f15eeb057e2bc7ca9c49d32a6ab","subject":"Modified the type fields in assert-build-groups and build-grouping","message":"Modified the type fields in assert-build-groups and build-grouping\n\nI reverted the type field in assert-build-groups back to ~UNKNOWN and added\n(type #define) to build-grouping instead. This change makes it possible to\nclean out the GLAPI-DEF instances along with the other objects\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_file":"src\/tools\/conv\/gl\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (object (is-a heading-span)\n (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type #define) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule grouping-update::generate-constant-if-statement\n (object (is-a heading-span)\n (header-name ?group)\n (contents $? ?name $?))\n ?obj <- (object (is-a file-line) \n (id ?name)\n (type #define)\n (contents ?element))\n =>\n (bind ?str (str-cat ?element))\n (printout t (format nil \"\/\/%s\" ?group) crlf \n (format nil \"if(strcmp(input,\\\"%s\\\")) { return %s; }\" \n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str)\n ?element) crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"d8b10ecefa29efde3b70a4b11096374abb2b2fd6","subject":"overwrote the pointer fact in Environment","message":"overwrote the pointer fact in Environment\n\nThe only number allowed is zero which makes it easier to figure out if this is\na copy or not.\n\nA message handler was added (init around) so that we can automatically\ninitialize an environment when a new environment object is created. It is up to\nthe end user to make the newly created environment aware of the creating\nenvironment if they want.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL_ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (dynamic-default 0))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment (is-a Object InteropObject))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2ed99a96b88a4a6da91f27b2c36990442b4b20c2","subject":"Rearranged several test conditions in LoopRegionMerging.clp","message":"Rearranged several test conditions in LoopRegionMerging.clp\n\nThis should improve performance of equivalence and ownership claims due to the\nfact that if the length checks fail then there is no need to evaluate the\nsubsetp commands which are far more expensive.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/LoopRegionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n\t\t\t\"Creates a flat representation of the contents of the given region\"\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?id) \n\t\t\t\t\t (contents $?z))\n\t\t\t(not (exists (object (is-a FlatList) \n\t\t\t\t\t\t\t\t\t\t(parent ?id))))\n\t\t\t=>\n\t\t\t(make-instance of FlatList \n\t\t\t\t\t\t\t\t(parent ?id)) \n\t\t\t(assert (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action populate-flatlist)\n\t\t\t\t\t\t\t\t (arguments ?id => $?z))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n\t\t\t?f <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t(action populate-flatlist)\n\t\t\t\t\t\t\t\t(arguments ?id => ?first $?rest))\n\t\t\t?o <- (object (is-a FlatList) \n\t\t\t\t\t\t\t (parent ?id))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?first))\n\t\t\t=>\n\t\t\t(slot-insert$ ?o values 1 ?first)\n\t\t\t(modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n\t\t\t?f <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t(action populate-flatlist)\n\t\t\t\t\t\t\t\t(arguments ?id => ?first $?rest))\n\t\t\t?o <- (object (is-a FlatList) \n\t\t\t\t\t\t\t (parent ?id))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?first))\n\t\t\t(object (is-a FlatList) \n\t\t\t\t\t (parent ?first) \n\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t;Add the reference to FlatList for the time being until we have\n\t\t\t;finished constructing an entire flat list\n\t\t\t(slot-insert$ ?o values 1 ?name)\n\t\t\t(modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n\t\t\t?f <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t(action populate-flatlist)\n\t\t\t\t\t\t\t\t(arguments ?id =>))\n\t\t\t=>\n\t\t\t(retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n\t\t\t\"Takes a flat list and expands one of the elements of the contents if \n\t\t\tit turns out that element is another flat list\"\n\t\t\t?id <- (object (is-a FlatList) \n\t\t\t\t\t\t\t\t(values $?a ?b $?c))\n\t\t\t(object (is-a FlatList) \n\t\t\t\t\t (id ?b) \n\t\t\t\t\t (values $?j))\n\t\t\t=>\n\t\t\t(modify-instance ?id (values $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n\t\t\t\"Asserts that a region owns another through a subset check. The first \n\t\t\tflat list is checked to see if it is a _proper_ subset of the second\"\n\t\t\t(object (is-a FlatList) \n\t\t\t\t\t (id ?i0) \n\t\t\t\t\t (values $?c0) \n\t\t\t\t\t (parent ?p0))\n\t\t\t(object (is-a FlatList) \n\t\t\t\t\t (id ?i1&~?i0) \n\t\t\t\t\t (values $?c1) \n\t\t\t\t\t (parent ?p1))\n\t\t\t(test (and (> (length$ ?c1) \n\t\t\t\t\t\t\t (length$ ?c0))\n\t\t\t\t\t\t (subsetp ?c0 ?c1)))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n\t\t\t\"This rule is used to assert ownership claims on basic blocks\"\n\t\t\t?f0 <- (object (is-a FlatList) \n\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t(values $? ?b $?))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?b))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?p => ?b))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n\t\t\t\"Asserts that two regions are equivalent if one flat list contains the\n\t\t\tsame elements as a second one.\"\n\t\t\t?f0 <- (object (is-a FlatList) \n\t\t\t\t\t\t\t\t(id ?i0) \n\t\t\t\t\t\t\t\t(values $?c0) \n\t\t\t\t\t\t\t\t(parent ?p0))\n\t\t\t?f1 <- (object (is-a FlatList) \n\t\t\t\t\t\t\t\t(id ?i1&~?i0) \n\t\t\t\t\t\t\t\t(values $?c1) \n\t\t\t\t\t\t\t\t(parent ?p1))\n\t\t\t(test (and (= (length$ ?c1) \n\t\t\t\t\t\t\t (length$ ?c0))\n\t\t\t\t\t\t (subsetp ?c0 ?c1)))\n\t\t\t=>\n\t\t\t(assert (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n\t\t\t\"It is possible for two facts of equivalence to actually be the same \n\t\t\tfact\"\n\t\t\t(declare (salience -1))\n\t\t\t?f0 <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))\n\t\t\t?f1 <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?b => ?a))\n\t\t\t=>\n\t\t\t(retract ?f1)\n\t\t\t(modify ?f0 (arguments ?a => ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region \n\t\t\tdies. The loop is the first entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))\n\t\t\t(object (is-a Loop) \n\t\t\t\t\t (id ?a))\n\t\t\t(object (is-a Region&~Loop) \n\t\t\t\t\t (id ?b))\n\t\t\t=>\n\t\t\t(duplicate ?f0 (action delete-region)\n\t\t\t\t\t\t (arguments ?b))\n\t\t\t(modify ?f0 (action replace)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n\t\t\t\"If we find an equivalence then it means that a loop and a region \n\t\t\tcontain the same elements. Therefore the loop persists and the region\n\t\t\tdies. The loop is the second entry.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-equivalent) \n\t\t\t\t\t\t\t\t (arguments ?b => ?a))\n\t\t\t(object (is-a Loop) \n\t\t\t\t\t (id ?a))\n\t\t\t(object (is-a Region&~Loop) \n\t\t\t\t\t (id ?b))\n\t\t\t=>\n\t\t\t(duplicate ?f0 (action delete-region)\n\t\t\t\t\t\t (arguments ?b))\n\t\t\t(modify ?f0 (action replace)))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n\t\t\t\"We target claims of ownership that deal with a given region that has \n\t\t\tto be replaced by another due to equivalence\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ?old => ?new))\n\t\t\t?f1 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?old => ?other))\n\t\t\t=>\n\t\t\t(modify ?f0)\n\t\t\t(modify ?f1 (arguments ?new => ?other)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ?old => ?new))\n\t\t\t?f1 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action claim-owns)\n\t\t\t\t\t\t\t\t (arguments ?other => ?old))\n\t\t\t=>\n\t\t\t(modify ?f0)\n\t\t\t(modify ?f1 (arguments ?other => ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n\t\t\t\"Retract replacement facts because there are no more claims to worry \n\t\t\tabout\"\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action replace)\n\t\t\t\t\t\t\t\t (arguments ? => ?))\n\t\t\t=>\n\t\t\t(retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::DeleteTargetRegion\n\t\t\t\"Deletes the target region slated for deletion\"\n\t\t\t?f0 <- (message (to loop-region-merging)\n\t\t\t\t\t\t\t\t (action delete-region)\n\t\t\t\t\t\t\t\t (arguments ?r0))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?r0))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::initiate-deletion\n\t\t\t\"Retracts the initial fact for this module and asserts local facts for\n\t\t\tdeleting flat lists and ownership determinants\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to loop-region-merging-cleanup-merger)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(assert (delete ownership-determinants)\n\t\t\t\t\t (delete flat-lists)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::DeleteFlatLists \n\t\t\t\"Deletes all of the flat lists in a single rule fire\"\n\t\t\t?f0 <- (delete flat-lists)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n\t\t\t\t\t (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoopRegionMerging.clp - Contains rules that merge loops and regions together\n; Written by Joshua Scoggins (6\/26\/2012)\n;\n; Major Rewrite started on 10\/22\/2012 to reflect changes made to \n; LibExpertSystem\n;------------------------------------------------------------------------------\n; The first thing to understand is that LibExpertSystem will no longer be\n; lifting a finger to assist us in merging loops and regions. I did a thought\n; experiment and I realized that it will be easier this way to ensure proper\n; merging and (by proxy) ordering. \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::ConstructFlatListForRegion\n \"Creates a flat representation of the contents of the given region\"\n (object (is-a Region) \n (id ?id) \n (contents $?z))\n (not (exists (object (is-a FlatList) \n (parent ?id))))\n =>\n (make-instance of FlatList (parent ?id)) \n (assert (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => $?z))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-BasicBlock\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => ?first $?rest))\n ?o <- (object (is-a FlatList) \n (parent ?id))\n (object (is-a BasicBlock) \n (id ?first))\n =>\n (slot-insert$ ?o values 1 ?first)\n (modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::PopulateFlatList-Region\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id => ?first $?rest))\n ?o <- (object (is-a FlatList) \n (parent ?id))\n (object (is-a Region) \n (id ?first))\n (object (is-a FlatList) \n (parent ?first) \n (id ?name))\n =>\n ;Add the reference to FlatList for the time being until we have\n ;finished constructing an entire flat list\n (slot-insert$ ?o values 1 ?name)\n (modify ?f (arguments ?id => $?rest)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-build::RetractFlatListConstruction\n ?f <- (message (to loop-region-merging)\n (action populate-flatlist)\n (arguments ?id =>))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-expand::ExpandFlatListEntry\n \"Takes a flat list and expands one of the elements of the contents if \n it turns out that element is another flat list\"\n ?id <- (object (is-a FlatList) \n (values $?a ?b $?c))\n (object (is-a FlatList) \n (id ?b) \n (values $?j))\n =>\n (modify-instance ?id (values $?a $?j $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnership\n \"Asserts that a region owns another through a subset check. The first \n flat list is checked to see if it is a _proper_ subset of the second\"\n ?f0 <- (object (is-a FlatList) \n (id ?i0) \n (values $?c0) \n (parent ?p0))\n ?f1 <- (object (is-a FlatList) \n (id ?i1&~?i0) \n (values $?c1) \n (parent ?p1))\n (test (and (subsetp ?c0 ?c1) \n (> (length$ ?c1) \n (length$ ?c0))))\n =>\n (assert (message (to loop-region-merging) \n (action claim-owns) \n (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimOwnershipOfBlocks\n \"This rule is used to assert ownership claims on basic blocks\"\n ?f0 <- (object (is-a FlatList) \n (parent ?p) \n (values $? ?b $?))\n (object (is-a BasicBlock) \n (id ?b))\n =>\n (assert (message (to loop-region-merging) \n (action claim-owns) \n (arguments ?p => ?b))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::ClaimEquivalence\n \"Asserts that two regions are equivalent if one flat list contains the\n same elements as a second one.\"\n ?f0 <- (object (is-a FlatList) \n (id ?i0) \n (values $?c0) \n (parent ?p0))\n ?f1 <- (object (is-a FlatList) \n (id ?i1&~?i0) \n (values $?c1) \n (parent ?p1))\n (test (and (subsetp ?c0 ?c1) \n (= (length$ ?c1) \n (length$ ?c0))))\n =>\n (assert (message (to loop-region-merging)\n (action claim-equivalent) \n (arguments ?p1 => ?p0))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-claim::MergeClaimsOfEquivalence\n \"It is possible for two facts of equivalence to actually be the same \n fact\"\n (declare (salience -1))\n ?f0 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?a => ?b))\n ?f1 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?b => ?a))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?a => ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopFirst\n \"If we find an equivalence then it means that a loop and a region \n contain the same elements. Therefore the loop persists and the region \n dies. The loop is the first entry.\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action claim-equivalent) \n (arguments ?a => ?b))\n (object (is-a Loop) \n (id ?a))\n (object (is-a Region&~Loop) \n (id ?b))\n =>\n (duplicate ?f0 (action delete-region)\n (arguments ?b))\n (modify ?f0 (action replace)\n (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-arbitrate::EliminateEquivalences-LoopSecond\n \"If we find an equivalence then it means that a loop and a region \n contain the same elements. Therefore the loop persists and the region\n dies. The loop is the second entry.\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging) \n (action claim-equivalent) \n (arguments ?b => ?a))\n (object (is-a Loop) \n (id ?a))\n (object (is-a Region&~Loop) \n (id ?b))\n =>\n (duplicate ?f0 (action delete-region)\n (arguments ?b))\n (modify ?f0 (action replace)))\n;------------------------------------------------------------------------------\n; Now that we have asserted delete and replacement claims it's necessary to\n; carry those claims out. First, we need to do the replacement actions\n; We need to apply these changes to the flat lists associated with these\n; objects to ensure that we do the proper replacement thing. \n; What we do is we use those replacement facts to retract the ownership claims\n;\n; Then we go through and perform partial replacement on the flat lists \n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-DeletionTargetClaimsAnother\n \"We target claims of ownership that deal with a given region that has \n to be replaced by another due to equivalence\"\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ?old => ?new))\n ?f1 <- (message (to loop-region-merging)\n (action claim-owns) \n (arguments ?old => ?other))\n =>\n (modify ?f0)\n (modify ?f1 (arguments ?new => ?other)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-AnotherClaimsDeletionTarget\n (declare (salience 1))\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ?old => ?new))\n ?f1 <- (message (to loop-region-merging)\n (action claim-owns)\n (arguments ?other => ?old))\n =>\n (modify ?f0)\n (modify ?f1 (arguments ?other => ?new)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::RemoveStaleClaims-NoMoreConvergence\n \"Retract replacement facts because there are no more claims to worry \n about\"\n ?f0 <- (message (to loop-region-merging)\n (action replace)\n (arguments ? => ?))\n =>\n (retract ?f0))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-flatlist-resolve::DeleteTargetRegion\n \"Deletes the target region slated for deletion\"\n ?f0 <- (message (to loop-region-merging)\n (action delete-region)\n (arguments ?r0))\n ?region <- (object (is-a Region) \n (id ?r0))\n =>\n (retract ?f0)\n (unmake-instance ?region))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::initiate-deletion\n \"Retracts the initial fact for this module and asserts local facts for\n deleting flat lists and ownership determinants\"\n ?f <- (message (from pipeline)\n (to loop-region-merging-cleanup-merger)\n (action initial-fact))\n =>\n (retract ?f)\n (assert (delete ownership-determinants)\n (delete flat-lists)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::DeleteFlatLists \n \"Deletes all of the flat lists in a single rule fire\"\n ?f0 <- (delete flat-lists)\n =>\n (retract ?f0)\n (progn$ (?fl (find-all-instances ((?list FlatList)) TRUE))\n (unmake-instance ?fl)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fce331fceb6471823fa2bf97ea25b43da8b2c0eb","subject":"Rewrote ValidBlockIdentification to be simpler and use modules","message":"Rewrote ValidBlockIdentification to be simpler and use modules\n\nI found several areas where I was taking a fact with a multifield and\nconverting each element into it's own fact through the use of individual rule\nfires. I believe at the time I was trying to be more \"expert system\" like but I\nrealized that it would be faster to use a progn$ in a single rule to do the\nsame thing. This increases the amount of work the rule does but reduces the\noverall number of rules that need to be fired.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) (parent ?r) (contents $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) (ID ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) (id ?path) (contents $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule AssertIdentifySpansInitial\n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t(object (is-a Hint) (Type Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t;select only BasicBlocks\n\t\t\t(object (is-a BasicBlock) (ID ?e))\n\t\t\t=>\n\t\t\t(assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule IdentifySpanSkips-SplitBlock\n\t\t\t(declare (salience 50))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t?fct <- (Picked ?e for ?r)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?e))\n\t\t\t(test (send ?bb .IsSplitBlock))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Schedule ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule IdentifySpans\n\t\t\t(declare (salience 50))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t?fct <- (Picked ?e for ?r)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?e) (Paths $?paths))\n\t\t\t(test (not (send ?bb .IsSplitBlock)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?bb (IsOpen TRUE))\n\t\t\t(assert (Build paths for ?e from $?paths)))\n;------------------------------------------------------------------------------\n(defrule BuildUpPaths\n\t\t\t(declare (salience 25))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t?fct <- (Build paths for ?e from ?path $?paths)\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Build paths for ?e from $?paths)\n\t\t\t\t\t (Check path ?path for block ?e)))\n;------------------------------------------------------------------------------\n(defrule RetractPathBuildUp\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Identify $?)\n\t\t\t?fct <- (Build paths for ? from)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule GetFactsBeforePathing\n\t\t\t(declare (salience 10000))\n\t\t\t(Debug)\n\t\t\t(Facts)\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Pathing $?)\n\t\t\t=>\n\t\t\t(printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n\t\t\t(facts)\n\t\t\t(printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule DispatchDivideBlock\n\t\t\t(declare (salience 200))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Pathing $?)\n\t\t\t?fct <- (Check path ?p for block ?e)\n\t\t\t(object (is-a Path) (ID ?p) (Contents $? ?e $?rest))\n\t\t\t(object (is-a BasicBlock) (ID ?e))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Scan path ?p for block ?e with contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule AnalyzePathElements\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Pathing $?)\n\t\t\t?fct <- (Scan path ?p for block ?e with contents ?curr $?rest)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?curr))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(if (= 0 (length$ (send ?bb get-Successors))) then\n\t\t\t (assert (CompletelyInvalid blocks for ?e are ?curr))\n\t\t\t (return))\n\t\t\t(if (send ?bb .IsSplitBlock) then\n\t\t\t (assert (CompletelyInvalid blocks for ?e are $?rest)\n\t\t\t\t\t\t (PotentiallyValid blocks for ?e are ?curr))\n\t\t\t (return))\n\t\t\t(if (send ?bb get-HasCallBarrier) then\n\t\t\t (assert (CompletelyInvalid blocks for ?e are $?rest)\n\t\t\t\t\t\t (PotentiallyValid blocks for ?e are ?curr))\n\t\t\t (return))\n\t\t\t(if (send ?bb get-HasMemoryBarrier) then\n\t\t\t (assert (Element ?curr has a MemoryBarrier for ?e)))\n\t\t\t(assert (PotentiallyValid blocks for ?e are ?curr)\n\t\t\t\t\t (Scan path ?p for block ?e with contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule AnalyzePathElements-Region\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Pathing $?)\n\t\t\t?fct <- (Scan path ?p for block ?e with contents ?curr $?rest)\n\t\t\t?bb <- (object (is-a Region) (ID ?curr))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(if (send ?bb get-HasCallBarrier) then\n\t\t\t (assert (CompletelyInvalid blocks for ?e are $?rest)\n\t\t\t\t\t\t (PotentiallyValid blocks for ?e are ?curr))\n\t\t\t (return))\n\t\t\t(if (send ?bb get-HasMemoryBarrier) then\n\t\t\t (assert (Element ?curr has a MemoryBarrier for ?e)))\n\t\t\t(assert (PotentiallyValid blocks for ?e are ?curr)\n\t\t\t\t\t (Scan path ?p for block ?e with contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule RetractCompletedFact\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Strip $?)\n\t\t\t?fct <- (Scan path ? for block ? with contents)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule PrintoutCompletedFacts \n\t\t\t(declare (salience -999))\n\t\t\t(Debug)\n\t\t\t(Facts)\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Pathing $?)\n\t\t\t=>\n\t\t\t(printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n\t\t\t(facts)\n\t\t\t(printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule FAIL-PATHS-EXIST\n\t\t\t(declare (salience -2500))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage Strip $?)\n\t\t\t(Check path ?p for block ?e)\n\t\t\t=>\n\t\t\t(printout t \"ERROR: DIDN'T RETRACT COMPLETED FACT: (Check path \" ?p \n\t\t\t\t\t\t \" for block \" ?e \")\" crlf)\n\t\t\t(facts)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0c587ac910b9d558b889aff09e9c93b430ae7294","subject":"Modified the surface class to require a height and width on initialization","message":"Modified the surface class to require a height and width on initialization\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"System\/Runtime\/Surface.clp","new_file":"System\/Runtime\/Surface.clp","new_contents":";------------------------------------------------------------------------------\n;Catharsis\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Surface.clp - Defines a block of tiles to draw to the screen. Surfaces can't\n; draw directly to the screen. That is up to the screen class.\n; \n; Written by Joshua Scoggins \n; Started on 3\/30\/2013\n;------------------------------------------------------------------------------\n; Modify these global values to change tile size. \n; Only do this if you know what you're doing\n;------------------------------------------------------------------------------\n(defclass Runtime::Surface\n \"Defines the screen to draw to. A screen is made up of one or more surfaces\n which contain tiles.\"\n (is-a DrawableObject)\n (role concrete)\n (pattern-match reactive)\n (slot width \n (source composite)\n (create-accessor read-write)\n (range 0 ?VARIABLE)\n (default ?NONE))\n (slot height \n (source composite)\n (create-accessor read-write)\n (range 0 ?VARIABLE)\n (default ?NONE))\n (slot position-x \n (type INTEGER)\n (visibility public)\n (range 0 ?VARIABLE))\n (slot position-y \n (type INTEGER)\n (visibility public)\n (range 0 ?VARIABLE))\n (slot visible\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (multislot children \n (type INSTANCE)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Catharsis\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Surface.clp - Defines a block of tiles to draw to the screen. Surfaces can't\n; draw directly to the screen. That is up to the screen class.\n; \n; Written by Joshua Scoggins \n; Started on 3\/30\/2013\n;------------------------------------------------------------------------------\n; Modify these global values to change tile size. \n; Only do this if you know what you're doing\n;------------------------------------------------------------------------------\n(defclass Runtime::Surface\n \"Defines the screen to draw to. A screen is made up of one or more surfaces\n which contain tiles.\"\n (is-a DrawableObject)\n (role concrete)\n (pattern-match reactive)\n (slot width \n (source composite)\n (create-accessor read-write)\n (range 0 ?VARIABLE))\n (slot height \n (source composite)\n (create-accessor read-write)\n (range 0 ?VARIABLE))\n (slot position-x \n (type INTEGER)\n (visibility public)\n (range 0 ?VARIABLE))\n (slot position-y \n (type INTEGER)\n (visibility public)\n (range 0 ?VARIABLE))\n (slot visible\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (multislot children \n (type INSTANCE)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"d6320b3deff091007167fb68b41dec24a3d19b16","subject":"Fixed a major logic bug in Hint.clp","message":"Fixed a major logic bug in Hint.clp\n\nI realized that the biggest issue I'm having with path traversal has to do\nwith the decrement-reference-count message-handler. The issue stems from an\nincorrect ordering on the subtraction. I was doing 1 - ?self:reference-count\ninstead of ?self:reference-count - 1. Obviously, this is wrong and has been\nfixed.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Hint.clp","new_file":"lib\/durandal\/modules\/core\/Hint.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Hint.clp - An object used to signify something is a hint. It also has the\n; ability to be reference counted if necessary\n;------------------------------------------------------------------------------\n(defclass core::Hint \n \"An object that makes it easy to create temporary entities.\"\n (is-a Object)\n (multislot values (visibility public))\n (slot reference-count (type NUMBER) (visibility public))\n (slot type (visibility public) (type SYMBOL))\n (slot point (visibility public) (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint increment-reference-count primary \n\"Incrementes the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \nincremented by. If more than one parameter is given then those numbers are \nadded together and then added to the current reference count\"\n ($?by)\n (bind ?len (length$ ?by))\n (switch (length$ ?by)\n (case 0 then \n (bind ?self:reference-count \n (+ 1 ?self:reference-count)))\n (case 1 then \n (bind ?self:reference-count \n (eval (format nil \"(+ %i %i)\", (first$ ?by)\n ?self:reference-count))))\n (default \n (bind ?v (eval (format nil \"(+ %s)\" \n (implode$ ?by))))\n (bind ?self:reference-count \n (+ ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint decrement-reference-count primary\n\"Decrements the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \ndecremented by. If more than one parameter is given then those numbers are \nadded together and then subtracted from the current reference count\"\n ($?by)\n (bind ?len (length$ ?by))\n (switch (length$ ?by)\n (case 0 then \n (bind ?self:reference-count \n (- ?self:reference-count 1)))\n (case 1 then \n (bind ?self:reference-count \n (eval (format nil \"(- %i %i)\" \n ?self:reference-count\n (first$ ?by)))))\n (default \n ;add all of the element together so that the\n ;subtraction is correct\n (bind ?v (eval (format nil \"(+ %s)\" \n (implode$ ?by))))\n (bind ?self:reference-count \n (- ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Hint.clp - An object used to signify something is a hint. It also has the\n; ability to be reference counted if necessary\n;------------------------------------------------------------------------------\n(defclass core::Hint \n \"An object that makes it easy to create temporary entities.\"\n (is-a Object)\n (multislot values (visibility public))\n (slot reference-count (type NUMBER) (visibility public))\n (slot type (visibility public) (type SYMBOL))\n (slot point (visibility public) (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint increment-reference-count primary ($?by)\n\"Incrementes the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \nincremented by. If more than one parameter is given then those numbers are \nadded together and then added to the current reference count\"\n\t\t\t\t\t\t (bind ?len (length$ ?by))\n\t\t\t\t\t\t (switch (length$ ?by)\n\t\t\t\t\t\t\t\t\t (case 0 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(+ 1 ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (case 1 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t (eval (format nil \"(+ %i %i)\", (first$ ?by)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:reference-count))))\n\t\t\t\t\t\t\t\t\t (default \n\t\t\t\t\t\t\t\t\t\t(bind ?v (eval (format nil \"(+ %s)\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (implode$ ?by))))\n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(+ ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Hint decrement-reference-count \n\"Decrements the reference count of the given hint. If no parameters are given \nthen the default is one. If a parameter is given then that is the value \ndecremented by. If more than one parameter is given then those numbers are \nadded together and then subtracted from the current reference count\"\n\t\t\t\t\t\t ($?by)\n\t\t\t\t\t\t (bind ?len (length$ ?by))\n\t\t\t\t\t\t (switch (length$ ?by)\n\t\t\t\t\t\t\t\t\t (case 0 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(- 1 ?self:reference-count)))\n\t\t\t\t\t\t\t\t\t (case 1 then \n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t (eval (format nil \"(- %i %i)\" (first$ ?by)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:reference-count))))\n\t\t\t\t\t\t\t\t\t (default \n\t\t\t\t\t\t\t\t\t\t;add all of the element together so that the\n\t\t\t\t\t\t\t\t\t\t;subtraction is correct\n\t\t\t\t\t\t\t\t\t\t(bind ?v (eval (format nil \"(+ %s)\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (implode$ ?by))))\n\t\t\t\t\t\t\t\t\t\t(bind ?self:reference-count \n\t\t\t\t\t\t\t\t\t\t\t\t(- ?self:reference-count ?v)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"a5c55b70873ab45c280c11ccc52aacf772f272be","subject":"Deleted io from being loaded in Library.clp","message":"Deleted io from being loaded in Library.clp\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"System\/Runtime\/Library.clp","new_file":"System\/Runtime\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the init module and loads all other corresponding\n; files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule Runtime (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(load* \"System\/Runtime\/GenericDeclareFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareLibraryFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareApplicationFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareLogicFunctions.clp\")\n(batch* \"System\/Runtime\/core\/Loader.clp\")\n(batch* \"System\/Runtime\/parsing\/Loader.clp\")\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the init module and loads all other corresponding\n; files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule Runtime (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(load* \"System\/Runtime\/GenericDeclareFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareLibraryFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareApplicationFunctions.clp\")\n(batch* \"System\/Runtime\/DeclareLogicFunctions.clp\")\n(batch* \"System\/Runtime\/core\/Loader.clp\")\n(batch* \"System\/Runtime\/io\/Loader.clp\")\n(batch* \"System\/Runtime\/parsing\/Loader.clp\")\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6120cf9c603a5a8fa2696fc1a465201a107a3cd4","subject":"lib\/dendrite\/Library.clp: Rewrote lib\/dendrite\/Library.clp to use library-files","message":"lib\/dendrite\/Library.clp: Rewrote lib\/dendrite\/Library.clp to use library-files\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/lib\/dendrite\/Library.clp","new_file":"src\/lib\/dendrite\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the dendrite module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule dendrite \n (import init ?ALL)\n (import cortex ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(library-files \"dendrite\"\n \"Interactable.clp\"\n \"Interaction.clp\"\n \"Event.clp\"\n \"Item.clp\"\n \"Entity.clp\"\n \"Player.clp\"\n \"Room.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the dendrite module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/6\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule dendrite \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/dendrite\/Interactable.clp\")\n(batch* \"lib\/dendrite\/Interaction.clp\")\n(batch* \"lib\/dendrite\/Event.clp\")\n(batch* \"lib\/dendrite\/Item.clp\")\n(batch* \"lib\/dendrite\/Entity.clp\")\n(batch* \"lib\/dendrite\/Player.clp\")\n(batch* \"lib\/dendrite\/Room.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"e068d458a7d0121aaf85f171ed4d43d1557ecfb8","subject":"Added basic conversion logic to GLAPIConversion.clp","message":"Added basic conversion logic to GLAPIConversion.clp\n\nArguments are now properly processed (at least basically)\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-name\n ?fct <- (message (to grouping-update)\n\t\t\t\t(action populate-argument)\n\t\t\t\t(arguments ?o => $?items ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t(id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?items))\n\t\t\t(modify-instance ?obj (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-type\n ?fct <- (message (to grouping-update)\n\t\t\t\t(action populate-argument)\n\t\t\t\t(arguments ?o => ?type $?rest))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t(id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(modify-instance ?obj (argument-type ?type)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n ?fct <- (message (to grouping-update)\n\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n (declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(send ?obj print))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ece6c2a9143d39c5e8b57a16904a4e68bd94982c","subject":"a veure...","message":"a veure...\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule crea-programa\n\n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n\t\n\t(printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n\t(bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t\n\t(send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","old_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-altura ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"2bb69dd1687ad6a046555ff330d0e50c69c5362a","subject":"Moved the set of common rules into it's own file.","message":"Moved the set of common rules into it's own file.\n\nThis makes it ridiculously easy to implement expert systems with different\nfunctionality.\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLCommonConversionRules.clp","new_file":"src\/tools\/conv\/gl\/GLCommonConversionRules.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLCommonConversionRules.clp - Common rules that multiple expert systems use\n; to do different kinds of conversion\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file \n (file-id ?name) \n (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n grouping-update)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (file-id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::blank-on-empty-string (?str)\n (if (> (str-length ?str) 0) then ?str else (create$)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::break-apart (?sp ?i)\n (bind ?str (if (stringp ?i) then ?i else (str-cat ?i)))\n (bind ?ind (str-index ?sp ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (create$ (blank-on-empty-string ?p0) ?sp\n (blank-on-empty-string ?p1)))\n;------------------------------------------------------------------------------\n(deffunction modify-input::input-is-not-split-symbol (?sp ?input)\n (bind ?str (str-cat ?input))\n (and (neq 0 (str-compare ?str ?sp))\n (str-index ?sp ?str)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \",\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \",\" ?symbol) \n $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?b ?s $?a))\n (test (input-is-not-split-symbol \"(\" ?s))\n =>\n (modify-instance ?fct (contents $?b (break-apart \"(\" ?s) $?a)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (input-is-not-split-symbol \")\" ?symbol))\n =>\n (modify-instance ?fct (contents $?before (break-apart \")\" ?symbol)\n $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) \n (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (object (is-a heading-span) \n (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (if (> (- ?i2 ?i) 0) then\n (make-instance of heading-span\n (header-name (implode$ $?name))\n (from ?i)\n (to ?i2)\n (parent ?parent))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (object (is-a heading-span)\n (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify-instance ?f (to ?i2)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/tools\/conv\/gl\/GLCommonConversionRules.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"f6b269d373b8a4a496dbc42fa74ee1026e377a12","subject":"Fixed bugs in WavefrontOperandRename.clp","message":"Fixed bugs in WavefrontOperandRename.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontOperandRename.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontOperandRename.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Now we need to rename operands as need be within the blocks that these\n; instructions have been scheduled into\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::AssertReplacementActions\n \"Iterates through the replacement actions multifield and asserts facts \n related to the replacement of given values with another value\"\n (declare (salience 100))\n (object (is-a PathAggregate) \n (parent ?e) \n (ReplacementActions $? ?orig ?new ! $?))\n =>\n ; I have turned you into a cheese sandwich, what do you say to that?\n (assert (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig \n with ?new \n block ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUses\n (declare (salience 20))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig\n with ?new\n block ?e))\n (object (is-a Instruction) \n (id ?orig) \n (pointer ?oPtr))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $? ?new $?rest))\n =>\n (bind ?ptrList (create$))\n (bind ?symList (create$))\n (bind ?i0 1)\n (progn$ (?var $?rest)\n (bind ?obj (instance-name (symbol-to-instance-name ?var)))\n (bind ?oOps (send ?obj get-Operands))\n (if (member$ ?orig ?oOps) then\n (bind ?ptrTmp (send ?obj get-Pointer))\n (bind ?ptrList (insert$ ?ptrList ?i0 ?ptrTmp))\n (bind ?symList (insert$ ?symList ?i0 ?var))\n (bind ?i0 (+ ?i0 1))))\n ;reuse ?fct's memory\n (modify ?fct (action replace-uses-clips)\n (arguments ?orig => ?new for ?symList))\n (assert (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?oPtr => ?nPtr for ?ptrList))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInLLVM\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?from => ?to for $?p2))\n =>\n (if (llvm-replace-uses ?from ?to ?p2) then \n (retract ?fct) \n else\n (printout t\n \"Some kind of error occured when trying to replace uses. \" \n crlf \"Make sure that you've done arguments correctly. \" \n crlf \"The failing rule is ReplaceUsesInLLVM.\" crlf\n \"?from = \" ?from crlf\n \"?to = \" ?to crlf\n \"?p2 = \" ?p2 crlf\n \"Now I'm halting execution\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ?from => ?to for ?symbol $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol) \n (Operands $?operands) \n (LocalDependencies $?locDep)\n (NonLocalDependencies $?nLocDep))\n =>\n (modify-instance ?inst (Operands) \n (LocalDependencies) \n (NonLocalDependencies))\n (modify ?fct (arguments ?from => ?to for $?rest))\n (assert (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?from => ?to\n replacement ?symbol\n operands $?operands))\n (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?locDep))\n (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?nLocDep))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS-End\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ? => ? for))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (modify-instance ?inst (LocalDependencies $?locDep ?curr))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (object-pattern-match-delay\n (modify-instance ?inst (LocalDependencies $?locDep ?to))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?curr))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?to))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?op&~?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?op))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?t))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Empty\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ? => ? \n replacement ?\n operands))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Now we need to rename operands as need be within the blocks that these\n; instructions have been scheduled into\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::AssertReplacementActions\n \"Iterates through the replacement actions multifield and asserts facts \n related to the replacement of given values with another value\"\n (declare (salience 100))\n (object (is-a PathAggregate) \n (parent ?e) \n (ReplacementActions $? ?orig ?new ! $?))\n =>\n ; I have turned you into a cheese sandwich, what do you say to that?\n (assert (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig \n with ?new \n block ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUses\n (declare (salience 20))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig\n with ?new\n block ?e))\n (object (is-a Instruction) \n (id ?orig) \n (pointer ?oPtr))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n (object (is-a BasicBlock) \n (id ?e) \n (Contents $? ?new $?rest))\n =>\n (bind ?ptrList (create$))\n (bind ?symList (create$))\n (bind ?i0 1)\n (progn$ (?var $?rest)\n (bind ?obj (instance-name (symbol-to-instance-name ?var)))\n (bind ?oOps (send ?obj get-Operands))\n (if (member$ ?orig ?oOps) then\n (bind ?ptrTmp (send ?obj get-Pointer))\n (bind ?ptrList (insert$ ?ptrList ?i0 ?ptrTmp))\n (bind ?symList (insert$ ?symList ?i0 ?var))\n (bind ?i0 (+ ?i0 1))))\n ;reuse ?fct's memory\n (modify ?fct (action replace-uses-clips)\n (arguments ?orig => ?new for ?symList))\n (assert (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?oPtr => ?nPtr for ?ptrList))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInLLVM\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?from => ?to for $?p2))\n =>\n (if (llvm-replace-uses ?from ?to ?p2) then \n (retract ?fct) \n else\n (printout t\n \"Some kind of error occured when trying to replace uses. \" \n crlf \"Make sure that you've done arguments correctly. \" \n crlf \"The failing rule is ReplaceUsesInLLVM.\" crlf\n \"?from = \" ?from crlf\n \"?to = \" ?to crlf\n \"?p2 = \" ?p2 crlf\n \"Now I'm halting execution\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ?from => ?to for ?symbol $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol) \n (Operands $?operands) \n (LocalDependencies $?locDep)\n (NonLocalDependencies $?nLocDep))\n =>\n (modify-instance ?inst (Operands) \n (LocalDependencies) \n (NonLocalDependencies))\n (modify ?fct (arguments ?from => ?to for $?rest))\n (assert (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?from => ?to\n replacement ?symbol\n operands $?operands))\n (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?locDep))\n (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?nLocDep))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS-End\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ? => ? for))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (modify-instance ?inst (LocalDependencies $?locDep ?curr))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (object-pattern-match-delay\n (modify-instance ?inst (LocalDependencies $?locDep ?to))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?curr))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?to))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?op&~?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?op))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?t))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Empty\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ? => ? \n replacement ?\n operands))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"340e20cc9fc7a5a7cad8cf0a82679f1a2fc347bf","subject":"Added the Wavefront Scheduling proper code module.","message":"Added the Wavefront Scheduling proper code module.\n\nThis module may encompass a very large number of rules or it may just be the\nlaunch point for a large number of modules. Only time will tell\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n\t\t\t\t\t\t\t\t\t\t;TODO: Insert more modules here\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"db1c78862050963b84f21de09b6193fe065c87a4","subject":"Updated Header to load the Message template","message":"Updated Header to load the Message template\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/clips\/modules\/engine\/Header.clp","new_file":"src\/clips\/modules\/engine\/Header.clp","new_contents":"; Header.clp Describes the header for the engine module\n; See LICENSE for license details\n; Written by Joshua Scoggins\n\n(defmodule engine (export ?ALL))\n\n(load* \"src\/clips\/modules\/engine\/Object.clp\")\n(load* \"src\/clips\/modules\/engine\/Entity.clp\")\n(load* \"src\/clips\/modules\/engine\/Resource.clp\")\n(load* \"src\/clips\/modules\/engine\/TextResource.clp\")\n(load* \"src\/clips\/modules\/engine\/Message.clp\")\n","old_contents":"; Header.clp Describes the header for the engine module\n; See LICENSE for license details\n; Written by Joshua Scoggins\n\n(defmodule engine (export ?ALL))\n\n(load* \"src\/clips\/modules\/engine\/Object.clp\")\n(load* \"src\/clips\/modules\/engine\/Entity.clp\")\n(load* \"src\/clips\/modules\/engine\/Resource.clp\")\n(load* \"src\/clips\/modules\/engine\/TextResource.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"0cbb730a346d80b0e4c7fc150f3251854fc1377b","subject":"Added more rules for GLAPIConversion","message":"Added more rules for GLAPIConversion\n\nI added suport for zero input functions as well as converging the rules for\nsetting names and type for a given argument\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n ()\n (format t \"%s %s %s %s\" \n (if ?self:is-constant then \"const\" else \"\")\n ?self:argument-type\n (if ?self:is-pointer then \"*\" else \"\")\n ?self:argument-name))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(retract ?msg)\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(send ?obj reconstitute)\n\t\t\t(printout t crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type)\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name)))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-name\n ?fct <- (message (to grouping-update)\n\t\t\t\t(action populate-argument)\n\t\t\t\t(arguments ?o => $?items ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t(id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?items))\n\t\t\t(modify-instance ?obj (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-type\n ?fct <- (message (to grouping-update)\n\t\t\t\t(action populate-argument)\n\t\t\t\t(arguments ?o => ?type $?rest))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t(id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(modify-instance ?obj (argument-type ?type)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n ?fct <- (message (to grouping-update)\n\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n (declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(send ?obj print))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"7e4ca3fa91afe5ffacc33351c1c488910b1b2e25","subject":"The rules in PathConstruction.clp now generate control facts","message":"The rules in PathConstruction.clp now generate control facts\n\nEach of these controls facts are meant to control the firing of the path\ntraverser rules and path building rules.\n\nThe reintroduction of this control fact makes it possible to have the same\nbehavior as the original wavefront scheduler that wasn't broken into modules.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/conditional\/PathConstruction.clp","new_file":"lib\/durandal\/passes\/path\/conditional\/PathConstruction.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-region\n (declare (salience 3))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?) \n (contents $? ?z $?))\n (object (is-a Region) \n (id ?z) \n (parent ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n&~?id))\n =>\n (bind ?name (gensym*))\n (modify ?fct (action build-path)\n (arguments ?name))\n (make-instance ?name of Path \n (parent ?n) \n (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-basicblock\n (declare (salience 3))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n))\n =>\n (bind ?name (gensym*))\n (modify ?fct (action build-path)\n (arguments ?name))\n (make-instance ?name of Path \n (parent ?n) \n (values ?a)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-region\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (message (to paths-conditional)\n\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a Region) (id ?z) (parent ?id) (Entrances $? ?a $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n&~?id))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-basicblock\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (message (to paths-conditional)\n\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?a)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"a8bfc1854baa7388c518c619c628d7e511d87131","subject":"Modified Loader.clp to do more than just load other files","message":"Modified Loader.clp to do more than just load other files\n\nNow it also contains the defmodules for the code in this folder as well as the\nrule that performs the macro expansion in the pass-description object.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-code::macro-expand\n ?msg <- (message (from pipeline) \n (to wavefront-scheduling-code)\n (action initial-fact))\n ?p <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?msg)\n (modify-instance ?p (passes \n wavefront-scheduling-init\n ;TODO: add more modules\n $?passes)))\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"08c07768c2268f24242fea471dc0a46f9787f677","subject":"change the call to is-registered with pass-registered","message":"change the call to is-registered with pass-registered\n\nThis is because is-registered is the message name associated with the Pass\nobject while pass-regitered is the command that links into the C++ side of\nthings.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"f0fff0f30a7e7253a6d8a4d4a59df736b6073524","subject":"update beer-knowledge.clp","message":"update beer-knowledge.clp","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-knowledge.clp","new_file":"clips\/beer-knowledge.clp","new_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous classic)\n (pizza-topping-for-vegetarian classic)\n (pizza-topping-for-vegan classic))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-or-vegetarian-is-cheese\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous cheese)\n (pizza-topping-for-vegetarian cheese))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Cr\u00e8me\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork-or-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich pork))\n (which-meat steak))\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter-or-which-entree-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n","old_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous classic)\n (pizza-topping-for-vegetarian classic)\n (pizza-topping-for-vegan classic))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-for-omnivorous-or-vegetarian-is-cheese\n (declare (salience ?*medium-low-priority*))\n (or (pizza-topping-for-omnivorous cheese)\n (pizza-topping-for-vegetarian cheese))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ch\u00e8vre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm\/hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruy\u00e8re\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Cr\u00e8me\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork-or-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich pork))\n (which-meat steak))\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened\/bitter-or-which-entr\u00e9e-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"5c923f29175bda800510451c484de6fd941cf92e","subject":"Added basic support for loading programs in memory.","message":"Added basic support for loading programs in memory.\n\nI am in the process of implementing operations that are actually objects in the\nsystem. I am deciding whether the initial implementation should be\nmessage-based (requires a subclass for each operation and a general pain in the\nass with the upside being that its easy to write \"microcode\" if I want to get\nthat low level) or using a common operation class that asserts facts which\ncontain the actual operation logic. I'm not sure which one to do at this point.\nI'm leaning towards the more \"pain-in-the-ass\" method because its easier to\nunderstand and I can rearrange encodings without having to change execution\nrules. The only downside is that the \"overhead\" of message passing could come\ninto play. However, this is not a safety-critical or performance tool so who\ncares....hmmmmmm\n\nAnyway, I have also implemented a cacheless design for the processor due to the\nway that the knowledge base works combined with the fact that it is dead\nfucking simple to implement. Caches add a lot of complexity that really is not\nnecessary at this point.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"Simulator.clp","new_file":"Simulator.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(defclass operation\n \"Represents an instruction to execute\"\n (is-a USER)\n (role abstract)\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE)\n (default ?NONE))\n (slot name\n (type SYMBOL)\n (visibility public)\n (storage local)\n (default ?NONE)))\n(defclass cell \n (is-a USER)\n (role abstract)\n (slot cell-type\n (type SYMBOL)\n (storage shared)\n (access read-only)\n (default unknown))\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (visibility public)\n (default-dynamic 0)))\n(defclass memory-cell\n (is-a cell)\n (role concrete)\n (slot cell-type\n (source composite)\n (default memory)))\n\n(defclass cache-cell\n (is-a cell)\n (role concrete)\n (slot address \n (source composite)\n (storage shared)\n (access initialize-only)\n (default 0))\n (slot cell-type\n (source composite)\n (default cache)))\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)))\n\n(defclass machine\n (is-a USER)\n (multislot registers \n (type INSTANCE)\n (allowed-classes register)))\n;TODO: automate the generation of the register set\n(defrule setup-machine\n (initial-fact)\n =>\n (bind ?registers (instance-name (make-instance pc of register (offset 256))))\n (loop-for-count (?i 0 255) do\n (bind ?registers (create$ ?registers (instance-name (make-instance (sym-cat r ?i) of register (offset ?i))))))\n (make-instance proc of machine \n (registers ?registers))\n (assert (Machine setup)))\n(defrule load-program-into-memory\n ?s <- (Machine setup)\n ?f <- (load ?program-path into memory)\n =>\n ; the encoding of this processor can change from time to time but my\n ; current idea is to have a 255 byte window that represents a set of\n ; actions to be performed by the machine itself.\n (retract ?s ?f)\n ;build the memory cells right now\n (if (open ?program-path file \"r\") then\n (bind ?this (get-char file))\n (bind ?i 0)\n (while (!= ?this -1) do\n (make-instance of memory-cell\n (address ?i)\n (value ?this))\n (bind ?this (get-char file))\n (bind ?i (+ ?i 1)))\n (close ?file)\n (assert (stage decode execute restart))\n else\n (printout t \"ERROR: Couldn't load program\" crlf)\n (halt)))\n(defrule next-stage\n (declare (salience -10000))\n ?f <- (stage ? $?rest)\n =>\n (retract ?f)\n (if (> (length$ ?rest) 0) then\n (assert (stage $?rest))))\n(defrule decode-instruction\n (stage decode $?)\n (object (is-a register)\n (name [pc])\n (value ?location))\n (object (is-a memory-cell)\n (address ?location)\n (value ?operation))\n\n\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(defclass memory-cell\n (is-a USER)\n (slot address\n (type INTEGER)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (default-dynamic 0)))\n\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (range 0 255)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (default-dynamic 0)))\n;TODO: automate the generation of the register set\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c5697230593031702bb7e39a5813ee4851548a66","subject":"Added the automation to the bottom of Simulator.clp","message":"Added the automation to the bottom of Simulator.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron","old_file":"Simulator.clp","new_file":"Simulator.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(load* MachineCommon.clp)\n(defclass cell \n (is-a USER)\n (role abstract)\n (slot cell-type\n (type SYMBOL)\n (storage shared)\n (access read-only)\n (default unknown))\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (visibility public)\n (default-dynamic 0)))\n(defclass memory-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot cell-type\n (source composite)\n (default memory)))\n\n(defclass cache-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot address \n (source composite)\n (storage shared)\n (access initialize-only)\n (default 0))\n (slot cell-type\n (source composite)\n (default cache)))\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)))\n\n(defclass machine\n (is-a USER)\n (multislot registers \n (type INSTANCE)\n (allowed-classes register)))\n\n(defgeneric next)\n(defgeneric next-one)\n(defgeneric next-two)\n(defgeneric next-three)\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (!= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value (* ?i ?inc)))))\n (return ?out))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value ?i))))\n (return ?out))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 1))\n (?inc NUMBER))\n (create$ (+ ?value ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)\n (+ ?value ?inc ?inc ?inc)))\n\n(defmethod next \n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)\n (+ ?value 3)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER))\n (next ?value ?count 1))\n\n\n(defmethod next-one\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 1 ?inc))\n\n(defmethod next-one\n ((?value NUMBER))\n (next ?value 1 1))\n\n(defmethod next-two\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 2 ?inc))\n\n(defmethod next-two\n ((?value NUMBER))\n (next ?value 2 1))\n\n(defmethod next-three\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 3 ?inc))\n\n(defmethod next-three\n ((?value NUMBER))\n (next ?value 3 1))\n\n(defrule setup-machine\n (initial-fact)\n =>\n (bind ?registers (instance-name (make-instance pc of register (offset 256))))\n (loop-for-count (?i 0 255) do\n (bind ?registers (create$ ?registers (instance-name (make-instance (sym-cat r ?i) of register (offset ?i))))))\n (make-instance proc of machine \n (registers ?registers))\n (assert (Machine setup)))\n(defrule load-program-into-memory\n ?s <- (Machine setup)\n ?f <- (load ?program-path into memory)\n =>\n (retract ?s ?f)\n ;build the memory cells right now\n (if (open ?program-path file \"r\") then\n (bind ?this (get-char file))\n (bind ?i 0)\n (while (!= ?this -1) do\n (make-instance of memory-cell\n (address ?i)\n (value ?this))\n (bind ?this (get-char file))\n (bind ?i (+ ?i 1)))\n (close file)\n (assert (stage decode execute restart))\n else\n (printout t \"ERROR: Couldn't load program\" crlf)\n (halt)))\n(defrule next-stage\n (declare (salience -10000))\n ?f <- (stage ? $?rest)\n =>\n (retract ?f)\n (if (> (length$ ?rest) 0) then\n (assert (stage $?rest))))\n(defrule load-instruction-into-decoder \n (stage decode $?)\n (object (is-a register)\n (name [pc])\n (value ?location))\n (object (is-a memory-cell)\n (address ?location)\n (value ?operation))\n =>\n ;tee hee, silly computer scientist, it's not a fixed \n ;decoder location :D. But it will serve our purposes\n ;well.\n (assert (invoke operation ?operation at ?location)))\n\n(defrule decode:invalid\n (declare (salience -1))\n (stage decode $?)\n ?f <- (invoke operation ? at ?)\n =>\n (retract ?f)\n (printout t \"ERROR: Target operation is not valid\" crlf)\n (halt))\n\n\n; MACHINE SPECIFIC DESCRIPTION CODE FOLLOWS:\n; With the exception of one instruction, the rest of the instruction\n; set operates on available registers (which is why there are 255 of\n; them). This only applies to the externally visible instruction set\n; which is transformed internally to provide on the fly optimizations.\n;\n; This is the basis of the procedurally declarative processor design\n; I'm implementing. Eventually, this will have more features but at\n; this point it is important to get a basic implementation.\n;\n; TODO: Modify the instruction set to define the program counter\n(defrule decode:nop\n \"defines a nop instruction\"\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*nop-instruction*) at ?)\n =>\n (retract ?f)\n (assert (nop)))\n\n(defrule decode:load\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?*load-instruction* ?x) at ?loc)\n =>\n (retract ?f)\n (assert (load (next-two ?loc))))\n\n(defrule decode:store\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*store-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (store (next-two ?loc))))\n\n(defrule decode:add\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*add-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (add (next-three ?loc))))\n\n(defrule decode:subtract\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*subtract-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (subtract (next-three ?loc))))\n\n(defrule decode:multiply\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*multiply-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (multiply (next-three ?loc))))\n\n(defrule decode:divide\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*divide-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (divide (next-three ?loc))))\n\n(defrule decode:equal\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*equal-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (equal (next-three ?loc))))\n\n; NOTES\n; the encoding of this processor can change from time to time but my\n; current idea is to have a 255 byte window that represents a set of\n; actions to be performed by the machine itself. This isn't valid at\n; this point but I may come back to this at another point\n\n(reset)\n(run)\n(exit)\n\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(load* MachineCommon.clp)\n(defclass cell \n (is-a USER)\n (role abstract)\n (slot cell-type\n (type SYMBOL)\n (storage shared)\n (access read-only)\n (default unknown))\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (visibility public)\n (default-dynamic 0)))\n(defclass memory-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot cell-type\n (source composite)\n (default memory)))\n\n(defclass cache-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot address \n (source composite)\n (storage shared)\n (access initialize-only)\n (default 0))\n (slot cell-type\n (source composite)\n (default cache)))\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)))\n\n(defclass machine\n (is-a USER)\n (multislot registers \n (type INSTANCE)\n (allowed-classes register)))\n\n(defgeneric next)\n(defgeneric next-one)\n(defgeneric next-two)\n(defgeneric next-three)\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (!= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value (* ?i ?inc)))))\n (return ?out))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value ?i))))\n (return ?out))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 1))\n (?inc NUMBER))\n (create$ (+ ?value ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)\n (+ ?value ?inc ?inc ?inc)))\n\n(defmethod next \n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)\n (+ ?value 3)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER))\n (next ?value ?count 1))\n\n\n(defmethod next-one\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 1 ?inc))\n\n(defmethod next-one\n ((?value NUMBER))\n (next ?value 1 1))\n\n(defmethod next-two\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 2 ?inc))\n\n(defmethod next-two\n ((?value NUMBER))\n (next ?value 2 1))\n\n(defmethod next-three\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 3 ?inc))\n\n(defmethod next-three\n ((?value NUMBER))\n (next ?value 3 1))\n\n(defrule setup-machine\n (initial-fact)\n =>\n (bind ?registers (instance-name (make-instance pc of register (offset 256))))\n (loop-for-count (?i 0 255) do\n (bind ?registers (create$ ?registers (instance-name (make-instance (sym-cat r ?i) of register (offset ?i))))))\n (make-instance proc of machine \n (registers ?registers))\n (assert (Machine setup)))\n(defrule load-program-into-memory\n ?s <- (Machine setup)\n ?f <- (load ?program-path into memory)\n =>\n (retract ?s ?f)\n ;build the memory cells right now\n (if (open ?program-path file \"r\") then\n (bind ?this (get-char file))\n (bind ?i 0)\n (while (!= ?this -1) do\n (make-instance of memory-cell\n (address ?i)\n (value ?this))\n (bind ?this (get-char file))\n (bind ?i (+ ?i 1)))\n (close file)\n (assert (stage decode execute restart))\n else\n (printout t \"ERROR: Couldn't load program\" crlf)\n (halt)))\n(defrule next-stage\n (declare (salience -10000))\n ?f <- (stage ? $?rest)\n =>\n (retract ?f)\n (if (> (length$ ?rest) 0) then\n (assert (stage $?rest))))\n(defrule load-instruction-into-decoder \n (stage decode $?)\n (object (is-a register)\n (name [pc])\n (value ?location))\n (object (is-a memory-cell)\n (address ?location)\n (value ?operation))\n =>\n ;tee hee, silly computer scientist, it's not a fixed \n ;decoder location :D. But it will serve our purposes\n ;well.\n (assert (invoke operation ?operation at ?location)))\n\n(defrule decode:invalid\n (declare (salience -1))\n (stage decode $?)\n ?f <- (invoke operation ? at ?)\n =>\n (retract ?f)\n (printout t \"ERROR: Target operation is not valid\" crlf)\n (halt))\n\n\n; MACHINE SPECIFIC DESCRIPTION CODE FOLLOWS:\n; With the exception of one instruction, the rest of the instruction\n; set operates on available registers (which is why there are 255 of\n; them). This only applies to the externally visible instruction set\n; which is transformed internally to provide on the fly optimizations.\n;\n; This is the basis of the procedurally declarative processor design\n; I'm implementing. Eventually, this will have more features but at\n; this point it is important to get a basic implementation.\n;\n; TODO: Modify the instruction set to define the program counter\n(defrule decode:nop\n \"defines a nop instruction\"\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*nop-instruction*) at ?)\n =>\n (retract ?f)\n (assert (nop)))\n\n(defrule decode:load\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?*load-instruction* ?x) at ?loc)\n =>\n (retract ?f)\n (assert (load (next-two ?loc))))\n\n(defrule decode:store\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*store-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (store (next-two ?loc))))\n\n(defrule decode:add\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*add-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (add (next-three ?loc))))\n\n(defrule decode:subtract\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*subtract-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (subtract (next-three ?loc))))\n\n(defrule decode:multiply\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*multiply-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (multiply (next-three ?loc))))\n\n(defrule decode:divide\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*divide-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (divide (next-three ?loc))))\n\n(defrule decode:equal\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*equal-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (equal (next-three ?loc))))\n\n; NOTES\n; the encoding of this processor can change from time to time but my\n; current idea is to have a 255 byte window that represents a set of\n; actions to be performed by the machine itself. This isn't valid at\n; this point but I may come back to this at another point\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"bbe85e938f97661b179e8b48c347d9284d2036db","subject":"Removed the overwrite of the pointer slot","message":"Removed the overwrite of the pointer slot\n\nIt was causing segmentation faults to occur\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject))\n ;(role concrete)\n ;(slot pointer (source composite) (access initialize-only)\n ; (visibility public)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (role concrete)\n (slot pointer (source composite) (access initialize-only)\n (visibility public) (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6f253ffd98ca79704d447bc854bc6403fd61aa62","subject":"update clips","message":"update clips\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-preferred-color\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer pale, amber, brown or dark beer? \ud83c\udf7a\")\n (relation-asserted preferred-color)\n (valid-answers pale amber brown dark))))\n\n(defrule determine-preferred-fermentation\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink top, bottom or wild fermented beer?\")\n (relation-asserted preferred-fermentation)\n (valid-answers top bottom wild))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha)? \ud83c\udf76\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-alcohol\n (declare (salience ?*very-high-priority*))\n (driver no)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, mild, high or very high alcoholic drinks? \ud83c\udf79\")\n (relation-asserted preferred-alcohol)\n (valid-answers low mild high \"very high\"))))\n\n(defrule determine-whether-he-should-smoke-a-cigar\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to smoke a cigar? If yes, is the cigar claro, maduro or oscuro? \ud83d\udeac\")\n (relation-asserted which-cigar)\n (valid-answers claro maduro oscuro no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage), semi-soft (Colby, Fontina, Havarti, Monterey Jack), firm\/hard \"\n \"(Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, Gorgonzola, Danish), \"\n \"natural rind (Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, Lancashire, \"\n \"Tomme de Savoie) or washed rind (Epoisses, Livarot, Taleggio)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses have not been aged, or are very slightly cured. These \"\n \"cheeses have a high moisture content and are usually mild and have a \"\n \"very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](goo.gl\/izu1Bw) cheeses have a smooth, generally, creamy \"\n \"interior with little or no rind. These cheeses are generally high in \"\n \"moisture content and range from very mild in flavor to very pungent.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](goo.gl\/yrfoJK) cheeses have a taste profiles range from \"\n \"very mild to sharp and pungent. They generally have a texture profile \"\n \"that ranges from elastic, at room temperature, to the hard cheeses that \"\n \"can be grated.\")\n (str-cat \"\ud83e\uddc0 [Blue](goo.gl\/9KkNww) cheeses have a distinctive blue\/green veining, \"\n \"created when the penicillium roqueforti mold, added during the make \"\n \"process, is exposed to air. This mold provides a distinct flavor to the \"\n \"cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](goo.gl\/Kh3BwD) cheeses are surface-ripened by washing \"\n \"the cheese throughout the ripening\/aging process with brine, beer, \"\n \"wine, brandy, or a mixture of ingredients, which encourages the growth \"\n \"of bacteria. The exterior rind of washed rind cheeses may vary from \"\n \"bright orange to brown, with flavor and aroma profiles that are quite \"\n \"pungent, yet the interior of these cheeses is most often semi-soft \"\n \"and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](goo.gl\/izu1Bw) cheeses can be paired with many different \"\n \"craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](goo.gl\/yrfoJK) cheeses are easily paried with an equally \"\n \"broad range of craft beer styles, such as Pilsner, Bock, Brown Ale and \"\n \"Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 [Blue](goo.gl\/9KkNww) are stronger-flavored cheeses which are most \"\n \"successfully balanced with stonger-flavored bolder beers like IPAs or \"\n \"Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](goo.gl\/ys8pkz) cheeses include Tomme de Savoie styles \"\n \"which pair well with Golden Ales or Blondes. Traditional British-style \"\n \"ales work well with English-style natural rind cheeses, such as \"\n \"Lancashire and Stilton.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](goo.gl\/Kh3BwD) itself, while potentially pungent, is \"\n \"often creamy. Pair Belgian-styles ales, like Triples and Golden Strong \"\n \"ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-whether-he-should-eat-Mascarpone-with-fruit\n (which-fresh-cheese Mascarpone)\n =>\n (assert (UI-state (display \"Do you have to eat Mascarpone with fruit?\")\n (relation-asserted mascarpone-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display (str-cat \"Is the blue cheese Stilton or other? \ud83e\uddc0\"))\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entr\u00e9e-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), fish, meat, vegetables, fats \"\n \"or other?\"))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entr\u00e9e-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds) or other?\"))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entr\u00e9e-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds), or other?\"))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display (str-cat \"Does the vegetables are root (parsnips, carrots), grilled (peppers, onions, \"\n \"mushrooms) or other?\"))\n (relation-asserted which-vegetables)\n (valid-answers root grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Does the fish is shellfish (clams, scallops, lobster, crab), bluefish (salmon, \"\n \"trout, tuna) or other? \ud83e\udd90 \ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Does the fats are vegetable (avocados, olive oil, peanut butter, nuts \"\n \"and seeds) or animal (duck\/pork fat, dairy)?\"))\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display (str-cat \"Does the meat is rich meats (beef strip loin, lamb), game birds (duck, quail, \"\n \"quinoa), braised meats (beef short-rib, pork shoulder), pork or other?\"))\n (relation-asserted which-meat)\n (valid-answers \"rich meats\" \"game birds\" \"braised meats\" pork other))))\n\n(defrule determine-which-pork\n (which-meat pork)\n =>\n (assert (UI-state (display \"Does the pork is prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Does the sausage is capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Does the dessert is creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Does the chocolate is white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n\n\n\n;(defrule determine-predominant-dish-taste\n; (start)\n; =>\n; (assert (UI-state (display \"Which is the predominant taste of the dish?\")\n; (relation-asserted predominant-dish-taste)\n; (valid-answers sweet acid spice umami \"not tasted yet\"))))\n\n;(defrule determine-dish-cooking-method\n; (start)\n; =>\n; (assert (UI-state (display (str-cat \"Does the dish cooking method is dry-heat (broiling, grilling, roasting, baking, \"\n; \"saut\u00e9ing, pan-frying, deep-frying), moist-heat (poaching, simmering, boiling, \"\n; \"steaming) or it is a combination of both (braising, stewing)?\"))\n; (relation-asserted dish-cooking-method)\n; (valid-answers dry-heat moist-heat combination \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \ud83c\udf7e\")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \ud83c\udf7a\")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-preferred-color\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer pale, amber, brown or dark beer? \ud83c\udf7a\")\n (relation-asserted preferred-color)\n (valid-answers pale amber brown dark))))\n\n(defrule determine-preferred-fermentation\n (declare (salience ?*very-high-priority*))\n (regular-beer-drinker yes)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink top, bottom or wild fermented beer?\")\n (relation-asserted preferred-fermentation)\n (valid-answers top bottom wild))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha)? \ud83e\udd5b\")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \ud83d\ude98\")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-alcohol\n (declare (salience ?*very-high-priority*))\n (driver no)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, mild, high or very high alcoholic drinks? \ud83c\udf79\")\n (relation-asserted preferred-alcohol)\n (valid-answers low mild high \"very high\"))))\n\n(defrule determine-whether-he-should-smoke-a-cigar\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to smoke a cigar? If yes, is the cigar claro, maduro or oscuro? \ud83d\udeac\")\n (relation-asserted which-cigar)\n (valid-answers claro maduro oscuro no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \ud83e\uddc0\")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage), semi-soft (Colby, Fontina, Havarti, Monterey Jack), firm\/hard \"\n \"(Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, Gorgonzola, Danish), \"\n \"natural rind (Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, Lancashire, \"\n \"Tomme de Savoie) or washed rind (Epoisses, Livarot, Taleggio)? \ud83e\uddc0\"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses have not been aged, or are very slightly cured. These \"\n \"cheeses have a high moisture content and are usually mild and have a \"\n \"very creamy taste and soft texture.\")\n (str-cat \"\ud83e\uddc0 [Semi-soft](goo.gl\/izu1Bw) cheeses have a smooth, generally, creamy \"\n \"interior with little or no rind. These cheeses are generally high in \"\n \"moisture content and range from very mild in flavor to very pungent.\")\n (str-cat \"\ud83e\uddc0 [Firm\/hard](goo.gl\/yrfoJK) cheeses have a taste profiles range from \"\n \"very mild to sharp and pungent. They generally have a texture profile \"\n \"that ranges from elastic, at room temperature, to the hard cheeses that \"\n \"can be grated.\")\n (str-cat \"\ud83e\uddc0 [Blue](goo.gl\/9KkNww) cheeses have a distinctive blue\/green veining, \"\n \"created when the penicillium roqueforti mold, added during the make \"\n \"process, is exposed to air. This mold provides a distinct flavor to the \"\n \"cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](goo.gl\/Kh3BwD) is used to describe those cheeses that \"\n \"are surface-ripened by washing the cheese throughout the ripening\/aging \"\n \"process with brine, beer, wine, brandy, or a mixture of ingredients, \"\n \"which encourages the growth of bacteria. The exterior rind of washed \"\n \"rind cheeses may vary from bright orange to brown, with flavor and \"\n \"aroma profiles that are quite pungent, yet the interior of these \"\n \"cheeses is most often semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \"\ud83e\uddc0 Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \"\ud83e\uddc0 The vast variety of [semi-soft](goo.gl\/izu1Bw) can be paired with \"\n \"many different craft beers, such as German K\u00f6lsch or Bock and Pale Ale \"\n \"beers.\")\n (str-cat \"\ud83e\uddc0 Because of their variety, [firm\/hard](goo.gl\/yrfoJK) are easily \"\n \"paried with an equally broad range of craft beer styles, such as \"\n \"Pilsner, Bock, Brown Ale and Imperial Stout.\")\n (str-cat \"\ud83e\uddc0 [Blue](goo.gl\/9KkNww) are stronger-flavored cheeses which are most \"\n \"successfully balanced with stonger-flavored bolder beers like IPAs or \"\n \"Imperial IPAs.\")\n (str-cat \"\ud83e\uddc0 [Natural rind](goo.gl\/ys8pkz) cheeses include Tomme de Savoie styles \"\n \"which pair well with Golden Ales or Blondes. Traditional British-style \"\n \"ales work well with English-style natural rind cheeses, such as \"\n \"Lancashire and Stilton.\")\n (str-cat \"\ud83e\uddc0 [Washed rind](goo.gl\/Kh3BwD) itself, while potentially pungent, is \"\n \"often creamy. Pair Belgian-styles ales, like Triples and Golden Strong \"\n \"ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-whether-he-should-eat-Mascarpone-with-fruit\n (which-fresh-cheese Mascarpone)\n =>\n (assert (UI-state (display \"Do you have to eat Mascarpone with fruit?\")\n (relation-asserted mascarpone-with-fruit)\n (valid-answers yes no))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Colby, Havarti, Monterey Jack or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm\/hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \ud83e\uddc0\")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \ud83e\uddc0\")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \ud83e\uddc0\")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \ud83e\uddc0\")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display (str-cat \"Is the blue cheese Stilton or other? \ud83e\uddc0\"))\n (why \"\ud83e\uddc0 Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \ud83e\uddc0\"))\n (why (str-cat \"\ud83e\uddc0 Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \ud83e\uddc0\")\n (why (str-cat \"\ud83e\uddc0 Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entr\u00e9e-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), fish, meat, vegetables, fats \"\n \"or other?\"))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entr\u00e9e-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds) or other?\"))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entr\u00e9e-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta), \"\n \"legumes (lentils, fava, chickpea, green beans), vegetables, vegetables fats \"\n \"(avocados, olive oil, peanut butter, nuts and seeds), or other?\"))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display (str-cat \"Does the vegetables are root (parsnips, carrots), grilled (peppers, onions, \"\n \"mushrooms) or other?\"))\n (relation-asserted which-vegetables)\n (valid-answers root grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Does the fish is shellfish (clams, scallops, lobster, crab), bluefish (salmon, \"\n \"trout, tuna) or other? \ud83e\udd90 \ud83d\udc1f\"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Does the fats are vegetable (avocados, olive oil, peanut butter, nuts \"\n \"and seeds) or animal (duck\/pork fat, dairy)?\"))\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display (str-cat \"Does the meat is rich meats (beef strip loin, lamb), game birds (duck, quail, \"\n \"quinoa), braised meats (beef short-rib, pork shoulder), pork or other?\"))\n (relation-asserted which-meat)\n (valid-answers \"rich meats\" \"game birds\" \"braised meats\" pork other))))\n\n(defrule determine-which-pork\n (which-meat pork)\n =>\n (assert (UI-state (display \"Does the pork is prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Does the sausage is capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Does the dessert is creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \ud83c\udf6b\"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Does the chocolate is white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \ud83c\udf6b\"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n\n\n\n;(defrule determine-predominant-dish-taste\n; (start)\n; =>\n; (assert (UI-state (display \"Which is the predominant taste of the dish?\")\n; (relation-asserted predominant-dish-taste)\n; (valid-answers sweet acid spice umami \"not tasted yet\"))))\n\n;(defrule determine-dish-cooking-method\n; (start)\n; =>\n; (assert (UI-state (display (str-cat \"Does the dish cooking method is dry-heat (broiling, grilling, roasting, baking, \"\n; \"saut\u00e9ing, pan-frying, deep-frying), moist-heat (poaching, simmering, boiling, \"\n; \"steaming) or it is a combination of both (braising, stewing)?\"))\n; (relation-asserted dish-cooking-method)\n; (valid-answers dry-heat moist-heat combination \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"6843c2e19704e42db065ffdb4f91bf3eb8ba0bd3","subject":"Create task1.clp","message":"Create task1.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task1.clp","new_file":"ssu-ai-level-2\/chapter5\/task1.clp","new_contents":"(defrule zachisl\n =>\n (printout t \"Input the count of students\")\n (bind ?n (read))\n (loop-for-count (?i 1 ?n) do\n (printout t \"Input the last name:\")\n (bind ?lastName (read))\n (assert (student ?lastName 1))\n )\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"ec44162d1dc27fbdccccd5a588e63fe28a18f55f","subject":"Create task1.clp","message":"Create task1.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task1.clp","new_file":"ssu-ai-level-2\/chapter7\/task1.clp","new_contents":"(defrule replace\n =>\n (bind ?str (readline))\n (bind ?a (readline))\n (bind ?b (readline))\n (bind ?n (str-length ?str))\n (bind ?k 0)\n (loop-for-count (?i 1 ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n (bind ?d (str-compare ?c1 ?a))\n\n (if (= ?d 0) then\n (printout t \"k=\" ?k crlf))))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"646e1ddf8fdd526c83c19fc9cae44bb1095e52a0","subject":"Modified the stage template to require the at field to be set.","message":"Modified the stage template to require the at field to be set.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron","old_file":"System\/Runtime\/Stage.clp","new_file":"System\/Runtime\/Stage.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Stage.clp - Standardized mechanism for providing stage control facts\n;------------------------------------------------------------------------------\n(deftemplate Runtime::stage\n \"Standardized mechanism for providing stage control facts\"\n (slot id \n (type SYMBOL) \n (default-dynamic (gensym*)))\n (slot at \n (type SYMBOL)\n (default ?NONE))\n (multislot rest \n (type SYMBOL)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Stage.clp - Standardized mechanism for providing stage control facts\n;------------------------------------------------------------------------------\n(deftemplate Runtime::stage\n \"Standardized mechanism for providing stage control facts\"\n (slot id (type SYMBOL) (default-dynamic (gensym*)))\n (slot at (type SYMBOL))\n (multislot rest (type SYMBOL)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c7438fcafdc20a01300166674119b3efecf61fcd","subject":"src\/lib\/cortex\/core\/Object.clp: Added the parent slot","message":"src\/lib\/cortex\/core\/Object.clp: Added the parent slot\n\nI have been debating having the parent slot be located in the base Object\nclass but I have decided to have it because it is super useful.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron","old_file":"src\/lib\/cortex\/core\/Object.clp","new_file":"src\/lib\/cortex\/core\/Object.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Contains basic object classes \n;------------------------------------------------------------------------------\n(defclass cortex::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visibility public) (access initialize-only))\n (slot class (type SYMBOL) (visibility public) (access initialize-only))\n (slot parent (type SYMBOL) (visibility public))\n (message-handler init around))\n;------------------------------------------------------------------------------\n(defmessage-handler cortex::Object init around \n \"Initializes the object, setting the id and class of the \n object\" \n ()\n (call-next-handler)\n ;we want to set this information as the last thing before \n ;we return \n (bind ?self:id (instance-name-to-symbol \n (instance-name ?self)))\n (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Contains basic object classes \n;------------------------------------------------------------------------------\n(defclass cortex::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visibility public) (access initialize-only))\n (slot class (type SYMBOL) (visibility public) (access initialize-only))\n (message-handler init around))\n;------------------------------------------------------------------------------\n(defmessage-handler cortex::Object init around \n \"Initializes the object, setting the id and class of the \n object\" \n ()\n (call-next-handler)\n ;we want to set this information as the last thing before \n ;we return \n (bind ?self:id (instance-name-to-symbol \n (instance-name ?self)))\n (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c1709dea07851af30a16b9537b7f85eaa08cba39","subject":"Partially implemented core course grade req.","message":"Partially implemented core course grade req.\n","repos":"jtan189\/CompSci-Degree-Expert-System,jtan189\/CompSci-Degree-Expert-System","old_file":"DegreeAdvisor\/src\/advisor.clp","new_file":"DegreeAdvisor\/src\/advisor.clp","new_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n\n;; GEN ED REQUIREMENTS\n\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {courseId == \"UNIV 189\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n (not (exists (Course {courseId == \"COMM 110\"})))\n (not (exists (Course {courseId == \"ENGL 110\"})))\n (not (exists (Course {courseId == \"ENGL 120\"})))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {courseId == \"MATH 165\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; Humanities & Fine Arts (A) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-a\n \"Advise student if Gen Ed Humanities & Fine Arts requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"A\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Humanities & Fine Arts requirements not satisfied\" \"At least 6 credits in the General Education Humanities & Fine Arts area are required.\" \"ISSUE\")))\n\n;; Social & Behavioral Sciences (B) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-b\n \"Advise student if Gen Ed Social & Behavioral Sciences requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"B\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Social & Behavioral Sciences requirements not satisfied\" \"At least 6 credits in the General Education Social & Behavioral Sciences area are required.\" \"ISSUE\")))\n\n;; Wellness (W) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-w\n \"Advise student if Gen Ed Wellness requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"W\")))) ;; CE\n (test (< ?totalCredits 2))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Wellness requirements not satisfied\" \"At least 6 credits in the General Education Wellness area are required.\" \"ISSUE\")))\n\n;; Cultural Diversity (D) Requirements\n(defrule gen-ed-d\n \"Advise student if Gen Ed Cultural Diversity requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"D\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Cultural Diversity requirements not satisfied\" \"At least 1 course in the General Education Cultural Diversity area is required.\" \"ISSUE\")))\n\n;; Global Perspectives (G) Requirements\n(defrule gen-ed-g\n \"Advise student if Gen Ed Global Perspectives requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"G\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Global Perspectives requirements not satisfied\" \"At least 1 course in the General Education Global Perspectives area is required.\" \"ISSUE\")))\n\n;; Gen Ed Lower Division Requirements\n(defrule gen-ed-ld\n \"Adivce student if Gen Ed lower division requirements are not satisfied.\"\n (exists (gen-ed-ld-not-satisfied))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed lower division requirements not satisfied\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; Gen Ed Upper Division Requirements\n(defrule gen-ed-ud\n \"Advise student if Gen Ed upper division requirements not satisfied.\"\n (not (exists (Course {courseId == \"ENGL 321\" || courseId == \"ENGL 324\"})))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed upper division requirements not satisfied\" \"Either Writing in the Technical Professions (ENGL 321) or Writing in the Sciences (ENGL 324) is required, but neither is listed among courses.\" \"ISSUE\")))\n\n;; Gen Ed Requirements\n(defrule gen-ed\n \"Advise student if Gen Ed requirements not satisfied.\"\n (or (exists (gen-ed-ld-not-satisfied)) (exists (gen-ed-ud-not-satisfied)))\n =>\n (assert (deg-req-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed requirements not satisfied\" \"See curriculm guide for details.\" \"ISSUE\")))\n\n\n\n;; One Year Lab Science Sequence Requirement\n(defrule lab-sci-biol-126\n (not (exists (Course {courseId == \"BIOL 126\"})))\n (not (exists (Course {courseId == \"BIOL 126L\"})))\n (not (exists (Course {courseId == \"BIOL 220\"})))\n (not (exists (Course {courseId == \"BIOL 220L\"})))\n =>\n (assert (no-biol-126-seq)))\n\n(defrule lab-sci-chem-121\n (not (exists (Course {courseId == \"CHEM 121\"})))\n (not (exists (Course {courseId == \"CHEM 121L\"})))\n (not (exists (Course {courseId == \"CHEM 122\"})))\n (not (exists (Course {courseId == \"CHEM 122L\"})))\n =>\n (assert (no-chem-121-seq)))\n\n(defrule lab-sci-chem-150\n (not (exists (Course {courseId == \"CHEM 150\"})))\n (not (exists (Course {courseId == \"CHEM 160\"})))\n (not (exists (Course {courseId == \"CHEM 151\"})))\n (not (exists (Course {courseId == \"CHEM 161\"})))\n =>\n (assert (no-chem-150-seq)))\n\n(defrule lab-sci-geol-105\n (not (exists (Course {courseId == \"GEOL 105\"})))\n (not (exists (Course {courseId == \"GEOL 105L\"})))\n (not (exists (Course {courseId == \"GEOL 106\"})))\n (not (exists (Course {courseId == \"GEOL 106L\"})))\n =>\n (assert (no-geol-105-seq)))\n\n(defrule lab-sci-phys-211\n (not (exists (Course {courseId == \"PHYS 211\"})))\n (not (exists (Course {courseId == \"PHYS 211L\"})))\n (not (exists (Course {courseId == \"PHYS 212\"})))\n (not (exists (Course {courseId == \"PHYS 212L\"})))\n =>\n (assert (no-phys-211-seq)))\n\n(defrule lab-sci-phys-251\n (not (exists (Course {courseId == \"PHYS 251\"})))\n (not (exists (Course {courseId == \"PHYS 251L\"})))\n (not (exists (Course {courseId == \"PHYS 252\"})))\n (not (exists (Course {courseId == \"PHYS 252L\"})))\n =>\n (assert (no-phys-251-seq)))\n\n(defrule lab-sci-seq-req\n (no-biol-126-seq)\n (no-chem-121-seq)\n (no-chem-150-seq)\n (no-geol-105-seq)\n (no-phys-211-seq)\n (no-phys-251-seq)\n =>\n (add (new Advice \"LabScienceRequirement\" \"Lab Science Sequence requirements not satisfied\" \"A one year sequence of lab science courses (with corresponding labs) is required.\" \"ISSUE\")))\n\n;; B.S. COMPUTER SCIENCE REQUIREMENTS\n\n;; core CS course requirements\n\n(deffunction is-core-cs (?c)\n (return (?c == \"CSCI 160\" ||\n\t ?c == \"CSCI 161\" ||\n\t ?c == \"CSCI 213\" ||\n\t ?c == \"CSCI 222\" ||\n\t ?c == \"CSCI 313\" ||\n\t ?c == \"CSCI 336\" ||\n\t ?c == \"CSCI 372\" ||\n\t ?c == \"CSCI 374\" ||\n\t ?c == \"CSCI 415\" ||\n\t ?c == \"CSCI 445\" ||\n\t ?c == \"CSCI 467\" ||\n\t ?c == \"CSCI 474\" ||\n\t ?c == \"CSCI 489\"))\n\n;; \"C\" or better required for all CSCI courses\n(defrule c-in-cs-course\n \"Advise that will have to retake a CS course if it's a degree requirement and a D or worse received.\"\n (Course (courseId ?c&:(is-core-cs ?c)) (grade ?g&:(g == \"D\" || g == \"F\")))\n =>\n (add (new Advice \"LabScienceRequirement\" \"Lab Science Sequence requirements not satisfied\" \"A one year sequence of lab science courses (with corresponding labs) is required.\" \"ISSUE\")))\n\t \n \n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n (not (exists (Course {grade == \"NA\"})))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","old_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n\n;; GEN ED REQUIREMENTS\n\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {courseId == \"UNIV 189\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n (not (exists (Course {courseId == \"COMM 110\"})))\n (not (exists (Course {courseId == \"ENGL 110\"})))\n (not (exists (Course {courseId == \"ENGL 120\"})))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {courseId == \"MATH 165\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; Humanities & Fine Arts (A) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-a\n \"Advise student if Gen Ed Humanities & Fine Arts requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"A\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Humanities & Fine Arts requirements not satisfied\" \"At least 6 credits in the General Education Humanities & Fine Arts area are required.\" \"ISSUE\")))\n\n;; Social & Behavioral Sciences (B) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-b\n \"Advise student if Gen Ed Social & Behavioral Sciences requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"B\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Social & Behavioral Sciences requirements not satisfied\" \"At least 6 credits in the General Education Social & Behavioral Sciences area are required.\" \"ISSUE\")))\n\n;; Wellness (W) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-w\n \"Advise student if Gen Ed Wellness requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"W\")))) ;; CE\n (test (< ?totalCredits 2))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Wellness requirements not satisfied\" \"At least 6 credits in the General Education Wellness area are required.\" \"ISSUE\")))\n\n;; Cultural Diversity (D) Requirements\n(defrule gen-ed-d\n \"Advise student if Gen Ed Cultural Diversity requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"D\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Cultural Diversity requirements not satisfied\" \"At least 1 course in the General Education Cultural Diversity area is required.\" \"ISSUE\")))\n\n;; Global Perspectives (G) Requirements\n(defrule gen-ed-g\n \"Advise student if Gen Ed Global Perspectives requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"G\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Global Perspectives requirements not satisfied\" \"At least 1 course in the General Education Global Perspectives area is required.\" \"ISSUE\")))\n\n;; Gen Ed Lower Division Requirements\n(defrule gen-ed-ld\n \"Adivce student if Gen Ed lower division requirements are not satisfied.\"\n (exists (gen-ed-ld-not-satisfied))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed lower division requirements not satisfied\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; Gen Ed Upper Division Requirements\n(defrule gen-ed-ud\n \"Advise student if Gen Ed upper division requirements not satisfied.\"\n (not (exists (Course {courseId == \"ENGL 321\" || courseId == \"ENGL 324\"})))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed upper division requirements not satisfied\" \"Either Writing in the Technical Professions (ENGL 321) or Writing in the Sciences (ENGL 324) is required, but neither is listed among courses.\" \"ISSUE\")))\n\n;; Gen Ed Requirements\n(defrule gen-ed\n \"Advise student if Gen Ed requirements not satisfied.\"\n (or (exists (gen-ed-ld-not-satisfied)) (exists (gen-ed-ud-not-satisfied)))\n =>\n (assert (deg-req-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed requirements not satisfied\" \"See curriculm guide for details.\" \"ISSUE\")))\n\n\n\n;; One Year Lab Science Sequence Requirement\n(defrule lab-sci-biol-126\n (not (exists (Course {courseId == \"BIOL 126\"})))\n (not (exists (Course {courseId == \"BIOL 126L\"})))\n (not (exists (Course {courseId == \"BIOL 220\"})))\n (not (exists (Course {courseId == \"BIOL 220L\"})))\n =>\n (assert (no-biol-126-seq)))\n\n(defrule lab-sci-chem-121\n (not (exists (Course {courseId == \"CHEM 121\"})))\n (not (exists (Course {courseId == \"CHEM 121L\"})))\n (not (exists (Course {courseId == \"CHEM 122\"})))\n (not (exists (Course {courseId == \"CHEM 122L\"})))\n =>\n (assert (no-chem-121-seq)))\n\n(defrule lab-sci-chem-150\n (not (exists (Course {courseId == \"CHEM 150\"})))\n (not (exists (Course {courseId == \"CHEM 160\"})))\n (not (exists (Course {courseId == \"CHEM 151\"})))\n (not (exists (Course {courseId == \"CHEM 161\"})))\n =>\n (assert (no-chem-150-seq)))\n\n(defrule lab-sci-geol-105\n (not (exists (Course {courseId == \"GEOL 105\"})))\n (not (exists (Course {courseId == \"GEOL 105L\"})))\n (not (exists (Course {courseId == \"GEOL 106\"})))\n (not (exists (Course {courseId == \"GEOL 106L\"})))\n =>\n (assert (no-geol-105-seq)))\n\n(defrule lab-sci-phys-211\n (not (exists (Course {courseId == \"PHYS 211\"})))\n (not (exists (Course {courseId == \"PHYS 211L\"})))\n (not (exists (Course {courseId == \"PHYS 212\"})))\n (not (exists (Course {courseId == \"PHYS 212L\"})))\n =>\n (assert (no-phys-211-seq)))\n\n(defrule lab-sci-phys-251\n (not (exists (Course {courseId == \"PHYS 251\"})))\n (not (exists (Course {courseId == \"PHYS 251L\"})))\n (not (exists (Course {courseId == \"PHYS 252\"})))\n (not (exists (Course {courseId == \"PHYS 252L\"})))\n =>\n (assert (no-phys-251-seq)))\n\n(defrule lab-sci-seq-req\n (no-biol-126-seq)\n (no-chem-121-seq)\n (no-chem-150-seq)\n (no-geol-105-seq)\n (no-phys-211-seq)\n (no-phys-251-seq)\n =>\n (add (new Advice \"LabScienceRequirement\" \"Lab Science Sequence requirements not satisfied\" \"A one year sequence of lab science courses (with corresponding labs) is required.\" \"ISSUE\")))\n\n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n (not (exists (Course {grade == \"NA\"})))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"87f8fc7b921b317670215fd928502d3430b44140","subject":"Removed the defmodule MAIN definition from Init.clp","message":"Removed the defmodule MAIN definition from Init.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"Init.clp","new_file":"Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/scheduler\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n;(defmodule MAIN (import core ?ALL) (import llvm ?ALL))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/scheduler\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n(defmodule MAIN (import core ?ALL) (import llvm ?ALL))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"b521f749c4013b24a7e037bc649f4006b11ff497","subject":"Fixed slot names in WavefrontInitialization.clp","message":"Fixed slot names in WavefrontInitialization.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInitialization.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInitialization.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-block\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $?c))\n =>\n (assert (message (to wavefront-schedule) \n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e) \n (OriginalStopIndex (- (length$ $?c) 1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-region\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a Region) \n (id ?e)) \n =>\n (assert (message (to wavefront-schedule)\n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; NOTE: This is the execution order of the wavefront scheduler\n;(defrule InitializeWavefrontSchedulingFacts\n; (declare (salience 1001))\n; (Stage WavefrontSchedule $?)\n; =>\n; (assert (Substage Init \n; Identify \n; PhiIdentify\n; PhiNode \n; PhiNodeUpdate\n; Pathing \n; Strip \n; Inject \n; Acquire \n; Slice \n; AnalyzeInit \n; GenerateAnalyze0\n; GenerateAnalyze\n; Analyze \n; SliceAnalyze\n; MergeInit \n; Merge \n; MergeUpdate \n; ReopenBlocks\n; Ponder\n; Rename \n; DependencyAnalysis \n; AdvanceInit\n; AdvanceIdentify\n; Advance\n; AdvanceEnd\n; Update)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-block\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $?c))\n =>\n (assert (message (to wavefront-schedule) \n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e) \n (OriginalStopIndex (- (length$ $?c) 1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-init::build-path-aggregate-for-region\n (declare (salience 100))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a Region) \n (id ?e)) \n =>\n (assert (message (to wavefront-schedule)\n (action propagate-aggregates)\n (arguments ?e)))\n (make-instance of PathAggregate (parent ?e)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5e6b1d1ab51e73460d805a917b5f658b68fcd724","subject":"Removed the extra pipeline push onto the focus stack","message":"Removed the extra pipeline push onto the focus stack\n\nThis is done automatically by the focus command itself.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n ?fct <- (message (to pipeline) \n (action pass-description) \n (arguments $?passes))\n =>\n (retract ?fct)\n (make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n ?obj <- (object (is-a pass-description) \n (passes ?first $?rest))\n =>\n (modify-instance ?obj (passes $?rest))\n ;remove what is currently on the focus stack\n ;\t\t\t(pop-focus)\n (assert (message (from pipeline) \n (to ?first) \n (action initial-fact)))\n (focus ?first))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n ?obj <- (object (is-a pass-description) \n (passes))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n ?fct <- (message (to pipeline) \n (action pass-description) \n (arguments $?passes))\n =>\n (retract ?fct)\n (make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n ?obj <- (object (is-a pass-description) \n (passes ?first $?rest))\n =>\n (modify-instance ?obj (passes $?rest))\n ;remove what is currently on the focus stack\n ;\t\t\t(pop-focus)\n (assert (message (from pipeline) \n (to ?first) \n (action initial-fact)))\n (focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n ?obj <- (object (is-a pass-description) \n (passes))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fe3092e9fe87201dbc03003e2a82b33ae08daafb","subject":"Changed PassDescriptor to pass-description in the terminate-pass rule","message":"Changed PassDescriptor to pass-description in the terminate-pass rule\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_file":"lib\/durandal\/modules\/pipeline\/PassHandler.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n\t\t\t?fct <- (message (to pipeline) \n\t\t\t\t\t\t\t\t (action pass-description) \n\t\t\t\t\t\t\t\t (arguments $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n\t\t\t?obj <- (object (is-a pass-description) \n\t\t\t\t\t\t\t\t (passes ?first $?rest))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (passes $?rest))\n\t\t\t;remove what is currently on the focus stack\n\t\t\t(pop-focus)\n\t\t\t(assert (message (from pipeline) \n\t\t\t\t\t\t\t\t (to ?first) \n\t\t\t\t\t\t\t\t (action initial-fact)))\n\t\t\t(focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n\t\t\t?obj <- (object (is-a pass-description) \n\t\t\t\t\t\t\t\t (passes))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassHandler.clp - Contains the logic necessary to handle pass execution\n;------------------------------------------------------------------------------\n(defrule pipeline::build-pass-descriptor\n\t\t\t?fct <- (message (to pipeline) \n\t\t\t\t\t\t\t\t (action pass-description) \n\t\t\t\t\t\t\t\t (arguments $?passes))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of pass-description (passes $?passes)))\n;------------------------------------------------------------------------------\n(defrule pipeline::next-pass\n\t\t\t?obj <- (object (is-a pass-description) \n\t\t\t\t\t\t\t\t (passes ?first $?rest))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (passes $?rest))\n\t\t\t;remove what is currently on the focus stack\n\t\t\t(pop-focus)\n\t\t\t(assert (message (from pipeline) \n\t\t\t\t\t\t\t\t (to ?first) \n\t\t\t\t\t\t\t\t (action initial-fact)))\n\t\t\t(focus ?first pipeline))\n;------------------------------------------------------------------------------\n(defrule pipeline::terminate-pass\n\t\t\t?obj <- (object (is-a PassDescriptor) \n\t\t\t\t\t\t\t\t (passes))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"345271a8b0463cf9b41db33d6e26754dc5f797b9","subject":"Create repro_template.clp","message":"Create repro_template.clp\n\nrepro template\r\nusage:\r\nblastdb\r\ndb2 -tvf repro_template.clp | tee repro.out","repos":"dramaticlly\/perl","old_file":"repro_template.clp","new_file":"repro_template.clp","new_contents":"!db2level ; -- echo current db2 level\n!db2set -r ; -- reset all db2 registers\n\n!db2set DB2_ROCM_DISABLE_FS_CHECK=TRUE; -- set db2 register values\n!db2set DB2_USE_FAST_SCATTERED_IO=OFF;\n!db2set DB2_SYSTEM_RAM=1GB;\n\n!db2set -all; --echo all db2s regsiter values\n\n!db2stop ;\n!db2start ;\ncreate database ldrng_db ;\nconnect to ldrng_db ;\n\ncreate long tablespace lng1 managed by database using (file 'tmp\/lng1' 1000);\ncreate tablespace reg1 managed by database using (file 'tmp\/reg1' 10000);\ncreate tablespace reg2 managed by database using (file 'tmp\/reg2' 10000);\ncreate tablespace inx1 managed by database using (file 'tmp\/inx1' 30000);\n\ncreate table TABLE130_9 ( a int , b double not null unique, c varchar(10) not null, d LONG VARCHAR) long in lng1 distribute by(b) organize by\ndimensions(a,c) partition by range (a NULLS FIRST,b NULLS LAST) (part p0 starting (MINVALUE,MINVALUE) ending (9,MAXVALUE) in reg1, part p1 starting (10,0) ending (190000,MAXVALUE) in reg1, part p2 starting (200000,0) ending (500000,100000) in reg2);\n\n\ncreate index indx1 on TABLE130_9 (a) not partitioned;\ninsert into TABLE130_9 values (1,2,'aa',NULL);\n\nrunstats on table TABLE130_9 with distribution and indexes all set profile only;\n\nload from ldrng130_9.asc of ASC MODIFIED BY reclen= 1047 method L( 1 11, 13 34, 36 45, 47 1046) NULL INDICATORS ( 12, 35, 46, 1047) replace into TABLE130_9 statistics use profile;\n\nselect npages from sysstat.tables where tabname='TABLE130_9';\n\nterminate;\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'repro_template.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"48065727dff7f0b673e5e500b7acaf009acb5585","subject":"GLAPIConversion.clp: Added classes for argument conversion","message":"GLAPIConversion.clp: Added classes for argument conversion\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;\n; The functions that take in a fixed size array are easy because I can allocate\n; a static block ahead of time that I can read and write from. \n;------------------------------------------------------------------------------\n; Conversion table \n;------------------------------------------------------------------------------\n; float => all floating point types \n; int => all integer types\n; symbol => GLenum or GLboolean\n; multifield => pointer type or fixed array\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(duplicate ?fct (action parse-entry)\n\t\t\t\t\t\t (arguments ?p ?index => ?argID)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify ?fct (action construct-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(modify-instance ?f (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-entry\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-function)\n\t\t\t\t\t\t\t\t(arguments ?p -1))\n\n\t\t\t=>\n\t\t\t(modify ?f (argument ?p 0)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-deferred\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-function)\n\t\t\t\t\t\t\t\t(arguments ?p ?index))\n\t\t\t?f1 <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-entry)\n\t\t\t\t\t\t\t\t (arguments ?p ?index => ?argID))\n\t\t\t?b <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (data-objects $?do)\n\t\t\t\t\t\t\t (variables $?vars)\n\t\t\t\t\t\t\t (parsing-entries $?pe))\n\t\t\t=>\n\t\t\t;generate the name of the object for the target argument entry \n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?f (arguments ?p (+ ?index 1)))\n\t\t\t;put name on each of the element sets.\n\t\t\t;We use that name and message passing to generate corresponding\n\t\t\t;entries in a macro-expand fashion\n\t\t\t(modify-instance ?b (data-objects $?do ?name)\n\t\t\t\t\t\t\t\t (variables $?vars ?name)\n\t\t\t\t\t\t\t\t (parsng-entries $?pe ?name))\n\t\t\t(modify ?f1 (action construct-entry)\n\t\t\t\t\t (arguments ?argID => ?name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n\t\t\t (slot index (type INTEGER) (range 1 ?VARIABLE))\n\t\t\t (slot argument-name-base (type SYMBOL STRING))\n\t\t\t (slot data-object-argument-name (type SYMBOL STRING))\n\t\t\t (slot variable-argument-name (type SYMBOL STRING))\n\t\t\t (slot variable-declaration (type STRING))\n\t\t\t (slot data-object-declaration (type STRING))\n\t\t\t (slot conversion-code (type STRING)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t (slot multifield-pointer-argument-name)\n\t\t\t (slot multifield-pointer-declaration))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n\t\t\t (slot multifield-size))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder\n ?f <- (message (to grouping-update)\n\t\t\t\t (action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t (object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t (is-pointer FALSE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIArgumentBuilder\n\t\t\t (parent ?arg)\n\t\t\t (argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield\n ?f <- (message (to grouping-update)\n\t\t\t\t (action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t (object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t (is-pointer TRUE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIMultifieldArgumentBuilder \n\t\t\t (parent ?arg)\n\t\t\t (argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield-fixed\n (declare (salience 1))\n ?f <- (message (to grouping-update)\n\t\t\t\t (action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t (object (is-a GLAPIFixedArrayArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t (size ?size))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIFixedMultifieldArgumentBuilder \n\t\t\t (parent ?arg)\n\t\t\t (multifield-size ?size)\n\t\t\t (argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-multifield-conversion-code\n ?f <- (message (to grouping-update)\n\t\t\t\t (action make-multifield-conversion-code)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?o <- (object (is-a CLIPSGLAPI\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-data-object-declaration\n ?f <- (message (to grouping-update)\n\t\t\t\t (action make-data-object-declaration)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?ab <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t (id ?name)\n\t\t\t\t\t\t\t\t(argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action finished-data-object-declaration))\n\t\t\t(bind ?doArg (sym-cat (format nil \"%s_DO\" ?anb)))\n\t\t\t(modify-instance ?ab \n\t\t\t (data-object-argument-name ?doArg)\n\t\t\t (data-object-declaration (format nil \"DATA_OBJECT %s;\" ?doArg)))\n;------------------------------------------------------------------------------\n;------------------------------------------------------------------------------\n; Printout results\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;\n; The functions that take in a fixed size array are easy because I can allocate\n; a static block ahead of time that I can read and write from. \n;------------------------------------------------------------------------------\n; Conversion table \n;------------------------------------------------------------------------------\n; float => all floating point types \n; int => all integer types\n; symbol => GLenum or GLboolean\n; multifield => pointer type or fixed array\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d2b40e8dfd80a559b003a9c353665bd353884889","subject":"my last comment \"only already bound variables\" is of course wrong. but it works also with unbound variables. changes are only in the rulecompilertest.clp in the \"nichtgelbpaar\" rule:","message":"my last comment \"only already bound variables\" is of course wrong. but it works also with unbound variables. changes are only in the rulecompilertest.clp in the \"nichtgelbpaar\" rule:\n\n- it demonstrates use of unbound variables in connected constraints\n- it demonstrates the usage of test conditions again, because its nice to see, that they still work ;)\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1343 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"examples\/parser\/rulecompilertest.clp","new_file":"examples\/parser\/rulecompilertest.clp","new_contents":"\n(deftemplate wurst (slot name) (slot spitzname) (slot farbe) (slot gewicht))\n(deftemplate salat (slot name) (slot farbe) (slot dazupasst) (slot gewicht))\n(deftemplate getraenk (slot name) (slot farbe) )\n(deftemplate farbe (slot name) (slot red) (slot green) (slot blue) )\n\n(assert (wurst (name \"gruenspanwurst\") (spitzname \"gruebi\") (farbe \"hellgruen\") (gewicht 1) ))\n(assert (wurst (name \"bratwurst\")(spitzname \"bratwosch\")(farbe \"weiss\")(gewicht 100) ))\n(assert (wurst (name \"weisswurst\")(spitzname \"weisswurst\")(farbe \"weiss\")(gewicht 200) ))\n(assert (wurst (name \"wienerwurst\")(spitzname \"wiener\")(farbe \"rot\")(gewicht 300) ))\n(assert (wurst (name \"gemuesewurst\")(spitzname \"gemuesewurst\")(farbe \"gruen\")(gewicht 400) ))\n(assert (wurst (name \"senfwurst\") (spitzname \"senfi\") (farbe \"gelb\") (gewicht 200) ))\n(assert (salat (name \"kartoffelsalat\")(farbe \"weiss\")(gewicht 220)(dazupasst \"weisswurst\") ))\n(assert (salat (name \"weissgurkensalat\")(farbe \"weiss\")(dazupasst \"spaghetti\")(gewicht 320) ))\n(assert (salat (name \"gelbebohnensalat\") (farbe \"gelb\") (dazupasst \"knoblauchmarmelade\") (gewicht 123) ))\n(assert (salat (name \"gruengurkensalat\")(farbe \"hellgruen\")(dazupasst \"spaghettisd\")(gewicht 32320) ))\n(assert (getraenk (name \"wasser\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"cola\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"kartoffelsalatdrink\") (farbe \"weiss\") ))\n\n(assert (farbe (name weiss) (red 1) (green 1) (blue 1)))\n(assert (farbe (name schwarz) (red 0) (green 0) (blue 0)))\n(assert (farbe (name rot) (red 1) (green 0) (blue 0)))\n(assert (farbe (name gruen) (red 0) (green 1) (blue 0)))\n(assert (farbe (name blau) (red 0) (green 0) (blue 1)))\n(assert (farbe (name gelb) (red 1) (green 1) (blue 0)))\n(assert (farbe (name hellgruen) (red 0.3) (green 1) (blue 0.3)))\n\n(defrule nichtgelbpaar\n\t(wurst (farbe ?wurstfarbe) (name ?wurstname) )\n\t(salat (farbe ?salatfarbe) (name ?salatname) )\n\t(farbe (name ?wurstfarbe & ?salatfarbe & ~ gelb & ?farbe) (green ?gruen) (blue ?blau) )\n\t(farbe (name ?farbe) (red ?rot) )\n\t(test (eq (str-length ?farbe) 5) )\n\t=> \n\t(printout t \"Ein Wurst\/Salat Paar mit gleicher Farbe (bei der der Name die L\u00e4nge 5 hat), die nicht Gelb ist, ist \" ?wurstname \"\/\" ?salatname \" und hat die RGB Farbanteile \" ?rot \",\" ?gruen \",\" ?blau \"!\" crlf)\n)\n\n(fire)\n\n\n\n(defrule babaam\n\t(or\t\n\t\t(not (wurst (name \"weisswurst\") ) )\n\t\t(not (wurst (name \"bratwurst\") ) )\n\t)\n\t=>\n\t(printout t \"es gibt entweder keine w oder keine b\" crlf)\n)\n\n(fire)\n\n(defrule vorschlag\n \t(salat (name ?salatname) (dazupasst ?match))\n \t(not\n \t\t(wurst (name ?match))\n \t)\n \t(not\n \t\t(wurst (gewicht 300))\n \t)\n \t=>\n \t(printout t \"man kann einen \" ?salatname \" essen.\" crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (farbe ?f) )\n\t(salat (name ?y) (farbe ?f) )\n\t=> (printout t ?x ?y crlf)\n)\n(fire)\n\n\n\n\n\n\n\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n\n\n(defrule megarule\n\t\t(salat (farbe ~ \"weiss\")(name ?weight) )\t\n\t=> (printout t ?weight crlf)\n)\n\n(fire)\n\n\n(defrule eineandereregelf\n\t?x <- (wurst)\n\t(test (less (fact-slot-value (get-fact-id ?x) \"gewicht\") 290) )\n\t=> (printout t \"jep \" ?x \" hat gewicht <290 n\u00e4mlich \" (fact-slot-value (get-fact-id ?x) \"gewicht\") crlf)\n)\n\n(fire)\n\n\n\n\n\n\n\n\n\n\n\n\n(defrule six\n\t?x <- (wurst (gewicht ?y & :(less ?y ?z) ))\n\t(salat (name \"kartoffelsalat\") (gewicht ?z))\n\t=> \n\t(printout t \"wurst die schwerer als kartoffelsalat ist: \" (get-fact-id ?x) crlf)\n)\n(fire)\n\n\n\n(defrule foo\n(wurst (farbe a & b & c & d & e | f | g & h))\n=>\n)\n\n\n\n\n\n(defrule ababab\n\t(salat (farbe ?farbe))\n\t?x <- (wurst (farbe ?farbe))\n=>\n\t(printout t (get-fact-id ?x) crlf )\n)\n(fire)\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (spitzname ?y))\n\t=> (printout t ?x crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n(defrule megarule1\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t=> (printout t \"Es gibt sowohl einen Salat, als auch eine Wurst, die \" ?farbe \"ist.\" crlf)\n)\n\n\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) )\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t(salat (name ?salatname))\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n\n\n(defrule zero\n => (printout t \"boombam\" crlf)\n)\n\n(defrule one\n\t(wurst (name ?x))\n\t=> (printout t \"rule with one condition fired \" ?x crlf)\n)\n\n(defrule two\n\t(wurst (name \"bratwurst\"))\n\t(wurst (farbe \"weiss\"))\n\t=> (printout t \"rule with two conditions fired \" crlf)\n)\n\n(defrule three\n\t(wurst (name \"wienerwurst\"))\n\t=> (printout t \"rule with one condition fired - wienerwurst\" crlf)\n)\n\n(defrule four\n\t?x <- (wurst (name \"wienerwurst\"))\n\t=> \n\t(printout t \"rule with one binding fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule five\n\t?x <- (wurst (name \"wienerwurst\") (gewicht ?y:&(> ?y 111))\n\t=> \n\t(printout t \"rule with one predicate constraint fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule six\n\t?x <- (wurst (gewicht ?y:&(> ?y ?z))\n\t(salat (name \"kartoffelsalat\") (gewicht ?z))\n\t=> \n\t(printout t \"rule with one predicate constraint and an internal join fired\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(fire)","old_contents":"\n(deftemplate wurst (slot name) (slot spitzname) (slot farbe) (slot gewicht))\n(deftemplate salat (slot name) (slot farbe) (slot dazupasst) (slot gewicht))\n(deftemplate getraenk (slot name) (slot farbe) )\n(deftemplate farbe (slot name) (slot red) (slot green) (slot blue) )\n\n(assert (wurst (name \"bratwurst\")(spitzname \"bratwosch\")(farbe \"weiss\")(gewicht 100) ))\n(assert (wurst (name \"weisswurst\")(spitzname \"weisswurst\")(farbe \"weiss\")(gewicht 200) ))\n(assert (wurst (name \"wienerwurst\")(spitzname \"wiener\")(farbe \"rot\")(gewicht 300) ))\n(assert (wurst (name \"gemuesewurst\")(spitzname \"gemuesewurst\")(farbe \"gruen\")(gewicht 400) ))\n(assert (wurst (name \"senfwurst\") (spitzname \"senfi\") (farbe \"gelb\") (gewicht 200) ))\n(assert (salat (name \"kartoffelsalat\")(farbe \"weiss\")(gewicht 220)(dazupasst \"weisswurst\") ))\n(assert (salat (name \"gurkensalat\")(farbe \"weiss\")(dazupasst \"spaghetti\")(gewicht 320) ))\n(assert (salat (name \"gelbebohnensalat\") (farbe \"gelb\") (dazupasst \"knoblauchmarmelade\") (gewicht 123) ))\n(assert (getraenk (name \"wasser\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"cola\") (farbe \"schwarz\") ))\n(assert (getraenk (name \"kartoffelsalatdrink\") (farbe \"weiss\") ))\n\n(assert (farbe (name weiss) (red 1) (green 1) (blue 1)))\n(assert (farbe (name schwarz) (red 0) (green 0) (blue 0)))\n(assert (farbe (name rot) (red 1) (green 0) (blue 0)))\n(assert (farbe (name gruen) (red 0) (green 1) (blue 0)))\n(assert (farbe (name blau) (red 0) (green 0) (blue 1)))\n(assert (farbe (name gelb) (red 1) (green 1) (blue 0)))\n\n\n(defrule nichtgelbpaar\n\t(wurst (farbe ?wurstfarbe) (name ?wurstname) )\n\t(salat (farbe ?salatfarbe) (name ?salatname) )\n\t(farbe (name ?wurstfarbe & ?salatfarbe & ~ gelb) (red ?rot) (green ?gruen) (blue ?blau) )\n\t=> \n\t(printout t \"Ein Wurst\/Salat Paar mit gleicher Farbe, die nicht Gelb ist, ist \" ?wurstname \"\/\" ?salatname \" und hat die RGB Farbanteile \" ?rot \",\" ?gruen \",\" ?blau \"!\" crlf)\n)\n\n(fire)\n\n\n\n(defrule babaam\n\t(or\t\n\t\t(not (wurst (name \"weisswurst\") ) )\n\t\t(not (wurst (name \"bratwurst\") ) )\n\t)\n\t=>\n\t(printout t \"es gibt entweder keine w oder keine b\" crlf)\n)\n\n(fire)\n\n(defrule vorschlag\n \t(salat (name ?salatname) (dazupasst ?match))\n \t(not\n \t\t(wurst (name ?match))\n \t)\n \t(not\n \t\t(wurst (gewicht 300))\n \t)\n \t=>\n \t(printout t \"man kann einen \" ?salatname \" essen.\" crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (farbe ?f) )\n\t(salat (name ?y) (farbe ?f) )\n\t=> (printout t ?x ?y crlf)\n)\n(fire)\n\n\n\n\n\n\n\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n\n\n(defrule megarule\n\t\t(salat (farbe ~ \"weiss\")(name ?weight) )\t\n\t=> (printout t ?weight crlf)\n)\n\n(fire)\n\n\n(defrule eineandereregelf\n\t?x <- (wurst)\n\t(test (less (fact-slot-value (get-fact-id ?x) \"gewicht\") 290) )\n\t=> (printout t \"jep \" ?x \" hat gewicht <290 n\u00e4mlich \" (fact-slot-value (get-fact-id ?x) \"gewicht\") crlf)\n)\n\n(fire)\n\n\n\n\n\n\n\n\n\n\n\n\n(defrule six\n\t?x <- (wurst (gewicht ?y & :(less ?y ?z) ))\n\t(salat (name \"kartoffelsalat\") (gewicht ?z))\n\t=> \n\t(printout t \"wurst die schwerer als kartoffelsalat ist: \" (get-fact-id ?x) crlf)\n)\n(fire)\n\n\n\n(defrule foo\n(wurst (farbe a & b & c & d & e | f | g & h))\n=>\n)\n\n\n\n\n\n(defrule ababab\n\t(salat (farbe ?farbe))\n\t?x <- (wurst (farbe ?farbe))\n=>\n\t(printout t (get-fact-id ?x) crlf )\n)\n(fire)\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) (farbe ?farbe))\n\t(salat (farbe ?farbe)(name ?salatname) )\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n(fire)\n\n(defrule tst2\n\t(wurst (name ?x) (spitzname ?y))\n\t=> (printout t ?x crlf)\n)\n\n(defrule tst\n\t(wurst (name ~ ?salad))\n\t(salat (name ?salad))\n\t(getraenk (name ~ ?salad))\n\t=> (printout t ?salad crlf)\n)\n\n\n(defrule megarule1\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t=> (printout t \"Es gibt sowohl einen Salat, als auch eine Wurst, die \" ?farbe \"ist.\" crlf)\n)\n\n\n\n\n(defrule megarule\n\t(wurst (name ?wurstname) (spitzname ?wurstname) )\n\t(salat (farbe ?farbe))\n\t(wurst (farbe ?farbe))\n\t(salat (name ?salatname))\t\n\t=> (printout t \"Die Wurst \" ?wurstname \" und der Salat \" ?salatname \" haben dieselbe Farbe, naemlich \" ?farbe \"! Ausserdem hat die Wurst denselben Spitznamen wie Name\" crlf)\n)\n\n\n\n(defrule zero\n => (printout t \"boombam\" crlf)\n)\n\n(defrule one\n\t(wurst (name ?x))\n\t=> (printout t \"rule with one condition fired \" ?x crlf)\n)\n\n(defrule two\n\t(wurst (name \"bratwurst\"))\n\t(wurst (farbe \"weiss\"))\n\t=> (printout t \"rule with two conditions fired \" crlf)\n)\n\n(defrule three\n\t(wurst (name \"wienerwurst\"))\n\t=> (printout t \"rule with one condition fired - wienerwurst\" crlf)\n)\n\n(defrule four\n\t?x <- (wurst (name \"wienerwurst\"))\n\t=> \n\t(printout t \"rule with one binding fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule five\n\t?x <- (wurst (name \"wienerwurst\") (gewicht ?y:&(> ?y 111))\n\t=> \n\t(printout t \"rule with one predicate constraint fired - wienerwurst\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(defrule six\n\t?x <- (wurst (gewicht ?y:&(> ?y ?z))\n\t(salat (name \"kartoffelsalat\") (gewicht ?z))\n\t=> \n\t(printout t \"rule with one predicate constraint and an internal join fired\" crlf)\n\t(printout t \"fact id of the wienerwurst fact\" (get-fact-id ?x) crlf)\n)\n\n(fire)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"73941d1fe0e31df771789545b2c9fa35af489d55","subject":"Fixed CloneInstructionIntoBlock","message":"Fixed CloneInstructionIntoBlock\n\nI fixed the duplicate-instance and message sends to use the proper instance\nnames instead of the straight id value.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::AssertScheduleCPVIntoTargetBlock \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a Diplomat) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (MovableCompensationPathVectors \n $?cpvs&:(<> 0 (length$ $?cpvs))))\n =>\n (modify-instance ?agObj (MovableCompensationPathVectors))\n (progn$ (?cpv $?cpvs)\n (assert (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsMove\n \"This rule attempts to determine if the CPV should be moved into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;the two sets are the same\n (test (equal$ ?paths ?cpvPaths))\n =>\n ;change the action...nothing more :D\n (modify ?fct (action move-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsCompensate\n \"This rule attempts to determine if the CPV should be copied into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted.\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;there are more paths in the CPV than in the block\n (test (subsetp ?paths ?cpvPaths))\n =>\n (modify ?fct (action clone-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::RemoveScheduleStyleForCPV\n (declare (salience 1))\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (parent ?i)\n (Paths $?cpvPaths))\n (test (not (subsetp ?paths ?cpvPaths)))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n ;TODO: Put code in here to delete a given instruction from the target\n ; instruction list as well. \n ;\n ; Eventually, I will detect if we are in a loop. If we are then it is\n ; necessary to figure out which paths remain in the loop and those\n ; that exit. \n ;this should prevent a potential infinite loop\n ;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::MoveInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last)\n (Produces $?nBProds))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n (class ?class))\n ?oldBlock <- (object (is-a BasicBlock) \n (id ?otherBlock) \n (Produces $?pBefore ?inst $?pRest)\n (contents $?before ?inst $?rest))\n ;TODO: add another rule where we have to update the consumers list as\n ; well\n =>\n (object-pattern-match-delay\n ;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n (modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n (modify-instance ?oldBlock (contents $?before $?rest) \n (Produces $?pBefore $?pRest))\n ;(modify-instance ?cpvObject (Paths))\n (modify ?fct (action remove-evidence)\n (arguments ?inst => $?niConsumers))\n (assert (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?otherBlock)))\n (if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n else\n (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?newName ?last))\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?newInst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (Producers) \n (Consumers)\n (NonLocalDependencies) \n (LocalDependencies)\n (TimeIndex ?ti) \n (parent ?e))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::CloneInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst) \n (Paths $?cpvPaths))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (class ?class))\n =>\n ;we also need to update all CPVs within \n (object-pattern-match-delay\n (bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n ;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n ; \" as \" ?newName crlf)\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?newInst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (parent ?e)\n (TimeIndex (+ ?ti 1)))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n ;we add the original name so that we don't have to do\n ; an insane number of updates to the CPVs that follow\n ; this object\n (if (eq StoreInstruction ?class) then \n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n else\n (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n (slot-insert$ ?newBlock Produces 1 ?register)\n (modify-instance ?newBlock (contents $?blockBefore ?newName ?last))\n (slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n (slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n (slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify ?fct (action recompute-block)\n (arguments ?otherBlock))\n (assert (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv)))\n (bind ?leftOvers (create$))\n (progn$ (?z ?cpvPaths)\n (bind ?cPath (instance-address * \n (symbol-to-instance-name ?z)))\n (if (not (member$ ?e (send ?cPath get-values))) then\n (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n (modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-CLONE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-MOVE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-SCHEDULE-STYLE\n (declare (salience -768))\n (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p)\n (Aliases $?aliases)\n (Paths $?cpvPaths))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Instruction) \n (id ?p) \n (parent ?bb))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r) \n (Paths $?paths))\n (object (is-a Wavefront) \n (parent ?r) \n (values $?z) \n (Closed $?y))\n (object (is-a Region) \n (id ?r) \n (Entrances ?x $?))\n (object (is-a BasicBlock) \n (id ?x) \n (Paths $?allPaths))\n =>\n (printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n \" which is targeted for \" ?e crlf\n \"Blocks on the wavefront = \" ?z crlf\n \"Closed Blocks = \" ?y crlf\n \"For reference ?cpvPaths = \" ?cpvPaths crlf\n \"For reference aliases of ?cpv are = \" $?aliases crlf\n \"For reference ?paths = \" ?paths crlf\n \"Parent of \" ?p \" is \" ?bb crlf\n \"Printing out the path aggregate for \" ?p crlf )\n (send ?pa print)\n (progn$ (?apath ?allPaths)\n (bind ?aObj (instance-name (symbol-to-instance-name ?apath)))\n (printout t \" \" ?apath \" = \" (send ?aObj get-contents) crlf))\n (facts)\n (halt))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::AssertScheduleCPVIntoTargetBlock \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a Diplomat) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (MovableCompensationPathVectors \n $?cpvs&:(<> 0 (length$ $?cpvs))))\n =>\n (modify-instance ?agObj (MovableCompensationPathVectors))\n (progn$ (?cpv $?cpvs)\n (assert (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsMove\n \"This rule attempts to determine if the CPV should be moved into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;the two sets are the same\n (test (equal$ ?paths ?cpvPaths))\n =>\n ;change the action...nothing more :D\n (modify ?fct (action move-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsCompensate\n \"This rule attempts to determine if the CPV should be copied into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted.\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;there are more paths in the CPV than in the block\n (test (subsetp ?paths ?cpvPaths))\n =>\n (modify ?fct (action clone-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::RemoveScheduleStyleForCPV\n (declare (salience 1))\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (parent ?i)\n (Paths $?cpvPaths))\n (test (not (subsetp ?paths ?cpvPaths)))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n ;TODO: Put code in here to delete a given instruction from the target\n ; instruction list as well. \n ;\n ; Eventually, I will detect if we are in a loop. If we are then it is\n ; necessary to figure out which paths remain in the loop and those\n ; that exit. \n ;this should prevent a potential infinite loop\n ;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::MoveInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last)\n (Produces $?nBProds))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n (class ?class))\n ?oldBlock <- (object (is-a BasicBlock) \n (id ?otherBlock) \n (Produces $?pBefore ?inst $?pRest)\n (contents $?before ?inst $?rest))\n ;TODO: add another rule where we have to update the consumers list as\n ; well\n =>\n (object-pattern-match-delay\n ;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n (modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n (modify-instance ?oldBlock (contents $?before $?rest) \n (Produces $?pBefore $?pRest))\n ;(modify-instance ?cpvObject (Paths))\n (modify ?fct (action remove-evidence)\n (arguments ?inst => $?niConsumers))\n (assert (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?otherBlock)))\n (if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n else\n (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?newName ?last))\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (bind ?inst-addr (instance-address * \n (symbol-to-instance-name ?inst)))\n (duplicate-instance ?inst-addr to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (Producers) \n (Consumers)\n (NonLocalDependencies) \n (LocalDependencies)\n (TimeIndex ?ti) \n (parent ?e))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::CloneInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst) \n (Paths $?cpvPaths))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (class ?class))\n =>\n ;we also need to update all CPVs within \n (object-pattern-match-delay\n (bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n ;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n ; \" as \" ?newName crlf)\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (parent ?e)\n (TimeIndex (+ ?ti 1)))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n ;we add the original name so that we don't have to do\n ; an insane number of updates to the CPVs that follow\n ; this object\n (if (eq StoreInstruction ?class) then \n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n else\n (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n (slot-insert$ ?newBlock Produces 1 ?register)\n (modify-instance ?newBlock (contents $?blockBefore ?newName ?last))\n (slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n (slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n (slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify ?fct (action recompute-block)\n (arguments ?otherBlock))\n (assert (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv)))\n (bind ?leftOvers (create$))\n (progn$ (?z ?cpvPaths)\n (bind ?cPath (symbol-to-instance-name ?z))\n (if (not (member$ ?e (send ?cPath get-contents))) then\n (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n (modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-CLONE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-MOVE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-SCHEDULE-STYLE\n (declare (salience -768))\n (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p)\n (Aliases $?aliases)\n (Paths $?cpvPaths))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Instruction) \n (id ?p) \n (parent ?bb))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r) \n (Paths $?paths))\n (object (is-a Wavefront) \n (parent ?r) \n (values $?z) \n (Closed $?y))\n (object (is-a Region) \n (id ?r) \n (Entrances ?x $?))\n (object (is-a BasicBlock) \n (id ?x) \n (Paths $?allPaths))\n =>\n (printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n \" which is targeted for \" ?e crlf\n \"Blocks on the wavefront = \" ?z crlf\n \"Closed Blocks = \" ?y crlf\n \"For reference ?cpvPaths = \" ?cpvPaths crlf\n \"For reference aliases of ?cpv are = \" $?aliases crlf\n \"For reference ?paths = \" ?paths crlf\n \"Parent of \" ?p \" is \" ?bb crlf\n \"Printing out the path aggregate for \" ?p crlf )\n (send ?pa print)\n (progn$ (?apath ?allPaths)\n (bind ?aObj (instance-name (symbol-to-instance-name ?apath)))\n (printout t \" \" ?apath \" = \" (send ?aObj get-contents) crlf))\n (facts)\n (halt))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"cff43b84837626bec45d0718d05779eed916cd76","subject":"Added set_delete function and rule.","message":"Added set_delete function and rule.\n\n-> For facts that should be deleted after a certain time.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/utils.clp","new_file":"CLIPS\/utils.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym (time) (\/ ?time 1000.0)))\n)\n\n(defrule clear_timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ? ?time ?duration)\n\t(test (>= (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ?sym ?time ?duration)\n\t(test (< (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n\t(assert (timer_sent ?sym ?time ?duration))\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n\n(deffunction set_delete\n\t(?fact ?time_in_secs)\n\t(bind ?sym (gensym*))\n\t(setTimer (* ?time_in_secs 1000) ?sym)\n\t(assert\n\t\t(BB_set_delete ?fact ?sym)\n\t)\n)\n\n(defrule set_delete-delete_fact\n\t(BB_timer ?sym)\n\t?f <-(BB_set_delete ?fact ?sym)\n\t=>\n\t(retract ?f ?fact)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\t\t\tGLOBALS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defglobal ?*outlog* = t)\n(defglobal ?*logLevel* = ERROR) ; INFO | WARNING | ERROR | DEBUG (print always)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\t\tFUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction log-message\n\t; Receives level and message chunks that would be concatenated.\n\t; Level is one of: INFO | WARNING | ERROR | DEBUG (print always)\n\t(?level ?msg1 $?msg2)\n\n\t(bind ?message ?msg1)\n\t(progn$ (?var $?msg2)\n\t\t(bind ?message (str-cat ?message ?var) )\n\t)\n\t(if (eq ?level DEBUG) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t\t(return)\n\t)\n\t(bind ?currentLogLevel 10)\n\t(bind ?lvl 10)\n\t(switch ?*logLevel*\n\t\t(case INFO then (bind ?currentLogLevel 0))\n\t\t(case ERROR then (bind ?currentLogLevel 20))\n\t\t(case WARNING then (bind ?currentLogLevel 10))\n\t)\n\t(switch ?level\n\t\t(case INFO then (bind ?lvl 0))\n\t\t(case ERROR then (bind ?lvl 20))\n\t\t(case WARNING then (bind ?lvl 10))\n\t)\n\t(if (>= ?lvl ?currentLogLevel) then\n\t\t(printout ?*outlog* ?level \": \" ?message crlf)\n\t)\n)\n\n(deffunction setCmdTimer\n\t(?time ?cmd ?id)\n\t(python-call setCmdTimer ?time ?cmd ?id)\n)\n\n(deffunction setTimer\n\t; Receives time in miliseconds and a symbol to identify fact that indicates the timer ran off.\n\t(?time ?sym)\n\t(python-call setTimer ?time ?sym)\n\t(assert (timer_sent ?sym (time) (\/ ?time 1000.0)))\n)\n\n(defrule clear_timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer $?)\n\t=>\n\t(retract ?t)\n)\n\n(defrule delete_old_timers\n\t(declare (salience -1000))\n\t?t <-(timer_sent ? ?time ?duration)\n\t(test (> (time) (+ ?time ?duration) ) )\n\t=>\n\t(retract ?t)\n)\n\n(deffunction sleep\n\t; Receives time in miliseconds.\n\t; Prevents python from running during that time, even when messages are received.\n\t(?ms)\n\t(bind ?sym (gensym*))\n\t(python-call sleep ?ms ?sym)\n\t(halt)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"7e1063b52eddc4ddd94f9bfb78861fb004401fa6","subject":"Added WidgetEvent.clp","message":"Added WidgetEvent.clp\n\nA WidgetEvent object is a standard way to define event handlers for different\nactions for a given widget.\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/lib\/widget\/WidgetEvent.clp","new_file":"src\/lib\/widget\/WidgetEvent.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetEvent.clp - Base class of all events to cause widgets to do things\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetEvent\n \"Base class of all events in the widget library\"\n (is-a Object)\n (slot event-name (type SYMBOL))\n (slot function-to-call (type SYMBOL))\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n(defmessage-handler widget::WidgetEvent raise-event primary ($?args)\n (funcall ?self:function-to-call $?args))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/lib\/widget\/WidgetEvent.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"673eb5e9d4626a56e251b332fa31cf33462a416b","subject":"- fixed a bug in fipa-requestWhen protocol","message":"- fixed a bug in fipa-requestWhen protocol\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1468 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"apps\/jamochaagent\/protocols\/fipa-requestWhen.clp","new_file":"apps\/jamochaagent\/protocols\/fipa-requestWhen.clp","new_contents":"; ===================================================\n; Definition of rules that handle the protocol\n; fipa-request-when for all possible performatives.\n; ===================================================\n\n(defrule fipa-requestWhen-error\n\t\"Fires for agent-evaluation-error facts with protocol request and performative request.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t)\n\t(agent-evaluation-error\n\t\t(message ?message)\n\t\t(error ?error)\n\t)\n\t\n\t=>\n\t\n\t(bind ?receivers (prepare-receivers ?message))\n\t\n\t(assert \n\t\t(agent-message\n\t\t\t(receivers ?receivers)\n\t\t\t(performative \"refuse\")\n\t\t\t(content (str-cat (fact-slot-value ?message \"content\") crlf \"\\\"\" ?error \"\\\"\"))\n\t\t\t(language (fact-slot-value ?message \"language\"))\n\t\t\t(encoding (fact-slot-value ?message \"encoding\"))\n\t\t\t(ontology (fact-slot-value ?message \"ontology\"))\n\t\t\t(protocol (fact-slot-value ?message \"protocol\"))\n\t\t\t(conversation-id (fact-slot-value ?message \"conversation-id\"))\n\t\t\t(in-reply-to (fact-slot-value ?message \"reply-with\"))\n\t\t\t(reply-with \"\")\n\t\t\t(reply-by 0)\n\t\t\t(timestamp (datetime2timestamp (now)))\n\t\t\t(incoming FALSE)\n\t\t)\n\t)\n)\n\n(defrule fipa-requestWhen\n\t\"Fires for agent-message facts with protocol request-when and performative request-when that are not linked by an error.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t\t(processed TRUE)\n\t)\n\t(not\n\t\t(agent-evaluation-error\n\t\t\t(message ?message)\n\t\t)\n\t)\n\n\t=>\n\t\n\t(send-agree ?message \"\")\n\t\n)\n\n(defrule fipa-requestWhen-result\n\t\"Fires for agent-requestWhen-result facts with protocol request-when and performative request-when.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t)\n\t?inform <- (agent-message\n\t\t(performative \"inform\")\n\t\t(sender ?sender)\n\t\t(receivers ?receivers)\n\t\t(content ?content)\n\t)\n\t(agent-requestWhen-result\n\t\t(message ?message)\n\t\t(result ?result)\n\t)\n\t(test (eq ?inform (fact-id ?result)))\n\t\n\t=>\n\t\n\t(bind ?senderName (fact-slot-value ?sender \"name\"))\n\t\n\t(bind ?receiverList (agent-identifiers-to-names ?receivers))\n\t\t\n\t(assert\n\t\t(agent-message\n\t\t\t(sender ?senderName)\n\t\t\t(receivers ?receiverList)\n\t\t\t(performative \"inform\")\n\t\t\t(content ?content)\n\t\t\t(language (fact-slot-value ?message \"language\"))\n\t\t\t(encoding (fact-slot-value ?message \"encoding\"))\n\t\t\t(ontology (fact-slot-value ?message \"ontology\"))\n\t\t\t(protocol (fact-slot-value ?message \"protocol\"))\n\t\t\t(conversation-id (fact-slot-value ?message \"conversation-id\"))\n\t\t\t(in-reply-to (fact-slot-value ?message \"reply-with\"))\n\t\t\t(reply-with \"\")\n\t\t\t(reply-by 0)\n\t\t\t(timestamp (datetime2timestamp (now)))\n\t\t\t(incoming FALSE)\n\t\t)\n\t)\n)","old_contents":"; ===================================================\n; Definition of rules that handle the protocol\n; fipa-request-when for all possible performatives.\n; ===================================================\n\n(defrule fipa-requestWhen-error\n\t\"Fires for agent-evaluation-error facts with protocol request and performative request.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t)\n\t(agent-evaluation-error\n\t\t(message ?message)\n\t\t(error ?error)\n\t)\n\t\n\t=>\n\t\n\t(bind ?receivers (prepare-receivers ?message))\n\t\n\t(assert \n\t\t(agent-message\n\t\t\t(receivers ?receivers)\n\t\t\t(performative \"refuse\")\n\t\t\t(content (str-cat (fact-slot-value ?message \"content\") crlf \"\\\"\" ?error \"\\\"\"))\n\t\t\t(language (fact-slot-value ?message \"language\"))\n\t\t\t(encoding (fact-slot-value ?message \"encoding\"))\n\t\t\t(ontology (fact-slot-value ?message \"ontology\"))\n\t\t\t(protocol (fact-slot-value ?message \"protocol\"))\n\t\t\t(conversation-id (fact-slot-value ?message \"conversation-id\"))\n\t\t\t(in-reply-to (fact-slot-value ?message \"reply-with\"))\n\t\t\t(reply-with \"\")\n\t\t\t(reply-by 0)\n\t\t\t(timestamp (datetime2timestamp (now)))\n\t\t\t(incoming FALSE)\n\t\t)\n\t)\n)\n\n(defrule fipa-requestWhen\n\t\"Fires for agent-message facts with protocol request-when and performative request-when that are not linked by an error.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t\t(processed TRUE)\n\t)\n\t(not\n\t\t(agent-evaluation-error\n\t\t\t(message ?message)\n\t\t)\n\t)\n\n\t=>\n\t\n\t(send-agree ?message \"\")\n\t\n)\n\n(defrule fipa-requestWhen-result\n\t\"Fires for agent-requestWhen-result facts with protocol request-when and performative request-when.\"\n\t?message <- (agent-message\n\t\t(protocol \"fipa-request-when\")\n\t\t(performative \"request-when\")\n\t)\n\t?inform <- (agent-message\n\t\t(performative \"inform\")\n\t\t(sender ?sender)\n\t\t(receiver ?receivers)\n\t\t(content ?content)\n\t)\n\t(agent-requestWhen-result\n\t\t(message ?message)\n\t\t(result ?result)\n\t)\n\t(test (eq ?inform (fact-id ?result)))\n\t\n\t=>\n\t\n\t(bind ?senderName (fact-slot-value ?sender \"name\"))\n\t\n\t(bind ?receiverList (agent-identifiers-to-names ?receivers))\n\t\t\n\t(assert\n\t\t(agent-message\n\t\t\t(sender ?senderName)\n\t\t\t(receivers ?receiverList)\n\t\t\t(performative \"inform\")\n\t\t\t(content ?content)\n\t\t\t(language (fact-slot-value ?message \"language\"))\n\t\t\t(encoding (fact-slot-value ?message \"encoding\"))\n\t\t\t(ontology (fact-slot-value ?message \"ontology\"))\n\t\t\t(protocol (fact-slot-value ?message \"protocol\"))\n\t\t\t(conversation-id (fact-slot-value ?message \"conversation-id\"))\n\t\t\t(in-reply-to (fact-slot-value ?message \"reply-with\"))\n\t\t\t(reply-with \"\")\n\t\t\t(reply-by 0)\n\t\t\t(timestamp (datetime2timestamp (now)))\n\t\t\t(incoming FALSE)\n\t\t)\n\t)\n)","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"d91a575cfa7c54ed250e98e5ae9260fa0e5afe27","subject":"Add an example","message":"Add an example\n","repos":"vbkaisetsu\/clopure","old_file":"examples\/pmap-example.clp","new_file":"examples\/pmap-example.clp","new_contents":"(defimport builtins list)\n(defimport builtins print)\n(defimport time sleep)\n\n(doseq\n [x (pmap\n (fn [x]\n (do\n (sleep 0.5)\n (print \"+ x 1:\" x)\n (+ x 1)))\n (pmap\n (fn [x]\n (do\n (print \"* x x:\" x)\n (* x x)))\n [0 1 2 3 4 5 6 7 8 9]))]\n (print x))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/pmap-example.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"0b76c674bfae5822fe0a47e0d68101d34fa8b325","subject":"snapshot","message":"snapshot\n","repos":"Ramarren\/lisa","old_file":"misc\/sample.clp","new_file":"misc\/sample.clp","new_contents":"(deftemplate rocky\n (slot name))\n\n(deftemplate boris\n (slot name))\n\n(deftemplate natasha\n (slot name)\n (slot nemesis))\n\n(defrule nemesis\n (rocky (name ?n&\"rocky\"))\n (natasha (name \"natasha\") (nemesis ?n))\n =>\n (printout t \"nemesis fired!\" crlf))\n\n; (defrule schtum\n; ?rocky <- (rocky (name \"rocky\"))\n; (boris (name \"boris\"))\n; ?natasha <- (natasha (name \"natasha\"))\n; =>\n; (retract ?rocky)\n; (retract ?natasha)\n; (printout t \"schtum!\" crlf))\n\n; (defrule schtum-shared\n; (boris (name \"boris\"))\n; =>\n; (printout t \"schtum-shared!\" crlf))\n\n; (defrule schtum-simple\n; ?f <- (rocky (name \"rocky\"))\n; =>\n; (retract ?f)\n; (printout t \"schtum-simple!\" crlf))\n\n; (defrule no-patterns\n; =>\n; (printout t \"no-patterns!\" crlf))\n\n(assert (rocky (name \"rocky\")))\n(assert (natasha (name \"natasha\") (nemesis \"rocky\")))\n(run)\n","old_contents":"(deftemplate rocky\n (slot name))\n\n(deftemplate boris\n (slot name))\n\n(deftemplate natasha\n (slot name)\n (slot nemesis))\n\n;(defrule nemesis\n; (natasha (name \"natasha\") (nemesis \"bullwinkle\"))\n; =>\n; (printout t \"nemesis fired!\" crlf))\n\n (defrule schtum\n ?rocky <- (rocky (name \"rocky\"))\n (boris (name \"boris\"))\n ?natasha <- (natasha (name \"natasha\"))\n =>\n (retract ?rocky)\n (retract ?natasha)\n (printout t \"schtum!\" crlf))\n\n; (defrule schtum-shared\n; (boris (name \"boris\"))\n; =>\n; (printout t \"schtum-shared!\" crlf))\n\n; (defrule schtum-simple\n; ?f <- (rocky (name \"rocky\"))\n; =>\n; (retract ?f)\n; (printout t \"schtum-simple!\" crlf))\n\n; (defrule no-patterns\n; =>\n; (printout t \"no-patterns!\" crlf))\n\n;(reset)\n;(assert (natasha (name \"natasha\") (nemesis \"bullwinkle\")))\n;(retract (fact-id 1))\n(reset)\n(assert (rocky (name \"rocky\")))\n(assert (boris (name \"boris\")))\n(assert (natasha (name \"natasha\")))\n(run)\n;(assert (boris (name \"boris\")))\n;(retract (fact-id 1))\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"c22b90dcad06721094e11d35c5a8397131fbdd84","subject":"Added logic.clp to contain the single rule necessary to run indirect passes","message":"Added logic.clp to contain the single rule necessary to run indirect passes\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/main\/logic.clp","new_file":"lib\/durandal\/modules\/main\/logic.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule MAIN::run\n \"Starts the process of invoking a pass within clips. The fact asserted is \n generated by LLVM and passed into CLIPS automatically.\"\n ?fct <- (passes $?passes) \n =>\n (retract ?fct)\n (assert (message (from MAIN) (to pipeline)\n\t\t\t (action pass-description)\n\t\t\t (arguments $?passes)))\n (focus pipeline))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/modules\/main\/logic.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ba5b53e4a879dc896586b439fe3bda633eb49f09","subject":"Fixed a bug where I put multifield instead of multislot","message":"Fixed a bug where I put multifield instead of multislot\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"bd0b234d735c510870006c3e95ef55d20cdf8ab4","subject":"Deleted \/src\/module\/engine\/Object.clp","message":"Deleted \/src\/module\/engine\/Object.clp\n\nThis class has been made redundant by cortex::Object\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/modules\/engine\/Object.clp","new_file":"src\/modules\/engine\/Object.clp","new_contents":"","old_contents":"; Object.clp - Base class for all objects in Pathways\n; See LICENSE for licensing details\n; Written by Joshua Scoggins\n\n(defclass engine::Object \n \"Base class for all custom objects in pathways\"\n (is-a USER)\n (slot id (type SYMBOL) (access initialize-only) (visibility public)))\n\n(defmessage-handler engine::Object init around ()\n (call-next-handler)\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4292a8a708ac60683925ae21a4292f1322207433","subject":"Added more decode rules","message":"Added more decode rules\n\nThey're basically the same rule but with a different target. I will need to\neventually automate the process but at this point im not sure what would be the\nbest way to do that.\n","repos":"DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron","old_file":"Simulator.clp","new_file":"Simulator.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(defclass cell \n (is-a USER)\n (role abstract)\n (slot cell-type\n (type SYMBOL)\n (storage shared)\n (access read-only)\n (default unknown))\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (visibility public)\n (default-dynamic 0)))\n(defclass memory-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot cell-type\n (source composite)\n (default memory)))\n\n(defclass cache-cell\n (is-a cell)\n (role concrete)\n (pattern-match reactive)\n (slot address \n (source composite)\n (storage shared)\n (access initialize-only)\n (default 0))\n (slot cell-type\n (source composite)\n (default cache)))\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)))\n\n(defclass machine\n (is-a USER)\n (multislot registers \n (type INSTANCE)\n (allowed-classes register)))\n\n(defgeneric next)\n(defgeneric next-one)\n(defgeneric next-two)\n(defgeneric next-three)\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (!= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value (* ?i ?inc)))))\n (return ?out))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (> ?count 3))\n (?inc NUMBER (= ?inc 1)))\n (bind ?out (create$))\n (loop-for-count (?i 1 ?count) do\n (bind ?out (create$ ?out (+ ?value ?i))))\n (return ?out))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 1))\n (?inc NUMBER))\n (create$ (+ ?value ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)))\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 2))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (!= ?count 1)))\n (create$ (+ ?value ?inc)\n (+ ?value ?inc ?inc)\n (+ ?value ?inc ?inc ?inc)))\n\n(defmethod next \n ((?value NUMBER)\n (?count NUMBER (= ?count 3))\n (?inc NUMBER (= ?count 1)))\n (create$ (+ ?value 1)\n (+ ?value 2)\n (+ ?value 3)))\n\n(defmethod next\n ((?value NUMBER)\n (?count NUMBER))\n (next ?value ?count 1))\n\n\n(defmethod next-one\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 1 ?inc))\n\n(defmethod next-one\n ((?value NUMBER))\n (next ?value 1 1))\n\n(defmethod next-two\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 2 ?inc))\n\n(defmethod next-two\n ((?value NUMBER))\n (next ?value 2 1))\n\n(defmethod next-three\n ((?value NUMBER)\n (?inc NUMBER))\n (next ?value 3 ?inc))\n\n(defmethod next-three\n ((?value NUMBER))\n (next ?value 3 1))\n;TODO: automate the generation of the register set\n(defrule setup-machine\n (initial-fact)\n =>\n (bind ?registers (instance-name (make-instance pc of register (offset 256))))\n (loop-for-count (?i 0 255) do\n (bind ?registers (create$ ?registers (instance-name (make-instance (sym-cat r ?i) of register (offset ?i))))))\n (make-instance proc of machine \n (registers ?registers))\n (assert (Machine setup)))\n(defrule load-program-into-memory\n ?s <- (Machine setup)\n ?f <- (load ?program-path into memory)\n =>\n (retract ?s ?f)\n ;build the memory cells right now\n (if (open ?program-path file \"r\") then\n (bind ?this (get-char file))\n (bind ?i 0)\n (while (!= ?this -1) do\n (make-instance of memory-cell\n (address ?i)\n (value ?this))\n (bind ?this (get-char file))\n (bind ?i (+ ?i 1)))\n (close file)\n (assert (stage decode execute restart))\n else\n (printout t \"ERROR: Couldn't load program\" crlf)\n (halt)))\n(defrule next-stage\n (declare (salience -10000))\n ?f <- (stage ? $?rest)\n =>\n (retract ?f)\n (if (> (length$ ?rest) 0) then\n (assert (stage $?rest))))\n(defrule load-instruction-into-decoder \n (stage decode $?)\n (object (is-a register)\n (name [pc])\n (value ?location))\n (object (is-a memory-cell)\n (address ?location)\n (value ?operation))\n =>\n ;tee hee, silly computer scientist, it's not a fixed \n ;decoder location :D. But it will serve our purposes\n ;well.\n (assert (invoke operation ?operation at ?location)))\n\n(defrule decode:invalid\n (declare (salience -1))\n (stage decode $?)\n ?f <- (invoke operation ? at ?)\n =>\n (retract ?f)\n (printout t \"ERROR: Target operation is not valid\" crlf)\n (halt))\n\n\n; MACHINE SPECIFIC DESCRIPTION CODE FOLLOWS:\n; With the exception of one instruction, the rest of the instruction\n; set operates on available registers (which is why there are 255 of\n; them). This only applies to the externally visible instruction set\n; which is transformed internally to provide on the fly optimizations.\n;\n; This is the basis of the procedurally declarative processor design\n; I'm implementing. Eventually, this will have more features but at\n; this point it is important to get a basic implementation.\n;\n; TODO: Modify the instruction set to define the program counter\n(defglobal MAIN \n ; finding a zero will cause the processor to terminate instruction\n ; execution\n ?*terminate-instruction* = 0\n ?*nop-instruction* = 1\n ?*add-instruction* = 2\n ?*subtract-instruction* = 3\n ?*multiply-instruction* = 4\n ?*divide-instruction* = 5\n ?*right-shift-instruction* = 6\n ?*left-shift-instruction* = 7\n ?*equal-instruction* = 8\n ?*not-equal-instruction* = 9\n ?*less-than-instruction* = 10\n ?*greater-than-instruction* = 11\n ?*and-instruction* = 12\n ?*or-instruction* = 13\n ?*not-instruction* = 14\n ?*branch-instruction* = 15\n ; load r1 <= [r2] is the only supported load instruction\n ?*load-instruction* = 16 \n ; store [r1] <= r2 is the only supported store instruction\n ?*store-instruction* = 17\n ; set r1 <= constant is the only immediate operation in the\n ; instruction set\n ?*set-instruction* = 18\n ; system r1\n ?*interrupt-instruction* = 250\n )\n(defrule decode:nop\n \"defines a nop instruction\"\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*nop-instruction*) at ?)\n =>\n (retract ?f)\n (assert (nop)))\n\n(defrule decode:load\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?*load-instruction* ?x) at ?loc)\n =>\n (retract ?f)\n (assert (load (next-two ?loc))))\n\n(defrule decode:store\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*store-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (store (next-two ?loc))))\n\n(defrule decode:add\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*add-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (add (next-three ?loc))))\n\n(defrule decode:subtract\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*subtract-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (subtract (next-three ?loc))))\n\n(defrule decode:multiply\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*multiply-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (multiply (next-three ?loc))))\n\n(defrule decode:divide\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*divide-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (divide (next-three ?loc))))\n\n(defrule decode:equal\n (stage decode $?)\n ?f <- (invoke operation ?x&:(= ?x ?*equal-instruction*) at ?loc)\n =>\n (retract ?f)\n (assert (equal (next-three ?loc))))\n\n; NOTES\n; the encoding of this processor can change from time to time but my\n; current idea is to have a 255 byte window that represents a set of\n; actions to be performed by the machine itself. This isn't valid at\n; this point but I may come back to this at another point\n\n\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Simulator.clp - Defines a simple computer to be executed through an expert\n; system. This computer is unique in that instructions declare\n; actions instead of perform actions directly.\n;\n; The Theoretical Architecture is an 8-bit declarative\n; processor architecture. It has an 8-bit direct address space\n; that can be extended through the use of jump instructions.\n;-------------------------------------------------------------------------------\n(defclass cell \n (is-a USER)\n (role abstract)\n (slot cell-type\n (type SYMBOL)\n (storage shared)\n (access read-only)\n (default unknown))\n (slot address\n (type INTEGER)\n (visibility public)\n (storage local)\n (range 0 ?VARIABLE))\n (slot value\n (type INTEGER)\n (range 0 255)\n (visibility public)\n (default-dynamic 0)))\n(defclass memory-cell\n (is-a cell)\n (role concrete)\n (slot cell-type\n (source composite)\n (default memory)))\n\n(defclass cache-cell\n (is-a cell)\n (role concrete)\n (slot address \n (source composite)\n (storage shared)\n (access initialize-only)\n (default 0))\n (slot cell-type\n (source composite)\n (default cache)))\n\n(defclass register\n \"Represents a storage location that is \\\"close\\\" to the procesor\"\n (is-a USER)\n (slot offset\n (type INTEGER)\n (storage local)\n (default ?NONE))\n (slot value\n (type INTEGER)))\n\n(defclass machine\n (is-a USER)\n (multislot registers \n (type INSTANCE)\n (allowed-classes register)))\n;TODO: automate the generation of the register set\n(defrule setup-machine\n (initial-fact)\n =>\n (bind ?registers (instance-name (make-instance pc of register (offset 256))))\n (loop-for-count (?i 0 255) do\n (bind ?registers (create$ ?registers (instance-name (make-instance (sym-cat r ?i) of register (offset ?i))))))\n (make-instance proc of machine \n (registers ?registers))\n (assert (Machine setup)))\n(defrule load-program-into-memory\n ?s <- (Machine setup)\n ?f <- (load ?program-path into memory)\n =>\n (retract ?s ?f)\n ;build the memory cells right now\n (if (open ?program-path file \"r\") then\n (bind ?this (get-char file))\n (bind ?i 0)\n (while (!= ?this -1) do\n (make-instance of memory-cell\n (address ?i)\n (value ?this))\n (bind ?this (get-char file))\n (bind ?i (+ ?i 1)))\n (close ?file)\n (assert (stage decode execute restart))\n else\n (printout t \"ERROR: Couldn't load program\" crlf)\n (halt)))\n(defrule next-stage\n (declare (salience -10000))\n ?f <- (stage ? $?rest)\n =>\n (retract ?f)\n (if (> (length$ ?rest) 0) then\n (assert (stage $?rest))))\n(defrule load-instruction-into-decoder \n (stage decode $?)\n (object (is-a register)\n (name [pc])\n (value ?location))\n (object (is-a memory-cell)\n (address ?location)\n (value ?operation))\n =>\n ;tee hee, silly computer scientist, it's not a fixed \n ;decoder location :D. But it will serve our purposes\n ;well.\n (assert (invoke operation ?operation at ?location)))\n\n(defrule decode:invalid\n (declare (salience -1))\n (stage decode $?)\n ?f <- (invoke operation ? at ?)\n =>\n (retract ?f)\n (printout t \"ERROR: Target operation is not valid\" crlf)\n (halt))\n; MACHINE SPECIFIC DESCRIPTION CODE FOLLOWS:\n; With the exception of one instruction, the rest of the instruction\n; set operates on available registers (which is why there are 255 of\n; them). This only applies to the externally visible instruction set\n; which is transformed internally to provide on the fly optimizations.\n;\n; This is the basis of the procedurally declarative processor design\n; I'm implementing. Eventually, this will have more features but at\n; this point it is important to get a basic implementation.\n;\n; TODO: Modify the instruction set to define the program counter\n(defglobal MAIN \n ; finding a zero will cause the processor to terminate instruction\n ; execution\n ?*terminate-instruction* = 0\n ?*nop-instruction* = 1\n ?*add-instruction* = 2\n ?*subtract-instruction* = 3\n ?*multiply-instruction* = 4\n ?*divide-instruction* = 5\n ?*right-shift-instruction*= 6\n ?*left-shift-instruction* = 7\n ?*equal-instruction* = 8\n ?*not-equal-instruction* = 9\n ?*less-than-instruction* = 10\n ?*greater-than-instruction* = 11\n ?*and-instruction* = 12\n ?*or-instruction* = 13\n ?*not-instruction* = 14\n ; uses a register as a predicate \n ; br r1 [r2]\n ?*branch-instruction* = 15\n ; load r1 <= [r2] is the only supported load instruction\n ?*load-instruction* = 16 \n ; store [r1] <= r2 is the only supported store instruction\n ?*store-instruction* = 17\n ; set r1 <= constant is the only immediate operation in the\n ; instruction set\n ?*set-instruction* = 18\n ; system r1\n ?*interrupt-instruction* = 250\n ?*terminate-instruction* = 255)\n(defrule decode:nop\n \"defines a nop instruction\"\n (stage decode $?)\n ?f <- (invoke operation 0 at ?location)\n =>\n (retract ?f)\n (assert (nop)))\n\n(defrule decode:load:base\n \"the current operation is a load, further analysis required\"\n (stage decode $?)\n ?f <- (invoke operation 1 at ?location)\n =>\n (retract ?f)\n (assert (determine:load ?location)))\n\n(defrule decode:load:register<=immediate\n (stage decode $?)\n ?f <- (determine:load ?offset)\n ;grab the status code\n (object (is-a memory-cell)\n (address =(+ ?offset 1))\n (value 0))\n =>\n (retract ?f)\n (assert (load register<=immediate ?destl ?srcl)))\n(defrule decode:load:register<=register-immediate\n (stage decode $?)\n ?f <- (load 1 ?destl ?srcl)\n =>\n (retract ?f)\n (assert (load register<=register-immediate ?destl ?srcl)))\n(defrule decode:store:base\n (stage decode $?)\n ?f <- (invoke operation 2 at ?location\n(defrule add-operation\n (stage execute $?)\n\n; NOTES\n; the encoding of this processor can change from time to time but my\n; current idea is to have a 255 byte window that represents a set of\n; actions to be performed by the machine itself. This isn't valid at\n; this point but I may come back to this at another point\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"20188c4691348567fdbed53166e0e51ece0eccc4","subject":"Added the interface slot to the message template","message":"Added the interface slot to the message template\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-filesystem","old_file":"sys\/core\/message.clp","new_file":"sys\/core\/message.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; message.clp - Defines the standard message template. Useful for passing \n; information between modules and making it possible to have reusable code.\n;------------------------------------------------------------------------------\n(deftemplate message\n \"A standard way to pass information around\"\n (slot interface)\n (slot to)\n (slot from)\n (slot action)\n (multislot contents))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; message.clp - Defines the standard message template. Useful for passing \n; information between modules and making it possible to have reusable code.\n;------------------------------------------------------------------------------\n(deftemplate message\n \"A standard way to pass information around\"\n (slot to)\n (slot from)\n (slot action)\n (multislot contents))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"7977da0a1edc36fc6e24d3a9f10ddf2f30507388","subject":"\/lib\/core.clp is now loaded by \/logic\/painter.clp","message":"\/lib\/core.clp is now loaded by \/logic\/painter.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/core.clp)\n(load* \/lib\/chicanery.clp)\n(defglobal MAIN\n ?*old-timestamp* = 0\n ?*max-factor* = 128\n ?*factor* = 1)\n\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (bind ?*old-timestamp* (send [mouse] get-timestamp))\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?*factor*)) \n (by (+ ?y ?*factor*)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n =>\n (if (< ?*factor* ?*max-factor*) then\n (bind ?*factor* (+ ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n =>\n (if (> ?*factor* 1) then\n (bind ?*factor* (- ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery.clp)\n(defglobal MAIN\n ?*old-timestamp* = 0\n ?*max-factor* = 128\n ?*factor* = 1)\n\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (bind ?*old-timestamp* (send [mouse] get-timestamp))\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?*factor*)) \n (by (+ ?y ?*factor*)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n =>\n (if (< ?*factor* ?*max-factor*) then\n (bind ?*factor* (+ ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n =>\n (if (> ?*factor* 1) then\n (bind ?*factor* (- ?*factor* 1)))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"1976a3bfbd2e58d1d996f553ffd891d96ee41358","subject":"imprimir solucion","message":"imprimir solucion\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n; Thu May 05 18:47:28 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 18:47:28 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n)\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)","old_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n)\n\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"e2723fd6d9d0fe34353a43b49b302aa15ea464c0","subject":"Added a new rule to identify #defines","message":"Added a new rule to identify #defines\n\nI also modified the blank line remover to remove all lines that haven't been\ntagged this makes removal of unnecessary lines even easier\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (contents \/* $? *\/) (type UNKNOWN))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (contents #define ?name ?) (type UNKNOWN))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-blank-lines\n ?f <- (file-line (contents))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (contents \/* $? *\/) (type UNKNOWN))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"8d0814d74fdfa70b7ebaeab65ce3f0fc16cacf3e","subject":"calculando tiempos","message":"calculando tiempos\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness (clamp -2000 ?fitness 5000))\n\t(bind ?calorias-deseadas (\/ (+ ?fitness 2000) 7)) ;entre 0 y 1000\n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo)))\n\t)\n)\n\t","old_contents":"; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 11:32:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -15)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -5)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -20)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 0 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 0 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t(printout t \"fitness \" ?fitness crlf) \n\t(assert (fitness ?fitness))\n)\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then (assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona)))))\n\t)\n\t\n\t(assert (solucion (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (solucion $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"7b3a57ee24122e73e8d89d0f56861f46df0af486","subject":"\/lib\/chicanery\/color.clp is now used by painter","message":"\/lib\/chicanery\/color.clp is now used by painter\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery\/pointer.clp)\n(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n(load* \/lib\/chicanery\/rectangle.clp)\n(load* \/lib\/chicanery\/color.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery\/pointer.clp)\n(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n(load* \/lib\/chicanery\/rectangle.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n \n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?name $?entries)\n =>\n (retract ?f)\n (defmenu ?name ?entries))\n\n(defrule on-resized\n (declare (salience 1000))\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard \n button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (input keyboard\n button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b&~NIL)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"58c85f25d23c75b409f3f7dd8f41b3066104ea6e","subject":"Just have successful printout messages for save and load right now","message":"Just have successful printout messages for save and load right now\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"prompt.clp","new_file":"prompt.clp","new_contents":";The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The user input prompt, located in the prompt module\n;------------------------------------------------------------------------------\n(defmodule prompt\n (import constants \n defglobal \n ?ALL)\n (export defclass \n input-state))\n\n(defclass prompt::input-state\n (is-a USER)\n (slot should-prompt\n (type SYMBOL)\n (allowed-symbols TRUE\n FALSE))\n (slot processed-input\n (type SYMBOL)\n (allowed-symbols FALSE\n TRUE))\n (slot prompt\n (type STRING)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot raw-input\n (type STRING)\n (default-dynamic \"\"))\n (multislot input\n (visibility public)))\n\n(definstances prompt::initialization-of-input-state\n (of input-state\n (prompt \"> \")))\n\n(defrule prompt::read-input\n \"Read input from the end user\"\n (declare (salience ?*absolute-first-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt TRUE)\n (prompt ?prompt))\n =>\n (printout ?*router-out* ?prompt tab)\n (modify-instance ?f \n (should-prompt FALSE)\n (processed-input FALSE)\n (raw-input (string-trim (bind ?rinput\n (readline))))\n (input (explode$ ?rinput))))\n\n(defrule prompt::core-keyword:quit\n (declare (salience ?*absolute-first-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (input quit))\n =>\n (unmake-instance ?f))\n\n(defrule prompt::core-keyword:save\n (declare (salience ?*absolute-first-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (input save ?path))\n =>\n (modify-instance ?f \n (processed-input TRUE))\n ;TODO: insert save code here\n (printout ?*router-out* \n tab \"Successfully saved state to \" ?path crlf))\n\n(defrule prompt::core-keyword:load\n (declare (salience ?*absolute-first-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (input load ?path))\n =>\n (modify-instance ?f (processed-input TRUE))\n ;TODO: insert load code here\n (printout ?*router-out* \n tab \"Successfully loaded state from \" ?path crlf))\n\n(defrule prompt::unknown-keyword\n \"This is a fallthrough state when it wasn't possible to process the input with another rule\"\n (declare (salience ?*after-normal-priority*))\n (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (raw-input ?input))\n =>\n (printout ?*router-out* \n tab ?*unknown-input-message* \" \\\"\" ?input \"\\\"\" crlf))\n\n\n(defrule prompt::reset-input\n (declare (salience ?*absolute-last-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE))\n =>\n (modify-instance ?f \n (should-prompt TRUE)))\n\n\n","old_contents":";The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The user input prompt, located in the prompt module\n;------------------------------------------------------------------------------\n(defmodule prompt\n (import constants \n defglobal \n ?ALL)\n (export defclass \n input-state))\n\n(defclass prompt::input-state\n (is-a USER)\n (slot should-prompt\n (type SYMBOL)\n (allowed-symbols TRUE\n FALSE))\n (slot processed-input\n (type SYMBOL)\n (allowed-symbols FALSE\n TRUE))\n (slot prompt\n (type STRING)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot raw-input\n (type STRING)\n (default-dynamic \"\"))\n (multislot input\n (visibility public)))\n\n(definstances prompt::initialization-of-input-state\n (of input-state\n (prompt \"> \")))\n\n(defrule prompt::read-input\n \"Read input from the end user\"\n (declare (salience ?*absolute-first-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt TRUE)\n (prompt ?prompt))\n =>\n (printout ?*router-out* ?prompt tab)\n (modify-instance ?f \n (should-prompt FALSE)\n (processed-input FALSE)\n (raw-input (bind ?rinput (readline)))\n (input (explode$ ?rinput))))\n\n(defrule prompt::core-keyword:quit\n (declare (salience ?*before-normal-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE)\n (input quit))\n =>\n (unmake-instance ?f))\n\n(defrule prompt::unknown-keyword\n \"This is a fallthrough state when it wasn't possible to process the input with another rule\"\n (declare (salience ?*after-normal-priority*))\n (object (is-a input-state)\n (should-prompt FALSE)\n (processed-input FALSE)\n (raw-input ?input))\n =>\n (printout ?*router-out* \n tab ?*unknown-input-message* \" \\\"\" ?input \"\\\"\" crlf))\n\n\n(defrule prompt::reset-input\n (declare (salience ?*absolute-last-priority*))\n ?f <- (object (is-a input-state)\n (should-prompt FALSE))\n =>\n (modify-instance ?f \n (should-prompt TRUE)))\n\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"998d44954ef155c029a4047c1853875a05b36478","subject":"Fixed incorrect slot names in WavefrontPreInitialization.clp","message":"Fixed incorrect slot names in WavefrontPreInitialization.clp\n\nI also reformatted the Left Hand Sides of the rules to be more in line with my\nnew rule scheme of having each slot on its own line\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/pre-init\/WavefrontPreInitialization.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/pre-init\/WavefrontPreInitialization.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::generate-wavefront-object\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (not (exists (object (is-a Wavefront) \n (parent ?p))))\n =>\n (retract ?msg)\n (make-instance of Wavefront \n (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::retract-wavefront-creation-action\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (exists (object (is-a Wavefront) \n (parent ?p)))\n =>\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-block-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r))\n =>\n (assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-region-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ~?r))\n (object (is-a Region) \n (parent ?r) \n (Entrances $? ?e $?) \n (id ?q))\n =>\n (assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n ?f1 <- (Add ?v1&~?v0 to wavefront for ?r)\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-multi-multi=>multi\n (declare (salience 1))\n ?f0 <- (In wavefront ?r add $?a)\n ?f1 <- (In wavefront ?r add $?b)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n =>\n (retract ?f0)\n (assert (In wavefront ?r add ?v0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::construct-wavefront-for-region\n (declare (salience -1))\n ?f <- (In wavefront ?r add $?w)\n ?wave <- (object (is-a Wavefront) \n (parent ?r))\n =>\n (retract ?f)\n (modify-instance ?wave (contents $?w)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::generate-wavefront-object\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (argument ?p))\n (not (exists (object (is-a Wavefront) (parent ?p))))\n =>\n (retract ?msg)\n (make-instance of Wavefront (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::retract-wavefront-creation-action\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (argument ?p))\n (exists (object (is-a Wavefront) (parent ?p)))\n =>\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-block-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) (parent ?r))\n (object (is-a Region) (id ?r) (Entrances $? ?e $?))\n (object (is-a BasicBlock) (id ?e) (parent ?r))\n =>\n (assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-region-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) (parent ?r))\n (object (is-a Region) (id ?r) (Entrances $? ?e $?))\n (object (is-a BasicBlock) (id ?e) (parent ~?r))\n (object (is-a Region) (parent ?r) (Entrances $? ?e $?) (id ?q))\n =>\n (assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single-single=>multi\n (declare (salience 1))\n ;(Stage WavefrontInit $?)\n ?f0 <- (Add ?v0 to wavefront for ?r)\n ?f1 <- (Add ?v1&~?v0 to wavefront for ?r)\n ;(test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-multi-multi=>multi\n (declare (salience 1))\n ?f0 <- (In wavefront ?r add $?a)\n ?f1 <- (In wavefront ?r add $?b)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n =>\n (retract ?f0)\n (assert (In wavefront ?r add ?v0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::construct-wavefront-for-region\n (declare (salience -1))\n ?f <- (In wavefront ?r add $?w)\n ?wave <- (object (is-a Wavefront) (parent ?r))\n =>\n (retract ?f)\n (modify-instance ?wave (contents $?w)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"675573fb3919b71039199c9e3001e9892f3b8acd","subject":"Finished the basic assembler","message":"Finished the basic assembler\n","repos":"DrItanium\/phoenix,DrItanium\/phoenix","old_file":"clp\/assembler.clp","new_file":"clp\/assembler.clp","new_contents":"(load* (proton: \/lib\/core.clp))\n(defglobal MAIN\n ?*instruction-list* = (create$ nop add sub mul div mod rightshift \n leftshift binaryand binaryor \n binarynot eq neq gt lt load store \n branch set call ret)\n\n ?*registers* = (create$ r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13\n r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 \n r25 r26 r27 r28 r29 r30 r31 r32 r33 r34 r35 \n r36 r37 r38 r39 r40 r41 r42 r43 r44 r45 r46 \n r47 r48 r49 r50 r51 r52 r53 r54 r55 r56 r57 \n r58 r59 r60 r61 r62 r63 r64 r65 r66 r67 r68 \n r69 r70 r71 r72 r73 r74 r75 r76 r77 r78 r79 \n r80 r81 r82 r83 r84 r85 r86 r87 r88 r89 r90 \n r91 r92 r93 r94 r95 r96 r97 r98 r99 r100 \n r101 r102 r103 pi3 pi2 pi1 pi0 pfalse ptrue \n ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 po0 po1 pfci \n ra pc cc rc pid true false))\n(defgeneric translate\/instruction)\n(defgeneric translate\/register)\n\n(defmethod translate\/instruction\n ((?index INTEGER (= ?index 254)))\n platform)\n(defmethod translate\/instruction\n ((?index INTEGER (= ?index 255)))\n terminate)\n\n\n(defmethod translate\/instruction\n ((?index INTEGER))\n (nth$ ?index ?*instruction-list*))\n\n(defmethod translate\/instruction\n ((?symbol LEXEME (eq ?symbol platform)))\n 254)\n(defmethod translate\/instruction\n ((?symbol LEXEME (eq ?symbol terminate)))\n 255)\n\n(defmethod translate\/instruction\n ((?symbol LEXEME))\n (member$ ?symbol ?*instruction-list*))\n\n(defmethod translate\/register\n ((?index INTEGER))\n (nth$ ?index ?*registers*))\n\n(defmethod translate\/register\n ((?symbol LEXEME))\n (member$ ?symbol ?*registers*))\n\n; syntax of an instruction is \n; predicate op dest0 dest1 <- src0 src1\n; predicate op dest0 <- src0 src1\n; predicate op dest0 <- value\n; predicate op dest0\n; predicate op <- value\n; predicate op\n\n(defrule parse-input\n (initial-fact)\n =>\n (assert (parse input 1 (readline))))\n\n(defrule done-parsing\n ?f <- (parse input ? EOF)\n =>\n (retract ?f))\n\n(defrule continue-parsing\n ?f <- (parse input ?n ?line&~EOF)\n =>\n (retract ?f)\n (assert (instruction ?n (explode$ ?line))\n (parse input (+ ?n 1) (readline))))\n\n(defrule eliminate-parens\n (declare (salience 3))\n ?f <- (instruction ?n \"(\" ?predicate \")\" $?rest)\n =>\n (retract ?f)\n (assert (instruction ?n ?predicate $?rest)))\n(defrule parse-dual-result-instruction\n (declare (salience 2))\n ?f <- (instruction ? ?predicate ?op ?d0 ?d1 <- ?s0 ?s1)\n (test (not (neq ?op eq neq gt lt)))\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction ?op))\n (put-char t (translate\/register ?d0))\n (put-char t (translate\/register ?d1))\n (put-char t (translate\/register ?s0))\n (put-char t (translate\/register ?s1))\n (put-char t 0)\n (put-char t 0))\n\n(defrule parse-single-result-instruction:dual-input\n (declare (salience 2))\n ?f <- (instruction ? ?predicate ?op ?d0 <- ?s0 ?s1)\n (test (not (neq ?op add sub mul div mod rightshift \n leftshift binaryor binaryand)))\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction ?op))\n (put-char t (translate\/register ?d0))\n (put-char t 0)\n (put-char t (translate\/register ?s0))\n (put-char t (translate\/register ?s1))\n (put-char t 0)\n (put-char t 0))\n\n(defrule parse-single-result:single-input:binarynot\n (declare (salience 2))\n ?f <- (instruction ? ?predicate ?op ?dest <- ?value)\n (test (not (neq ?op load store binarynot)))\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction binarynot))\n (put-char t (translate\/register ?dest))\n (put-char t 0)\n (put-char t (translate\/register ?value))\n (put-char t 0)\n (put-char t 0)\n (put-char t 0))\n\n(defrule parse-single:set\n (declare (salience 2))\n ?f <- (instruction ? ?predicate set ?dest <- ?value)\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction set))\n (put-char t (translate\/register ?dest))\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (progn$ (?a (slice8 ?value)) \n (put-char t ?a)))\n\n(defrule parse-none\n (declare (salience 2))\n ?f <- (instruction ? ?predicate ?op)\n (test (not (neq ?op nop ret platform terminate)))\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction ?op))\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0))\n\n(defrule parse-call\n (declare (salience 2))\n ?f <- (instruction ? ?predicate call ?reg)\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction call))\n (put-char t 0)\n (put-char t 0)\n (put-char t (translate\/register ?reg))\n (put-char t 0)\n (put-char t 0)\n (put-char t 0))\n\n(defrule parse-branch\n (declare (salience 2))\n ?f <- (instruction ? ?predicate branch ?value)\n =>\n (retract ?f)\n (put-char t (translate\/register ?predicate))\n (put-char t (translate\/instruction branch))\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (put-char t 0)\n (progn$ (?a (slice8 ?value)) \n (put-char t ?a)))\n(defrule skip-empty-lines\n (declare (salience 3))\n ?f <- (instruction ?)\n =>\n (retract ?f))\n(defrule unknown-instruction \n (declare (salience 1))\n ?f <- (instruction ?line $?symbols) \n =>\n (retract ?f)\n (format werror \"ERROR: unknown instruction on line %d%n%t%s%n\" ?line \n (implode$ $?symbols))\n (exit 1))\n\n\n;TODO: continue\n(batch* (proton: \/lib\/reset-run-exit.clp))\n","old_contents":"(defglobal MAIN\n\t\t\t ?*instruction-list* = (create$ nop add sub mul div mod rightshift \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tleftshift binaryand binaryor \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbinarynot eq neq gt lt load store \n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbranch set call ret)\n\n\t\t\t ?*registers* = (create$ r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13\n\t\t\t\t\t\t\t\t\t\t\t r14 r15 r16 r17 r18 r19 r20 r21 r22 r23 r24 \n\t\t\t\t\t\t\t\t\t\t\t r25 r26 r27 r28 r29 r30 r31 r32 r33 r34 r35 \n\t\t\t\t\t\t\t\t\t\t\t r36 r37 r38 r39 r40 r41 r42 r43 r44 r45 r46 \n\t\t\t\t\t\t\t\t\t\t\t r47 r48 r49 r50 r51 r52 r53 r54 r55 r56 r57 \n\t\t\t\t\t\t\t\t\t\t\t r58 r59 r60 r61 r62 r63 r64 r65 r66 r67 r68 \n\t\t\t\t\t\t\t\t\t\t\t r69 r70 r71 r72 r73 r74 r75 r76 r77 r78 r79 \n\t\t\t\t\t\t\t\t\t\t\t r80 r81 r82 r83 r84 r85 r86 r87 r88 r89 r90 \n\t\t\t\t\t\t\t\t\t\t\t r91 r92 r93 r94 r95 r96 r97 r98 r99 r100 \n\t\t\t\t\t\t\t\t\t\t\t r101 r102 r103 pi3 pi2 pi1 pi0 pfalse ptrue \n\t\t\t\t\t\t\t\t\t\t\t ps7 ps6 ps5 ps4 ps3 ps2 ps1 ps0 po0 po1 pfci \n\t\t\t\t\t\t\t\t\t\t\t ra pc cc rc pid true false))\n(defgeneric translate\/instruction)\n(defgeneric translate\/register)\n\n(defmethod translate\/instruction\n ((?index INTEGER (= ?index 254)))\n platform)\n(defmethod translate\/instruction\n ((?index INTEGER (= ?index 255)))\n termnate)\n\n(defmethod translate\/instruction\n ((?index INTEGER))\n (nth$ ?index ?*instruction-list*))\n\n(defmethod translate\/instruction\n ((?symbol LEXEME (eq ?symbol platform)))\n 254)\n(defmethod translate\/instruction\n ((?symbol LEXEME (eq ?symbol terminate)))\n 255)\n(defmethod translate\/instruction\n ((?symbol LEXEME))\n (member$ ?symbol ?*instruction-list*))\n\n\n(defmethod translate\/register\n ((?index INTEGER))\n (nth$ ?index ?*registers*))\n\n(defmethod translate\/register\n ((?symbol LEXEME))\n (member$ ?symbol ?*registers*))\n\n; syntax of an instruction is \n; predicate op dest0 dest1 <- src0 src1\n; predicate op dest0 <- src0 src1\n; predicate op dest0 <- value\n; predicate op dest0\n; predicate op <- value\n; predicate op\n\n(defrule parse-dual-result-instruction\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (instruction ?predicate ?op ?d0 ?d1 <- ?s0 ?s1)\n\t\t\t(test (not (neq ?op eq neq gt lt)))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(put-char t (translate\/register ?predicate))\n\t\t\t(put-char t (translate\/instruction ?op))\n\t\t\t(put-char t (translate\/register ?d0))\n\t\t\t(put-char t (translate\/register ?d1))\n\t\t\t(put-char t (translate\/register ?s0))\n\t\t\t(put-char t (translate\/register ?s1))\n\t\t\t(put-char t 0)\n\t\t\t(put-char t 0))\n\n(defrule parse-single-result-instruction:dual-input\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (instruction ?predicate ?op ?d0 <- ?s0 ?s1)\n\t\t\t(test (not (neq ?op add sub mul div mod rightshift \n\t\t\t\t\t\t\t\t leftshift binaryor binaryand)))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(put-char t (translate\/register ?predicate))\n\t\t\t(put-char t (translate\/instruction ?op))\n\t\t\t(put-char t (translate\/register ?d0))\n\t\t\t(put-char t 0)\n\t\t\t(put-char t (translate\/register ?s0))\n\t\t\t(put-char t (translate\/register ?s1))\n\t\t\t(put-char t 0)\n\t\t\t(put-char t 0))\n\n(defrule parse-single-result:single-input:binarynot\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (instruction ?predicate binarynot ?dest <- ?value)\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(put-char t (translate\/register ?predicate))\n\t\t\t(put-char t (translate\/instruction binarynot))\n\t\t\t(put-char t (translate\/register ?op))\n\t\t\t(put-char t 0)\n\t\t\t(put-char t (translate\/register ?value))\n\t\t\t(put-char t 0)\n\t\t\t(put-char t 0)\n\t\t\t(put-char t 0))\n;TODO: continue\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"24275beb7ee2cb68f86a91b8aa20b6544c30c15d","subject":"Added improved menu handling","message":"Added improved menu handling\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"lib\/chicanery.clp","new_file":"lib\/chicanery.clp","new_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defclass image\n (is-a native-pointer)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (type INTEGER)\n (create-accessor read))\n (multislot buttons \n (type SYMBOL)\n (create-accessor read))\n (multislot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler query primary))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons\n (translate\/mouse\/buttons (mouse\/buttons)))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (bind ?self:keys (create$))\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:index 1)\n ?key)\n else\n (bind ?self:keys (create$ ?key)))\n (bind ?self:length (+ ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n","old_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defclass image\n (is-a native-pointer)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (type INTEGER)\n (create-accessor read))\n (multislot buttons \n (type SYMBOL)\n (create-accessor read))\n (multislot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler query primary))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons\n (translate\/mouse\/buttons (mouse\/buttons)))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (bind ?self:keys (create$))\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:index 1)\n ?key)\n else\n (bind ?self:keys (create$ ?key)))\n (bind ?self:length (+ ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"73c9281abcbc2405529377f7ac075d0abbb01bc4","subject":"waltz part running abouyt 10 minutes","message":"waltz part running abouyt 10 minutes\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"clipsfiles\/waltz\/waltz_10minutes.clp","new_file":"clipsfiles\/waltz\/waltz_10minutes.clp","new_contents":";;; The Waltz Algorithm implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; The copyright notice from the original code:\n\n;;; Copyright C 1991 Satoshi Nishiyama and the University of Texas at Austin\n;;; anyone may copy and use this program the terms listed in the copyright\n;;; notice in and covering the Communications of the ACM, the program is\n;;; is not warranted to do anything\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Converted C code to deffunctions\n;;; Uses salience to obtain a number of rule firings consistent\n;;; with other rule engines running this benchmark\n\n;;; ##########################################################################\n;;; Deftemplates\n;;;\n;;; Lines have the lable line followed by the 2 points defining the line.\n;;;\n;;; Edges are like lines accept that they can be labeled, permanently labeled,\n;;; and plotted.\n;;;\n;;; Junctions are defined by 4 points. The basepoint is where the 3 (2) lines\n;;; intersect. The points p1, p2, p3 are the other endpoints of the lines at\n;;; this junction\n;;; ##########################################################################\n\n(deftemplate stage\n (slot value))\n\n(deftemplate line\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER)))\n\n(deftemplate edge\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot joined (type BOOLEAN))\n (slot label)\n (slot plotted))\n\n(deftemplate junction\n (slot p1 (type INTEGER))\n (slot p2 (type INTEGER))\n (slot p3 (type INTEGER))\n (slot base_point (type INTEGER))\n (slot jtype))\n\n; ;;; #################################################################\n; ;;; Deffunctions\n; ;;;\n; ;;; In the OPS5 version of this program, the following deffunctions\n; ;;; were implemented in C code that needed to be linked with the OPS5\n; ;;; interpreter. Using deffunctions allows the benchmark to be run\n; ;;; without having to recompile and relink CLIPS with the C code used\n; ;;; in the original benchmark. The performance impact of using\n; ;;; deffunctions for this benchmark rather than C code is minimal.\n; ;;; #################################################################\n\n; (defglobal ?*MOD-NUM* = 100)\n\n; ;;; *****\n; ;;; atan2\n; ;;; *****\n\n; (deffunction atan2 (?y ?x)\n; (if (> ?x 0)\n; then\n; (return (atan (\/ ?y ?x))))\n\n; (if (< ?x 0)\n; then\n; (return (- (atan (\/ ?y ?x)) (pi))))\n\n; (if (> ?y 0) then\n; then\n; (return (pi)))\n\n; (if (< ?y 0)\n; then\n; (return (- 0 (pi))))\n\n; (return undefined))\n\n; ;;; *****\n; ;;; get-y\n; ;;; *****\n\n; (deffunction get-y (?val)\n; (mod ?val ?*MOD-NUM*))\n\n; ;;; *****\n; ;;; get-x\n; ;;; *****\n\n; (deffunction get-x (?val)\n; (integer (\/ ?val ?*MOD-NUM*)))\n\n; ;;; *********\n; ;;; get-angle\n; ;;; *********\n\n; (deffunction get-angle (?p1 ?p2)\n; (bind ?delta-x (- (get-x ?p2) (get-x ?p1)))\n; (bind ?delta-y (- (get-y ?p2) (get-y ?p1)))\n; (if (= ?delta-x 0)\n; then\n; (if (> ?delta-y 0)\n; \t\t then (return (\/ (pi) 2))\n; \t\t else (if (< ?delta-y 0) then (return (\/ (pi) -2))))\n; else\n; (if (= ?delta-y 0)\n; then\n; (if (> ?delta-x 0)\n; then (return 0.0)\n; \t\t else (if (< ?delta-x 0) then return (pi)))\n; else\n; (return (atan2 ?delta-y ?delta-x)))))\n\n; ;;; ***************\n; ;;; inscribed-angle\n; ;;; ***************\n\n; (deffunction inscribed-angle (?basepoint ?p1 ?p2)\n\n; \t;; Get the angle between line #1 and the origin and the angle\n; \t;; between line #2 and the origin, and then subtract these values.\n\n; (bind ?angle1 (get-angle ?basepoint ?p1))\n; (bind ?angle2 (get-angle ?basepoint ?p2))\n; (bind ?temp (- ?angle1 ?angle2))\n\n; (if (< ?temp 0)\n; then (bind ?temp (- 0 ?temp)))\n\n; ;; We always want the smaller of the two angles inscribed, so\n; ;; if the answer is greater than 180 degrees, calculate the\n; ;; smaller angle and return it.\n\n; (if (> ?temp (pi))\n; then\n; (bind ?temp (- (* 2 (pi)) ?temp)))\n\n; (if (< ?temp 0)\n; then (return (- 0 ?temp)))\n\n; (return ?temp))\n\n; ;;; ***************\n; ;;; make-3-junction\n; ;;; ***************\n\n; (deffunction make-3-junction (?basepoint ?p1 ?p2 ?p3)\n; (bind ?angle12 (inscribed-angle ?basepoint ?p1 ?p2))\n; (bind ?angle13 (inscribed-angle ?basepoint ?p1 ?p3))\n; (bind ?angle23 (inscribed-angle ?basepoint ?p2 ?p3))\n\n; (bind ?sum1213 (+ ?angle12 ?angle13))\n; (bind ?sum1223 (+ ?angle12 ?angle23))\n; (bind ?sum1323 (+ ?angle13 ?angle23))\n\n; (if (< ?sum1213 ?sum1223)\n; then\n; (if (< ?sum1213 ?sum1323)\n; then\n; (bind ?sum ?sum1213)\n; (bind ?shaft ?p1)\n; (bind ?barb1 ?p2)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2))\n; else\n; (if (< ?sum1223 ?sum1323)\n; then\n; (bind ?sum ?sum1223)\n; (bind ?shaft ?p2)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p3)\n; else\n; (bind ?sum ?sum1323)\n; (bind ?shaft ?p3)\n; (bind ?barb1 ?p1)\n; (bind ?barb2 ?p2)))\n\n; (bind ?delta (- ?sum (pi)))\n; (if (< ?delta 0)\n; then (bind ?delta (- 0 ?delta)))\n\n; (if (< ?delta 0.001)\n; then (bind ?jtype tee)\n; else\n; (if (> ?sum (pi))\n; then (bind ?jtype fork)\n; else (bind ?jtype arrow)))\n\n; (assert (junction (p1 (integer ?barb1))\n; (p2 (integer ?shaft))\n; (p3 (integer ?barb2))\n; (base_point (integer ?basepoint))\n; (jtype ?jtype))))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *******************************************************\n;;; begin: Our starting production. It checks to see if the\n;;; start flag is in WM, and if it is, it deletes it\n;;; *******************************************************\n\n(defrule begin\n\t?f1 <- (stage (value start))\n\t=>\n\t(assert (line (p1 0122) (p2 0107)))\n\t(assert (line (p1 0107) (p2 2207)))\n\t(assert (line (p1 2207) (p2 3204)))\n\t(assert (line (p1 3204) (p2 6404)))\n\t(assert (line (p1 2216) (p2 2207)))\n\t(assert (line (p1 3213) (p2 3204)))\n\t(assert (line (p1 2216) (p2 3213)))\n\t(assert (line (p1 0107) (p2 2601)))\n\t(assert (line (p1 2601) (p2 7401)))\n\t(assert (line (p1 6404) (p2 7401)))\n\t(assert (line (p1 3213) (p2 6413)))\n\t(assert (line (p1 6413) (p2 6404)))\n\t(assert (line (p1 7416) (p2 7401)))\n\t(assert (line (p1 5216) (p2 6413)))\n\t(assert (line (p1 2216) (p2 5216)))\n\t(assert (line (p1 0122) (p2 5222)))\n\t(assert (line (p1 5222) (p2 7416)))\n\t(assert (line (p1 5222) (p2 5216)))\n\t(modify ?f1 (value duplicateStage)))\n\n;;; **********************************************************************\n;;; reverse_edges: If the duplicate flag is set, and there is still a line\n;;; in WM, delete the line and add two edges. One edge runs from p1 to\n;;; p2 and the other runs from p2 to p1. We then plot the edge.\n;;; **********************************************************************\n\n(defrule reverse_edges\n\t(stage (value duplicateStage))\n\t?f2 <- (line (p1 ?p1) (p2 ?p2))\n\t=>\n\t(assert (edge (p1 ?p1) (p2 ?p2) (joined false)))\n (assert (edge (p1 ?p2) (p2 ?p1) (joined false)))\n\t(retract ?f2))\n\n;;; **************************************************************************\n;;; done_reversing: If the duplicating flag is set, and there are no more\n;;; lines, then remove the duplicating flag and set the make junctions flag.\n;;; **************************************************************************\n\n(defrule done_reversing\n\t(declare (salience -10))\n\t?f1 <- (stage (value duplicateStage))\n\t(not (line))\n\t=>\n\t(modify ?f1 (value detect_junctions)))\n\n;;; *****************************************************************************\n;;; make-3_junction: If three edges meet at a point and none of them have already\n;;; been joined in a junction, then make the corresponding jtype of junction and\n;;; label the edges joined. This production calls make-3_junction to determine\n;;; what jtype of junction it is based on the angles inscribed by the\n;;; intersecting edges.\n;;; *****************************************************************************\n\n(defrule make-3_junction\n\t(declare (salience 10))\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p1) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p2&~?p1) (joined false))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p3&~?p1&~?p2) (joined false))\n\t=>\n\t(make-3-junction ?base_point ?p1 ?p2 ?p3)\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true))\n\t(modify ?f4 (joined true)))\n\n;;; ******************************************************\n;;; make_L: If two, and only two, edges meet that have not\n;;; already been joined, then the junction is an \"L\".\n;;; ******************************************************\n\n(defrule make_L\n\t(stage (value detect_junctions))\n\t?f2 <- (edge (p1 ?base_point) (p2 ?p2) (joined false))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p3&~?p2) (joined false))\n\t(not (edge (p1 ?base_point) (p2 ~?p2&~?p3)))\n\t=>\n\t(assert (junction (jtype L)\n \t\t (base_point ?base_point)\n\t\t (p1 ?p2)\n\t\t (p2 ?p3)))\n\t(modify ?f2 (joined true))\n\t(modify ?f3 (joined true)))\n\n;;; ******************************************************************\n;;; done_detecting: If the detect junctions flag is set, and there are\n;;; no more un_joined edges, set the find_initial_boundary flag.\n;;; ******************************************************************\n\n(defrule done_detecting\n\t(declare (salience -10))\n\t?f1 <- (stage (value detect_junctions))\n\t(not (edge (joined false)))\n\t=>\n\t(modify ?f1 (value find_initial_boundary)))\n\n;;; ****************************************************\n;;; initial_boundary_junction_L: If the initial boundary\n;;; junction is an L, then we know it's labelling\n;;; ****************************************************\n\n(defrule initial_boundary_junction_L\n\t?f1 <- (stage (value find_initial_boundary))\n (junction (jtype L)\n (base_point ?base_point)\n (p1 ?p1)\n (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(> ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***************************************************\n;;; initial_boundary_junction_arrow: Ditto for an arrow\n;;; ***************************************************\n\n(defrule initial_boundary_junction_arrow\n\t?f1 <- (stage (value find_initial_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(> ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value find_second_boundary)))\n\n;;; ***********************************************************************\n;;; second_boundary_junction_L: If we have already found the first boundary\n;;; point, then find the second boundary point, and label it.\n;;; ***********************************************************************\n\n(defrule second_boundary_junction_L\n\t?f1 <- (stage (value find_second_boundary))\n (junction (jtype L) (base_point ?base_point) (p1 ?p1) (p2 ?p2))\n\t?f3 <- (edge (p1 ?base_point) (p2 ?p1))\n\t?f4 <- (edge (p1 ?base_point) (p2 ?p2))\n (not (junction (base_point ?bp&:(< ?bp ?base_point))))\n\t=>\n (modify ?f3 (label B))\n (modify ?f4 (label B))\n (modify ?f1 (value labeling)))\n\n;;; ******************************\n;;; second_boundary_junction_arrow\n;;; ******************************\n\n(defrule second_boundary_junction_arrow\n\t?f1 <- (stage (value find_second_boundary))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t(not (junction (base_point ?base_point&:(< ?base_point ?bp))))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label B))\n\t(modify ?f1 (value labeling)))\n\n;;; **********************************************************************\n;;; match_edge: If we have an edge whose label we already know definitely,\n;;; then label the corresponding edge in the other direction\n;;; **********************************************************************\n\n(defrule match_edge\n\t(stage (value labeling))\n\t?f2 <- (edge (p1 ?p1) (p2 ?p2) (label ?label& + | - | B))\n\t?f3 <- (edge (p1 ?p2) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f2 (plotted t))\n\t(modify ?f3 (label ?label) (plotted t)))\n\n;;; The following productions propogate the possible labellings of the edges\n;;; based on the labellings of edges incident on adjacent junctions. Since\n;;; from the initial boundary productions, we have determined the labellings of\n;;; of atleast two junctions, this propogation will label all of the junctions\n;;; with the possible labellings. The search space is pruned due to filtering,\n;;; i.e. - only label a junction in the ways physically possible based on the\n;;; labellings of adjacent junctions.\n\n;;; *******\n;;; label_L\n;;; *******\n(defrule label_L\n\t(stage (value labeling))\n\t(junction (jtype L) (base_point ?p1))\n\t(edge (p1 ?p1) (p2 ?p2) (label + | -))\n\t?f4 <- (edge (p1 ?p1) (p2 ~?p2) (label nil))\n\t=>\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_A\n;;; ***********\n\n(defrule label_tee_A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ***********\n;;; label_tee_B\n;;; ***********\n\n(defrule label_tee_B\n\t(stage (value labeling))\n\t(junction (jtype tee) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t?f3 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n (modify ?f3 (label B))\n\t(modify ?f4 (label B)))\n\n;;; ************\n;;; label_fork-1\n;;; ************\n(defrules\n(label_fork-1\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2&~?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; ************\n;;; label_fork-2\n;;; ************\n\n(label_fork-2\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label B)))\n\n;;; ************\n;;; label_fork-3\n;;; ************\n\n(label_fork-3\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label B))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label B))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; ************\n;;; label_fork-4\n;;; ************\n\n(label_fork-4\n\t(stage (value labeling))\n\t(junction (jtype fork) (base_point ?bp))\n\t(edge (p1 ?bp) (p2 ?p1) (label -))\n\t(edge (p1 ?bp) (p2 ?p2&~?p1) (label -))\n\t?f5 <- (edge (p1 ?bp) (p2 ~?p2&~?p1) (label nil))\n\t=>\n\t(modify ?f5 (label -)))\n\n;;; **************\n;;; label_arrow-1A\n;;; **************\n)\n\n(defrules\n(label_arrow-1A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-1B\n;;; **************\n\n(label_arrow-1B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2A\n;;; **************\n\n(label_arrow-2A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n\n;;; **************\n;;; label_arrow-2B\n;;; **************\n\n(label_arrow-2B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label ?label& B | - ))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label ?label)))\n)\n\n;;; **************\n;;; label_arrow-3A\n;;; **************\n\n(defrule label_arrow-3A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-3B\n;;; **************\n\n(defrule label_arrow-3B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p1) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4A\n;;; **************\n\n(defrule label_arrow-4A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-4B\n;;; **************\n\n(defrule label_arrow-4B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p3) (label +))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p2))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t=>\n\t(modify ?f4 (label -))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5A\n;;; **************\n\n(defrule label_arrow-5A\n\t(declare (salience 5))\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3) (label nil))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; **************\n;;; label_arrow-5B\n;;; **************\n\n(defrule label_arrow-5B\n\t(stage (value labeling))\n\t(junction (jtype arrow) (base_point ?bp) (p1 ?p1) (p2 ?p2) (p3 ?p3))\n\t(edge (p1 ?bp) (p2 ?p2) (label -))\n\t?f4 <- (edge (p1 ?bp) (p2 ?p1) (label nil))\n\t?f5 <- (edge (p1 ?bp) (p2 ?p3))\n\t=>\n\t(modify ?f4 (label +))\n\t(modify ?f5 (label +)))\n\n;;; *******************************************************************************\n;;; done_labeling: The conflict resolution mechanism will only execute a production\n;;; if no productions that are more complicated are satisfied. This production\n;;; is simple, so all of the above dictionary productions will fire before this\n;;; change of state production\n;;; *******************************************************************************\n\n(defrule done_labeling\n\t(declare (salience -10))\n\t?f1 <- (stage (value labeling))\n\t=>\n\t(modify ?f1 (value plot_remaining_edges)))\n\n;;; **************************************************\n;;; plot_remaining: At this point, some labellings may\n;;; have not been plotted, so plot them\n;;; **************************************************\n\n(defrule plot_remaining\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label ?label&~nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ********************************************************************************\n;;; plot_boundaries: If we have been un able to label an edge, assume that it is a\n;;; boundary. This is a total Kludge, but what the hell. (if we assume only\n;;; valid drawings will be given for labeling, this assumption generally is true!)\n;;; ********************************************************************************\n\n(defrule plot_boundaries\n\t(stage (value plot_remaining_edges))\n\t?f2 <- (edge (plotted nil) (label nil) (p1 ?p1) (p2 ?p2))\n\t=>\n\t(modify ?f2 (plotted t)))\n\n;;; ****************************************************************************\n;;; done_plotting: If there is no more work to do, then we are done and flag it.\n;;; ****************************************************************************\n\n(defrule done_plotting\n\t(declare (salience -10))\n\t?f1 <- (stage (value plot_remaining_edges))\n\t(not (edge (plotted nil)))\n\t=>\n\t(modify ?f1 (value done)))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'clipsfiles\/waltz\/waltz_10minutes.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"1f29fb673f4a888c11ff93307308e74e59cb0100","subject":"Rewrote more parts of wavefront-scheduling to use message templates","message":"Rewrote more parts of wavefront-scheduling to use message templates\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (bind ?name (instance-name-to-symbol \n (instance-name\n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv ?name))) \n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (instance-address * (symbol-to-instance-name\n ?cpv)))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n ?inst <- (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n ;(retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-address * (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-values))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (modify ?fct (action pull-slices-for)\n (arguments range ?e => ?b\n instruction ?i\n cpv ?cpv\n paths $?validPaths))\n ;(assert (Pull slices for range ?e to ?b for instruction ?i { \n ; associated cpv ?cpv } using paths $?validPaths))\n else\n (retract ?fct)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (message (to wavefront-scheduling)\n (action pull-slices-for)\n (arguments range ?e => ?b\n instruction ?i\n cpv ?cpv\n paths ?path $?paths))\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (duplicate ?fct (action analyze-slice)\n (arguments ?s ?e ?cpv))\n (modify ?fct (arguments range ?e => ?b\n instruction ?i\n cpv ?cpv\n paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (message (to wavefront-scheduling)\n (action pull-slices-for)\n (arguments range ? => ?\n instruction ?\n cpv ?\n paths))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (message (to wavefront-scheduling)\n (action pull-slices-for)\n (arguments range ?e => ?b\n instruction ?i\n cpv ?cpv\n paths ?path $?paths))\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s0 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-scheduling)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (bind ?name (instance-name-to-symbol \n (instance-name\n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv ?name))) \n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (instance-address * (symbol-to-instance-name\n ?cpv)))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-address * (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-values))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-scheduling)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0a11455afb31aebc7ab6fb4c817bd677707dcef8","subject":"GLAPIConversion.clp: Added comments and expanded several rules","message":"GLAPIConversion.clp: Added comments and expanded several rules\n\nThis conversion is a very complicated process that must be defined ahead of\ntime to prevent large numbers of bugs from appearing. This is a very complex\nexpert system that (while possible) will not be simple due my desire to create\nan elegant design.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"8b0faa0daff124aed34cd7385ba918bb98b18b8a","subject":"Fixed the naming issue in WavefrontScheduling.clp","message":"Fixed the naming issue in WavefrontScheduling.clp\n\nIt turns out that having the module name tacked onto the front of the instance\nname was the problem all along. I have fixed it by wrapping the call to\nconstructing the compensation path vector in a\n(instance-name-to-symbol (instance-name ... ) )\n call to get out the name of the instance without the module name attached to\n it\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontScheduling.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (bind ?name (instance-name-to-symbol \n (instance-name\n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv ?name))) \n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (instance-address * (symbol-to-instance-name\n ?cpv)))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-address * (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-values))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The idea for wavefront scheduling is that we pull a region, construct\n; schedules for all of the blocks within the region, identify blocks that can\n; relinquish control over instructions and move them up and out of the given\n; block and into blocks on the wavefront.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergePotentiallyValidBlocks\n (declare (salience 2))\n ?pv0 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => ?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeMemoryPotentiallyValidBlocks\n ?pv0 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?t))\n ?pv1 <- (message (to wavefront-scheduling)\n (action memory-potentially-valid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?pv0 ?pv1) (subsetp ?t ?q)))\n =>\n (retract ?pv1)\n ;make sure that we get matches again!\n (modify ?pv0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::MergeCompletelyInvalid\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f1 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?q))\n (test (and (neq ?f0 ?f1) (subsetp ?t ?q)))\n =>\n (retract ?f1)\n (modify ?f0 (arguments ?e => $?q)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractPotentiallyValidBlocksThatAreCompletelyEnclosed\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?t))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?q&:(subsetp ?q ?t)))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::StripoutIndividualElementsFromPotentiallyValid\n (declare (salience -1))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?before ?car $?rest))\n (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $? ?car $?))\n =>\n (modify ?f (arguments ?e => $?before $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-strip::RetractEmptyPotentiallyValid\n (declare (salience -100))\n ?f <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ? => ))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectPotentiallyValidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (PotentiallyValid $?pv))\n =>\n (retract ?fct)\n (bind ?pvLen (length$ ?pv))\n (if (= 0 ?pvLen) then\n (modify-instance ?pa (PotentiallyValid $?blocks))\n else \n (bind ?pvs $?pv)\n (bind ?newIndex (+ ?pvLen 1))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?pvs)) then \n (bind ?pvs (insert$ ?pvs ?newIndex ?block))\n (bind ?newIndex (+ ?newIndex 1))))\n (modify-instance ?pa (PotentiallyValid ?pvs))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCompletelyInvalidBlocks-Complete\n ?fct <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?blocks))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CompletelyInvalid $?ci))\n =>\n (retract ?fct)\n (bind ?ciLen (length$ ?ci))\n (if (= 0 ?ciLen) then\n (modify-instance ?pa (CompletelyInvalid $?blocks))\n else\n (bind ?cis $?ci)\n (bind ?newIndex (+ 1 (length$ ?ci)))\n (progn$ (?block ?blocks)\n (if (not (member$ ?block ?cis)) then \n (bind ?cis (insert$ ?cis ?newIndex ?block))\n (bind ?newIndex (+ 1 ?newIndex))))\n (modify-instance ?pa (CompletelyInvalid ?cis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InterleavedInjectCompletelyInvalid-AndPotentiallyInvalidBlocks\n (declare (salience 1))\n ?f0 <- (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?b0))\n ?f1 <- (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => $?b1))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (CompletelyInvalid $?ci)\n (PotentiallyValid $?pv))\n =>\n (retract ?f0 ?f1)\n (bind ?ciLen (length$ $?ci))\n (bind ?pvLen (length$ $?pv))\n (bind ?cis $?ci)\n (bind ?pvs $?pv)\n (if (= 0 ?ciLen) then \n (bind ?cis $?b0)\n else\n (bind ?i0 (+ 1 ?ciLen))\n (progn$ (?b ?b0)\n (if (not (member$ ?b ?cis)) then\n (bind ?cis (insert$ ?cis ?i0 ?b))\n (bind ?i0 (+ ?i0 1)))))\n (if (= 0 ?pvLen) then\n (bind ?pvs $?b1)\n else\n (bind ?i1 (+ 1 ?pvLen))\n (progn$ (?b ?b1)\n (if (not (member$ ?b ?pvs)) then\n (bind ?pvs (insert$ ?pvs ?i1 ?b))\n (bind ?i1 (+ ?i1 1)))))\n (modify-instance ?pa (CompletelyInvalid ?cis) \n (PotentiallyValid ?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectMemoryBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (MemoryBarriers $?mb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?mb)) then\n (modify-instance ?pa (MemoryBarriers $?mb ?t))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-inject::InjectCallBarrierBlocks \n ?fct <- (message (to wavefront-scheduling)\n (action element-has-call-barrier)\n (arguments ?t => ?e))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (CallBarriers $?cb))\n =>\n (retract ?fct)\n (if (not (member$ ?t $?cb)) then\n (modify-instance ?pa (CallBarriers $?cb ?t))))\n;------------------------------------------------------------------------------\n; now that we have a path aggregate we need to get the list of instruction\n; CPV's that represent valid movable instructions for the given block on the\n; wavefront. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SelectValidCPVs \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e)\n (PotentiallyValid $?pv))\n =>\n (assert (For ?e find CPVs for $?pv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::FindValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a BasicBlock) \n (id ?pv) \n (contents $?instructions))\n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)\n (Get CPVs out of ?pv for ?e using $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::SkipRegionsForFindingValidCPVsForBlock\n ?fct <- (For ?e find CPVs for ?pv $?pvs)\n (object (is-a Region) \n (id ?pv)) \n =>\n (retract ?fct)\n (assert (For ?e find CPVs for $?pvs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractValidCPVsForBlock\n ?fct <- (For ? find CPVs for)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnorePHIInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a PhiNode) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreCallInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a CallInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::IgnoreTerminatorInstructions\n (declare (salience 1))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n (object (is-a TerminatorInstruction) \n (id ?inst))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnDestinationPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same\n (object (is-a Instruction)\n (id ?inst) \n (parent ?p) \n (DestinationRegisters $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg) \n (parent ?p))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::DisableInstructionsDependentOnLocalPhis\n (declare (salience 2))\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ;make sure that the parent block is the same \n (object (is-a Instruction) \n (id ?inst) \n (LocalDependencies $? ?reg $?))\n (object (is-a PhiNode) \n (id ?reg))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::TagValidCPVs\n ?fct <- (Get CPVs out of ?pv for ?e using ?inst $?insts)\n ?i <- (object (is-a Instruction) \n (id ?inst) \n (IsTerminator FALSE) \n (HasCallDependency FALSE))\n =>\n (retract ?fct)\n (assert (Get CPVs out of ?pv for ?e using $?insts)\n (Marked ?inst as valid for block ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::RetractDrainedGetCPVFacts\n ?fct <- (Get CPVs out of ?pv for ?e using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::ReloadCPVIntoNewAggregate\n \"Put the CPV that has already been created into the target path \n aggregate\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il)\n (ScheduledInstructions $?si)\n (CompensationPathVectors $?cpvs)\n (ImpossibleCompensationPathVectors \n $?icpv&:(not (member$ ?cpvID $?icpv))))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds)\n (DestinationRegisters ?reg))\n =>\n (retract ?fct)\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?reg ?inst)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg)))\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (CompensationPathVectors $?cpvs ?cpvID)\n (InstructionList ?ils)\n (ScheduledInstructions ?sis)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::CPVIsImpossible\n \"Target CPV is considered to be impossible to schedule. However, we should\n still schedule the non-local dependencies to make sure that all non-local\n dependencies are scheduled\"\n ?fct <- (Marked ?inst as valid for block ?e)\n (object (is-a CompensationPathVector) \n (parent ?inst) \n (id ?cpvID))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (ImpossibleCompensationPathVectors \n $?icpv&:(member$ ?cpvID $?icpv))\n (ScheduledInstructions $?si))\n (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nlds))\n =>\n (retract ?fct)\n ;add the non-local dependencies\n (bind ?sLen (length$ ?si))\n (if (= 0 ?sLen) then\n (modify-instance ?agObj (ScheduledInstructions ?nlds))\n else\n (bind ?sis $?si)\n (progn$ (?nld ?nlds)\n (if (not (member$ ?nld $?sis)) then\n (bind ?sis (create$ ?sis ?nld))))\n (modify-instance ?agObj (ScheduledInstructions ?sis))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-acquire::MakeCPV \n ?fct <- (Marked ?inst as valid for block ?e)\n (not (exists (object (is-a CompensationPathVector)\n (parent ?inst))))\n (object (is-a Instruction) \n (id ?inst) \n (parent ?pv) \n (DestinationRegisters ?reg) \n (NonLocalDependencies $?nlds))\n (object (is-a BasicBlock) \n (id ?pv) \n (Paths $?paths))\n ?pa <- (object (is-a PathAggregate) \n (id ?ag) \n (parent ?e)\n (CompensationPathVectors $?cpv)\n (InstructionList $?il)\n (ScheduledInstructions $?si))\n =>\n ; We need to disable the stores from moving when their dependencies\n ; \n ; YOU DON'T EVEN WANT TO KNOW WHAT I'M GOING TO DO TO YOU\n (retract ?fct)\n (bind ?ilLen (length$ ?il))\n (bind ?siLen (length$ ?si))\n (bind ?ils $?il)\n (bind ?sis $?si)\n (if (= 0 ?ilLen) then\n (if (neq ?inst ?reg) then\n (bind ?ils ?inst ?reg)\n else\n (bind ?ils ?inst)) \n else\n (if (not (member$ ?inst ?ils)) then\n (bind ?ils (create$ ?ils ?inst)))\n (if (and (neq ?inst ?reg)\n (not (member$ ?reg ?ils))) then\n (bind ?ils (create$ ?ils ?reg))))\n (if (= 0 ?siLen) then\n (bind ?sis $?nlds)\n else\n (progn$ (?nld ?nlds) \n (if (not (member$ ?nld ?sis)) then\n (bind ?sis (create$ ?sis ?nld)))))\n (modify-instance ?pa \n (ScheduledInstructions ?sis)\n (InstructionList ?ils)\n (CompensationPathVectors \n $?cpv (instance-name-to-symbol \n (make-instance of CompensationPathVector\n (parent ?inst)\n (Paths $?paths)\n (OriginalBlock ?pv))))))\n;------------------------------------------------------------------------------\n; Now we go through and attempt to schedule the instruction represented by \n; each CPV into the block on the wavefront. I call this stage merge. I had some\n; far raunchier names but this is my thesis. Some of the potential names were\n; OneeChanTheresNoWayThatCanFit, ImAMexiCan, Copulation, and many more.\n; \n; I guess the biggest question would be why? And my answer would be why not?\n; These terms just popped into my head.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SetifyInstructionList\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?a ?b $?c ?b $?d))\n =>\n ;we found a single duplicate, let's setify the whole InstructionList\n ;now to make sure.\n (bind ?ils (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?ils)) then\n (bind ?ils (create$ ?ils ?i))))\n (modify-instance ?pa (InstructionList ?ils)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateInitialSliceFactsForElementsOnTheWavefront \n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n (object (is-a PathAggregate) \n (parent ?e) \n (CompensationPathVectors $?cpv&:(> (length$ ?cpv) 0)))\n =>\n (assert (Generate slices for block ?e in ?r using $?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::GenerateFactForSlicesFromCPV\n ?fct <- (Generate slices for block ?e in ?r using ?cpv $?cpvs)\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i)\n (Paths $?paths))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r using $?cpvs)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RetractEmptySlicesCreationFact\n ?fct <- (Generate slices for block ? in ? using)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCanCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv \n with stop block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $? ?e $?))\n =>\n (retract ?fct)\n (assert (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::QueryCantCreateSliceForPath\n ?fct <- (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths ?path $?paths)\n (object (is-a Path) \n (id ?path) \n (values $?z&:(not (member$ ?e ?z))))\n =>\n (retract ?fct)\n (assert (Generate slices for block ?e in ?r with cpv ?cpv with stop \n block ?b using paths $?paths)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::TryConstructNewSlice\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e))))\n (object (is-a Path) \n (id ?path) \n ; we want the elements between the last block and the block on\n ; the wavefront. With multifield pattern matching, this is\n ; really easy\n (values $? ?e $?slice ?b $?))\n =>\n (retract ?fct)\n (make-instance of Slice \n (parent ?b) \n (target-path ?path)\n (target-block ?e) \n (contents $?slice)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::SliceAlreadyExists\n ?fct <- (Generate slice for block ?e in ?r with cpv ?cpv with stop \n block ?b using path ?path)\n (exists (object (is-a Slice) \n (parent ?b) \n (target-path ?path) \n (target-block ?e)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice::RemoveSliceAnalysisFact\n ?fct <- (Generate slices for block ? in ? with cpv ? with stop block ? \n using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n;only construct slices as we see fit as we can just reference them again.\n;------------------------------------------------------------------------------\n; Now that we have slices constructed it's time to run through the\n; analyze-merge cycle. First up, analyze. In this phase we need to see if it\n; is possible to schedule into the block. Actually, I can see that we already\n; did the hard work as any regions that would have prevented code from moving\n; up would have already prevented the block from being selected. Thus we should\n; just check to see if we have a local dependency\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::InitialCPVSetupForPathAggregate\n \"Load all of the compensation path vectors for the given path \n aggregate into the aggregates TargetCompensationPathVectors \n multifield\"\n (object (is-a Wavefront) \n (values $? ?blkID $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?blkID) \n (CompensationPathVectors \n $?cpvIDs&:(> (length$ ?cpvIDs) 0)))\n =>\n (modify-instance ?agObj \n (TargetCompensationPathVectors $?cpvIDs)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze-init::SetifyTargetCompensationPathVectors\n ?pa <- (object (is-a PathAggregate) \n (TargetCompensationPathVectors $?a ?b $?c ?b $?d))\n =>\n (bind ?tcpv (create$ ?b))\n (progn$ (?i (create$ ?a ?c ?d))\n (if (not (member$ ?i ?tcpv)) then\n (bind ?tcpv (create$ ?tcpv ?i))))\n (modify-instance ?pa (TargetCompensationPathVectors ?tcpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-generate-analyze::SelectCPVForAnalysis\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (TargetCompensationPathVectors \n $?cpvs&:(> (length$ ?cpvs) 0)))\n =>\n ;clear out the cpvs\n (modify-instance ?agObj \n (TargetCompensationPathVectors))\n (bind ?result (create$))\n ;object of this loop is to figure out if there are any remaining\n ;paths tied to the target path aggregate that can reach the block on\n ;the wavefront. \n (progn$ (?cpv $?cpvs)\n (bind ?det FALSE)\n (bind ?cpvName (instance-address * (symbol-to-instance-name\n ?cpv)))\n (bind ?paths (send ?cpvName get-Paths))\n ;we look through the set of paths that the target CPV is on.\n ;We try to find one that contains the target block on the\n ;wavefront\n (progn$ (?p ?paths)\n (if ?det then \n ;we found a path that contains ?e\n (break)\n else \n (bind ?o2 (instance-address *\n (symbol-to-instance-name ?p)))\n (bind ?o2C (send ?o2 get-values))\n (bind ?det (or ?det (member$ ?e ?o2C)))))\n ;Outer loop\n (if ?det then \n (bind ?result (create$ ?result ?cpv))))\n ; if we didn't find any valid CPVs then this message will be \n ; automatically retracted in the next module\n (assert (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => $?result))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::SegmentCPVsApart\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ?e ?r => ?cpv $?cpvs))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n =>\n (modify ?fct (arguments ?e ?r => $?cpvs))\n (assert (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::RetractCPVSegmentationFact\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-block-using-cpvs)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionDoesNotHaveACorrespondingCPV\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV. This rule removes those elements from the path \n aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c))\n (not (exists (object (is-a CompensationPathVector) \n (parent ?a))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-generate-analyze::TargetInstructionIsNotRegisteredWithTheTargetPathAggregate\n \"Sometimes it turns out that sometimes store instructions will add \n certain instructions to the instruction list even though they don't \n have a valid CPV registered with the path aggregate. This rule removes \n those elements from the path aggregate\"\n ?pa <- (object (is-a PathAggregate) \n (InstructionList $?b ?a $?c)\n (CompensationPathVectors $?cpvs))\n (object (is-a CompensationPathVector) \n (parent ?a) \n (id ?id&:(not (member$ ?id $?cpvs))))\n =>\n (modify-instance ?pa (InstructionList $?b $?c)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVIsImpossibleToScheduleIntoTargetBlock\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld)\n (NonLocalDependencies $?nld))\n (test (not (and (subsetp ?ld ?il)\n (subsetp ?nld ?sched))))\n =>\n ;reuse the memory of ?fct for something else\n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e ever))\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVCantBeScheduledIntoTargetBlockYet\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n ?paObj <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionList $?il)\n (ScheduledInstructions $?sched)\n (CompensationPathVectors $?cpvs))\n ;TODO: test to see if putting parts of the test condition into the\n ;match conditions of the previous CE will work correctly or even allow\n ;for piecewise evaluation\n (object (is-a Instruction) \n (id ?i) \n (LocalDependencies $?ld) \n (NonLocalDependencies $?nld))\n (test (and (not (subsetp ?ld ?sched))\n (subsetp ?ld ?il)\n (subsetp ?nld ?sched)))\n =>\n ;cheaper way to \n (modify ?fct (action cant-schedule)\n (arguments ?cpv ?e now)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::TargetCPVNeedsToBeSliceAnalyzed\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-instruction-with-associate-cpv-for)\n (arguments ?i ?cpv ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (ScheduledInstructions $?sched))\n (object (is-a Instruction) \n (id ?i) \n (parent ?b) \n (LocalDependencies $?ld&:(subsetp ?ld ?sched)))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Paths $?paths))\n =>\n (retract ?fct)\n (bind ?validPaths (create$))\n (progn$ (?z ?paths)\n (bind ?obj (instance-address * (symbol-to-instance-name ?z)))\n (bind ?contents (send ?obj get-contents))\n (if (member$ ?e ?contents) then\n (bind ?validPaths (create$ ?validPaths ?z))))\n (if (> (length$ ?validPaths) 0) then\n (assert (Pull slices for range ?e to ?b for instruction ?i { \n associated cpv ?cpv } using paths $?validPaths))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::CreateSliceSegments\n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (object (is-a Slice) \n (parent ?b) \n (target-block ?e) \n (target-path ?path)\n (id ?s))\n =>\n (retract ?fct)\n (assert (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths $?paths)\n (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s ?e ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::RetractSliceSegmenterFact\n ?fct <- (Pull slices for range ? to ? for instruction ? {\n associated cpv ? } using paths)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::FAILURE-MISSING-SLICE \n ?fct <- (Pull slices for range ?e to ?b for instruction ?i {\n associated cpv ?cpv } using paths ?path $?paths)\n (not (exists (object (is-a Slice) \n (parent ?b) \n (target-block ?e)\n (target-path ?path))))\n =>\n (facts)\n (printout t \"ERROR: Couldn't find an associated slice for \" crlf\n \"TargetBlock = \" ?e crlf\n \"Parent = \" ?b crlf\n \"TargetPath = \" ?path crlf\n \"TargetPath contents = \" (send (symbol-to-instance-name\n ?path) get-contents) crlf\n \"Rest of paths are = \" $?paths crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single-single=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s1&~?s1 ?e ?cpv))\n =>\n (retract ?f1)\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0 ?s1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::single=>multi\n (declare (salience -3))\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slice)\n (arguments ?s0 ?e ?cpv))\n =>\n (modify ?f0 (action analyze-slices)\n (arguments ?e ?cpv => ?s0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::multi-multi=>multi\n ?f0 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?q))\n ?f1 <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?z))\n (test (neq ?f0 ?f1)) \n =>\n (modify ?f0 (arguments ?e ?cpv => $?q $?z))\n (retract ?f1))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-analyze::SetifyAnalyzeSlicesFact\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?a ?b $?c ?b $?d))\n =>\n (bind ?tmp (create$ ?b))\n (progn$ (?s (create$ ?a ?c ?d))\n (if (not (member$ ?s ?tmp)) then\n (bind ?tmp (create$ ?tmp ?s))))\n (modify ?fct (arguments ?e ?cpv => ?tmp)))\n;------------------------------------------------------------------------------\n; now that we have a list of slices to look at it's time to check and see if\n; the given cpv can be moved up based on the slice. If it can't then assert \n; a fact that says as much\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::RetractSliceAnalysis\n \"Retract all slice analysis if it turns out there is a failure fact\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => $?))\n (exists (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ?)))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-ProducerLowerThanTargetBlock\n \"Does a check to make sure that non local dependencies prevent an \n instruction from being moved upward into the target block\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (Produces $? ?nld $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) (id ?i) \n (DestinationRegisters ?dr)\n (NonLocalDependencies $? ?nld $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i ?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::AnalyzeSliceContentsForFailure-CallBarrier\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b)\n (contents $? ?element $?))\n (object (id ?element) \n (HasCallBarrier TRUE))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a Instruction) \n (id ?i) \n (DestinationRegisters ?dr))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetHasMemoryBarrier\n \"The given slice has an element that contains a memory barrier. \n A memory barrier is only created when analysis has failed to ascertain\n what is being read from or written to in memory.\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-ModifiesSameMemory\n \"The given slice has an element that contains a entry in the WritesTo \n list that is the same thing as the given load or store instruction\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?b) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i)\n (MemoryTarget ?mt) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (HasMemoryBarrier FALSE) \n (HasCallBarrier FALSE)\n (WritesTo $? ?mt $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::SliceTargetDoesntHaveMemoryBarrier-HasUnknownReference\n \"Does now allow loads or stores to be moved above the given element\n regardless of if a memory barrier exists or not. This is because there\n is an unknown loader element\"\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n (object (is-a Slice) \n (id ?s) \n (target-block ?e) \n (parent ?cpv) \n (contents $? ?element $?))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?i))\n (object (is-a LoadInstruction|StoreInstruction) \n (id ?i) \n (parent ?q) \n (DestinationRegisters ?dr))\n (object (id ?element) \n (WritesTo $? UNKNOWN $?))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (bind ?ind (member$ ?i (send ?agObj get-InstructionList)))\n (if ?ind then\n (slot-delete$ ?agObj InstructionList ?ind ?ind))\n (assert (message (to wavefront-scheduling)\n (action cant-schedule)\n (arguments ?cpv ?e ever))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleIntoBlockOnSlice\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv => ?s $?ss))\n =>\n (modify ?fct (arguments ?e ?cpv => $?ss)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-slice-analyze::CanScheduleInstructionThisIteration\n (declare (salience -3))\n ?fct <- (message (to wavefront-scheduling)\n (action analyze-slices)\n (arguments ?e ?cpv =>))\n =>\n ;modify the template to fit our needs :D\n (modify ?fct (action can-schedule)\n (arguments ?cpv ?e)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::AddCPVToSuccessList\n ?fct <- (message (to wavefront-schedule)\n (action can-schedule)\n (arguments ?cpv ?e))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (MovableCompensationPathVectors $?mcpv))\n =>\n (retract ?fct)\n (modify-instance ?agObj (MovableCompensationPathVectors $?mcpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::FailCPVForNow\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b now))\n ?ag <- (object (is-a PathAggregate) \n (parent ?b)\n (StalledCompensationPathVectors $?scpv))\n =>\n (retract ?fct)\n (modify-instance ?ag (StalledCompensationPathVectors $?scpv ?cpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-init::RemoveCPVFromService\n ?fct <- (message (to wavefront-schedule)\n (action cant-schedule)\n (arguments ?cpv ?b ever))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ImpossibleCompensationPathVectors $?icpv))\n ?cpvObj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?fails))\n =>\n (retract ?fct)\n (object-pattern-match-delay\n (modify-instance ?cpvObj (Failures $?fails ?b))\n (modify-instance ?agObj (ImpossibleCompensationPathVectors \n $?icpv ?cpv))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::PonderMovementIteration\n (declare (salience 100))\n (object (is-a Wavefront) \n (id ?r) \n (values $? ?e $?))\n ?ag <- (object (is-a PathAggregate) \n (parent ?e) \n (id ?pa)\n (StalledCompensationPathVectors \n $?scpv&:(> (length$ $?scpv) 0)))\n =>\n ;we use an explicit fact like this so that it's easy to match against\n ;and only one version of this fact will exist at any given time within\n ;the fact pool of the wavefront-scheduling-ponder module\n (assert (Another Movement Required))\n (modify-instance ?ag (StalledCompensationPathVectors)\n (TargetCompensationPathVectors $?scpv)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-ponder::AnotherMovementIsRequired\n ?f <- (Another Movement Required)\n ?obj <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?f)\n (modify-instance ?obj (passes wavefront-scheduling-pre-generate-analyze\n wavefront-scheduling-generate-analyze\n wavefront-scheduling-analyze \n wavefront-scheduling-slice-analyze\n wavefront-scheduling-merge-init \n wavefront-scheduling-merge \n wavefront-scheduling-merge-update \n wavefront-scheduling-reopen-blocks\n wavefront-scheduling-ponder\n $?passes)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-post-ponder::FinishSchedulingIntoBlock\n ?fct <- (message (from pipeline)\n (to wavefront-scheduling-post-ponder)\n (action initial-fact))\n =>\n (retract ?fct)\n (progn$ (?instance (find-all-instances ((?wave Wavefront)) TRUE))\n (progn$ (?child (send ?instance get-values))\n (bind ?name (instance-address llvm (symbol-to-instance-name ?child)))\n (modify-instance ?name \n (IsOpen FALSE)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5dfa92596b0feac6dc804ddbb1a710484981f2e1","subject":"fixed an infinite loop bug in WavefrontPropagation.clp","message":"fixed an infinite loop bug in WavefrontPropagation.clp\n\nThis bug manfiests because each instance modification causes\nPropagateAggregateInformation to restart its entire chain of execution. This\ncauses an infinite loop to occur.\n\nI have reverted the body of the rule to be a slot-insert$ instead of modify\ninstance and have removed the slot match for InstuctionPropagation in the left\nhand side of the rule.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (slot-insert$ ?pa InstructionPropagation 1 ?targ ?alias ?z !))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n ?count\n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n ?count\n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"89697dff49fe150cad42302494e56205ab7f2a22","subject":"update clips","message":"update clips\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-knowledge.clp","new_file":"clips\/beer-knowledge.clp","new_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-color-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-color ?color)\n =>\n (assert (attribute (name best-color) (value ?color) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-fermentation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-fermentation ?fermentation)\n =>\n (assert (attribute (name best-fermentation) (value ?fermentation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-claro\n (declare (salience ?*medium-low-priority*))\n (which-cigar claro)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-maduro\n (declare (salience ?*medium-low-priority*))\n (which-cigar maduro)\n =>\n (assert (attribute (name best-style) (value \"Stout\") (certainty 20)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-oscuro\n (declare (salience ?*medium-low-priority*))\n (which-cigar oscuro)\n =>\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n ; ... if main meal is cheese\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Mascarpone-with-fruit-is-yes\n (declare (salience ?*medium-low-priority*))\n (Mascarpone-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ch\u00e8vre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork-is-loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm\/hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-shellfish oysters)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruy\u00e8re\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Cr\u00e8me\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork-or-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich pork))\n (which-meat steak))\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n ; ... if main meal is dessert\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened\/bitter-or-which-entr\u00e9e-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-sweet\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste sweet)\n; =>\n; (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-acid\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste acid)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-spice\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste spice)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n; (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-umami\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste umami)\n; =>\n; (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n; (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n;(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-fats-and-predominant-dish-taste-is-sweet\n; (declare (salience ?*medium-low-priority*))\n; (or (which-entr\u00e9e-omnivorous fats)\n; (which-entr\u00e9e-vegetarian \"vegetable fats\")\n; (which-entr\u00e9e-vegan \"vegetable fats\"))\n; (predominant-dish-taste sweet)\n; =>\n; (assert (attribute (name best-alcohol) (value harsh) (certainty 50)))\n; (assert (attribute (name best-alcohol) (value noticeable) (certainty 25))))\n\n;(defrule determine-best-beer-attributes-if-dish-cooking-method-is-dry-heat\n; (declare (salience ?*medium-low-priority*))\n; (dish-cooking-method dry-heat)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))","old_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-regular-beer-drinker-is-no\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 20)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 20)))\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 10)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 10)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-color-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-color ?color)\n =>\n (assert (attribute (name best-color) (value ?color) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-fermentation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-fermentation ?fermentation)\n =>\n (assert (attribute (name best-fermentation) (value ?fermentation) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-fermented-foods-eater-is-yes\n (declare (salience ?*medium-low-priority*))\n (fermented-foods-eater yes)\n =>\n (assert (attribute (name best-fermentation) (value wild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-driver-is-yes\n (declare (salience ?*medium-low-priority*))\n (driver yes)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 10))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-claro\n (declare (salience ?*medium-low-priority*))\n (which-cigar claro)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-maduro\n (declare (salience ?*medium-low-priority*))\n (which-cigar maduro)\n =>\n (assert (attribute (name best-style) (value \"Stout\") (certainty 20)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-which-cigar-is-oscuro\n (declare (salience ?*medium-low-priority*))\n (which-cigar oscuro)\n =>\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 20))))\n\n(defrule determine-best-beer-attributes-if-preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor fruity)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 20))))\n\n; determine best beer attributes for meal type recognized...\n\n ; ... if main meal is cheese\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Mascarpone-with-fruit-is-yes\n (declare (salience ?*medium-low-priority*))\n (Mascarpone-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ricotta)\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ch\u00e8vre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Feta)\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese \"Monterey Jack\")\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm\/hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 80)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp\n (declare (salience ?*medium-low-priority*))\n (Cheddar-is-sharp yes)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Emmental)\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruy\u00e8re\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-firm\/hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 80)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Cr\u00e8me\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 80)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-grain\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (which-grain bruschetta)\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits\n (declare (salience ?*medium-low-priority*))\n (which-grain grits)\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-legumes\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous legumes)\n (which-entr\u00e9e-vegetarian legumes)\n (which-entr\u00e9e-vegan legumes))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 80)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (shellfish-is-mild yes)\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (fish-cooking-method grilled)\n (which-shellfish shrimps)\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (fish-cooking-method grilled)\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-which-entr\u00e9e-omnivorous-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich beef)\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 50)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich pork)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (which-pork loin)\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild\n (declare (salience ?*medium-low-priority*))\n (which-game wild)\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-steak\n (declare (salience ?*medium-low-priority*))\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-steak\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-meat steak)\n =>\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 80)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 80))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (which-other-vegetables mushrooms)\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-fats\n (declare (salience ?*medium-low-priority*))\n (or (which-entr\u00e9e-omnivorous fats)\n (which-entr\u00e9e-vegetarian \"vegetable fats\")\n (which-entr\u00e9e-vegan \"vegetable fats\"))\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (or (which-fats vegetable)\n (which-entr\u00e9e-vegetarian \"vegetables fats\")\n (which-entr\u00e9e-vegan \"vegetables fats\"))\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n ; ... if main meal is dessert\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 90)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 90)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 90))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened\/bitter-or-which-entr\u00e9e-vegan-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (which-chocolate unsweetened\/bitter)\n (which-entr\u00e9e-vegan chocolate))\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 90)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 90)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 90))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-sweet\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste sweet)\n; =>\n; (assert (attribute (name best-flavor) (value dark-roasty) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-acid\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste acid)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-spice\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste spice)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50)))\n; (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 50))))\n\n;(defrule determine-best-beer-attributes-if-predominant-dish-taste-is-umami\n; (declare (salience ?*medium-low-priority*))\n; (predominant-dish-taste umami)\n; =>\n; (assert (attribute (name best-carbonation) (value high) (certainty 50)))\n; (assert (attribute (name best-carbonation) (value medium) (certainty 25))))\n\n;(defrule determine-best-beer-attributes-if-which-entr\u00e9e-is-fats-and-predominant-dish-taste-is-sweet\n; (declare (salience ?*medium-low-priority*))\n; (or (which-entr\u00e9e-omnivorous fats)\n; (which-entr\u00e9e-vegetarian \"vegetable fats\")\n; (which-entr\u00e9e-vegan \"vegetable fats\"))\n; (predominant-dish-taste sweet)\n; =>\n; (assert (attribute (name best-alcohol) (value harsh) (certainty 50)))\n; (assert (attribute (name best-alcohol) (value noticeable) (certainty 25))))\n\n;(defrule determine-best-beer-attributes-if-dish-cooking-method-is-dry-heat\n; (declare (salience ?*medium-low-priority*))\n; (dish-cooking-method dry-heat)\n; =>\n; (assert (attribute (name best-flavor) (value malty-sweet) (certainty 50))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"c2b5a7feafe6bcca15b35dfb9cbdaaa1f64b2836","subject":"fixed persons heights","message":"fixed persons heights\n","repos":"The4Ms\/family-knowledgebase","old_file":"personsFacts.clp","new_file":"personsFacts.clp","new_contents":"(deffacts initialPersons\n\t\n\t(Person\n\t\t(name \"Ali\")\n\t\t(gender m)\n\t\t(birthYear 1925)\n\t\t(height 180)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Mona\")\n\t)\n\t\n\t(Person\n\t\t(name \"Mona\")\n\t\t(gender f)\n\t\t(birthYear 1930)\n\t\t(height 160)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Ali\")\n\t)\n\t\n\t(Person\n\t\t(name \"Sami\")\n\t\t(gender m)\n\t\t(birthYear 1950)\n\t\t(height 175)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Hassan\" \"Hala\")\n\t\t(spouse \"Nadia\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nadia\")\n\t\t(gender f)\n\t\t(birthYear 1951)\n\t\t(height 165)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Sami\")\n\t)\n\n\t(Person\n\t\t(name \"Hala\")\n\t\t(gender f)\n\t\t(birthYear 1955)\n\t\t(height 150)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Sami\" \"Hassan\")\n\t\t(spouse \"Zein\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hassan\")\n\t\t(gender m)\n\t\t(birthYear 1952)\n\t\t(height 170)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Hala\"\"Sami\")\n\t\t(spouse \"Nahed\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nahed\")\n\t\t(gender f)\n\t\t(birthYear 1955)\n\t\t(height 155)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\")\n\t\t(spouse \"Hassan\")\n\t)\n\t\n\t(Person\n\t\t(name \"Zein\")\n\t\t(gender m)\n\t\t(birthYear 1950)\n\t\t(height 180)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\")\n\t\t(spouse \"Hala\")\n\t)\n\t\n\t(Person\n\t\t(name \"Ahmed\")\n\t\t(gender m)\n\t\t(birthYear 1975)\n\t\t(height 173)\n\t\t(parents \"Sami\" \"Nadia\")\n\t\t(siblings \"Salma\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Salma\")\n\t\t(gender f)\n\t\t(birthYear 1978)\n\t\t(height 162)\n\t\t(parents \"Sami\" \"Nadia\")\n\t\t(siblings \"Ahmed\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hani\")\n\t\t(gender m)\n\t\t(birthYear 1980)\n\t\t(height 173)\n\t\t(parents \"Hassan\" \"Nahed\")\n\t\t(siblings \"Laila\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Laila\")\n\t\t(gender f)\n\t\t(birthYear 1979)\n\t\t(height 160)\n\t\t(parents \"Hassan Nahed\" \"\")\n\t\t(siblings \"Hani\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hana\")\n\t\t(gender f)\n\t\t(birthYear 1985)\n\t\t(height 168)\n\t\t(parents \"Zein Hala\" \"\")\n\t\t(siblings \"Mai\" \"\")\n\t\t(spouse \"\")\n\t)\n\t(Person\n\t\t(name \"Mai\")\n\t\t(gender f)\n\t\t(birthYear 1986)\n\t\t(height 155)\n\t\t(parents \"Zein Hala\" \"\")\n\t\t(siblings \"Hana\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Adam\")\n\t\t(gender m)\n\t\t(birthYear 2001)\n\t\t(height 150)\n\t\t(parents \"Ahmed\" \"\")\n\t\t(siblings \"Nadine\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nadine\")\n\t\t(gender f)\n\t\t(birthYear 2003)\n\t\t(height 125)\n\t\t(parents \"Ahmed\" \"\")\n\t\t(siblings \"Adam\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Salwa\")\n\t\t(gender f)\n\t\t(birthYear 2005)\n\t\t(height 120)\n\t\t(parents \"Hani\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Adel\")\n\t\t(gender m)\n\t\t(birthYear 2001)\n\t\t(height 135)\n\t\t(parents \"Laila\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Abdullah\")\n\t\t(gender m)\n\t\t(birthYear 2010)\n\t\t(height 90)\n\t\t(parents \"Hana\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hossam\")\n\t\t(gender m)\n\t\t(birthYear 2010)\n\t\t(height 100)\n\t\t(parents \"Mai\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n)","old_contents":"(deffacts initialPersons\n\t\n\t(Person\n\t\t(name \"Ali\")\n\t\t(gender m)\n\t\t(birthYear 1925)\n\t\t(height 180)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Mona\")\n\t)\n\t\n\t(Person\n\t\t(name \"Mona\")\n\t\t(gender f)\n\t\t(birthYear 1930)\n\t\t(height 160)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Ali\")\n\t)\n\t\n\t(Person\n\t\t(name \"Sami\")\n\t\t(gender m)\n\t\t(birthYear 1950)\n\t\t(height 175)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Hassan\" \"Hala\")\n\t\t(spouse \"Nadia\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nadia\")\n\t\t(gender f)\n\t\t(birthYear 1951)\n\t\t(height 165)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"Sami\")\n\t)\n\n\t(Person\n\t\t(name \"Hala\")\n\t\t(gender f)\n\t\t(birthYear 1955)\n\t\t(height 150)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Sami\" \"Hassan\")\n\t\t(spouse \"Zein\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hassan\")\n\t\t(gender m)\n\t\t(birthYear 1952)\n\t\t(height 170)\n\t\t(parents \"Ali\" \"Mona\")\n\t\t(siblings \"Hala\"\"Sami\")\n\t\t(spouse \"Nahed\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nahed\")\n\t\t(gender f)\n\t\t(birthYear 1955)\n\t\t(height 1.55)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\")\n\t\t(spouse \"Hassan\")\n\t)\n\t\n\t(Person\n\t\t(name \"Zein\")\n\t\t(gender m)\n\t\t(birthYear 1950)\n\t\t(height 1.8)\n\t\t(parents \"\" \"\")\n\t\t(siblings \"\")\n\t\t(spouse \"Hala\")\n\t)\n\t\n\t(Person\n\t\t(name \"Ahmed\")\n\t\t(gender m)\n\t\t(birthYear 1975)\n\t\t(height 1.73)\n\t\t(parents \"Sami\" \"Nadia\")\n\t\t(siblings \"Salma\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Salma\")\n\t\t(gender f)\n\t\t(birthYear 1978)\n\t\t(height 1.62)\n\t\t(parents \"Sami\" \"Nadia\")\n\t\t(siblings \"Ahmed\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hani\")\n\t\t(gender m)\n\t\t(birthYear 1980)\n\t\t(height 1.73)\n\t\t(parents \"Hassan\" \"Nahed\")\n\t\t(siblings \"Laila\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Laila\")\n\t\t(gender f)\n\t\t(birthYear 1979)\n\t\t(height 1.6)\n\t\t(parents \"Hassan Nahed\" \"\")\n\t\t(siblings \"Hani\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hana\")\n\t\t(gender f)\n\t\t(birthYear 1985)\n\t\t(height 1.68)\n\t\t(parents \"Zein Hala\" \"\")\n\t\t(siblings \"Mai\" \"\")\n\t\t(spouse \"\")\n\t)\n\t(Person\n\t\t(name \"Mai\")\n\t\t(gender f)\n\t\t(birthYear 1986)\n\t\t(height 1.55)\n\t\t(parents \"Zein Hala\" \"\")\n\t\t(siblings \"Hana\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Adam\")\n\t\t(gender m)\n\t\t(birthYear 2001)\n\t\t(height 1.5)\n\t\t(parents \"Ahmed\" \"\")\n\t\t(siblings \"Nadine\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Nadine\")\n\t\t(gender f)\n\t\t(birthYear 2003)\n\t\t(height 1.25)\n\t\t(parents \"Ahmed\" \"\")\n\t\t(siblings \"Adam\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Salwa\")\n\t\t(gender f)\n\t\t(birthYear 2005)\n\t\t(height 1.2)\n\t\t(parents \"Hani\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Adel\")\n\t\t(gender m)\n\t\t(birthYear 2001)\n\t\t(height 1.35)\n\t\t(parents \"Laila\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Abdullah\")\n\t\t(gender m)\n\t\t(birthYear 2010)\n\t\t(height 0.9)\n\t\t(parents \"Hana\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n\t\n\t(Person\n\t\t(name \"Hossam\")\n\t\t(gender m)\n\t\t(birthYear 2010)\n\t\t(height 1)\n\t\t(parents \"Mai\" \"\")\n\t\t(siblings \"\" \"\")\n\t\t(spouse \"\")\n\t)\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"195d95aecd517929b382f90cfac6db127922715d","subject":"Fixed the assert message handler","message":"Fixed the assert message handler\n\nIt now uses the format command to wrap the variable number of arguments in a\nset of parens.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject))\n ;(role concrete)\n ;(slot pointer (source composite) (access initialize-only)\n ; (visibility public)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n\t\t\t\t\t\t\t (bind ?t (implode$ $?elements))\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (format nil \"(%s)\" ?t))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject))\n ;(role concrete)\n ;(slot pointer (source composite) (access initialize-only)\n ; (visibility public)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"32e54d8bd1aea59839660ee511f25c8b5e2eee9a","subject":"message template now requires the to and action slots to be set on assert","message":"message template now requires the to and action slots to be set on assert\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform","old_file":"System\/Runtime\/Message.clp","new_file":"System\/Runtime\/Message.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Message.clp - Contains the message template which is a standard way to pass\n; knowledge between modules that have no knowledge of one another.\n;\n; Use of messages also allows programmers to use modify and duplicate to cut\n; down on the amount of redundant typing which can potentially lead to a \n; reduction in the overall error rate.\n;------------------------------------------------------------------------------\n(deftemplate Runtime::message\n \"Provides a communication medium between modules\"\n (slot to \n (type SYMBOL)\n (default ?NONE))\n (slot from \n (type SYMBOL))\n (slot action \n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Message.clp - Contains the message template which is a standard way to pass\n; knowledge between modules that have no knowledge of one another.\n;\n; Use of messages also allows programmers to use modify and duplicate to cut\n; down on the amount of redundant typing which can potentially lead to a \n; reduction in the overall error rate.\n;------------------------------------------------------------------------------\n(deftemplate Runtime::message\n \"Provides a communication medium between modules\"\n (slot to (type SYMBOL))\n (slot from (type SYMBOL))\n (slot action (type SYMBOL))\n (multislot arguments))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"cdc35586cc53196d85c36206d405983615a8b187","subject":"Added functions for point intersections","message":"Added functions for point intersections\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery.clp","new_file":"lib\/chicanery.clp","new_contents":";------------------------------------------------------------------------------\n;electron-platform\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler intersects primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?mask INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?mask)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (create-accessor read))\n (multislot buttons \n (create-accessor read))\n (slot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler mouse clear primary\n ()\n (bind ?self:position (create$))\n (bind ?self:buttons (create$))\n (bind ?self:timestamp 0))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons (translate\/mouse\/buttons))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (slot-direct-delete$ keys 1 ?self:length)\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:length 1)\n ?key)\n (bind ?self:length (+ ?self:length 1))\n else\n (bind ?self:keys ?key)\n (bind ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-entries))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n(defmethod translate-menu-id\n \"Handles the case when -1 is passed\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n (return NIL))\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n; system initialization features\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n; on-resized handling\n\n(defgeneric on-resized)\n\n(defrule on-resized\n \"library defined rule which calls the on-resized method\"\n (declare (salience 10000))\n ?f <- (event resized new ?value)\n =>\n (retract ?f)\n (on-resized ?value))\n\n; intersection methods for points and rectangles\n(defgeneric intersects)\n\n(defmethod intersects \n \"Checks to see if the given point intersects with the given area\"\n ((?px NUMBER)\n (?py NUMBER)\n (?rx NUMBER)\n (?ry NUMBER)\n (?rbx NUMBER)\n (?rby NUMBER))\n (and (<= ?rx ?px ?rbx)\n (<= ?ry ?py ?rby)))\n\n(defmethod intersects\n ((?px NUMBER)\n (?py NUMBER)\n (?rectangle rectangle))\n =>\n (send ?rectangle intersects ?px ?py))\n\n(defmessage-handler rectangle intersects primary\n (?px ?py)\n (intersects ?px ?py ?self:x ?self:y ?self:bx ?self:by))\n","old_contents":";------------------------------------------------------------------------------\n;electron-platform\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?mask INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?mask)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r INSTANCE-NAME)\n (?src INSTANCE-NAME)\n (?p INSTANCE-NAME))\n (screen\/draw (instance-address ?r)\n (instance-address ?src)\n (instance-address ?p)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (create-accessor read))\n (multislot buttons \n (create-accessor read))\n (slot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler mouse clear primary\n ()\n (bind ?self:position (create$))\n (bind ?self:buttons (create$))\n (bind ?self:timestamp 0))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons (translate\/mouse\/buttons))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (slot-direct-delete$ keys 1 ?self:length)\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:length 1)\n ?key)\n (bind ?self:length (+ ?self:length 1))\n else\n (bind ?self:keys ?key)\n (bind ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-entries))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n(defmethod translate-menu-id\n \"Handles the case when -1 is passed\"\n ((?id INTEGER (= ?id -1))\n (?elements MULTIFIELD LEXEME))\n (return NIL))\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n; system initialization features\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n; on-resized handling\n\n(defgeneric on-resized)\n\n(defrule on-resized\n \"library defined rule which calls the on-resized method\"\n (declare (salience 10000))\n ?f <- (event resized new ?value)\n =>\n (retract ?f)\n (on-resized ?value))\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"305a1b1f50d4dc0c1d455612b4666d73853d9f13","subject":"update beer-knowledge.clp","message":"update beer-knowledge.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-knowledge.clp","new_file":"clips\/beer-knowledge.clp","new_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-which-sex-is-male\n (declare (salience ?*medium-low-priority*))\n (which-sex male)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-color) (value brown) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-color) (value dark) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-sex-is-female\n (declare (salience ?*medium-low-priority*))\n (which-sex female)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-color) (value amber) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-color) (value pale) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05))\n\n(defrule determine-best-beer-attributes-if-which-age-is-18-23\n (declare (salience ?*medium-low-priority*))\n (which-age 18-23)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-24-29\n (declare (salience ?*medium-low-priority*))\n (which-age 24-29)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-more-or-equal-than-30\n (declare (salience ?*medium-low-priority*))\n (which-age >=30)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-autumn\n (declare (salience ?*medium-low-priority*))\n (which-season autumn)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-spring\n (declare (salience ?*medium-low-priority*))\n (which-season spring)\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-summer\n (declare (salience ?*medium-low-priority*))\n (which-season summer)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-winter\n (declare (salience ?*medium-low-priority*))\n (which-season winter)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-he-is-not-a-regular-beer-drinker\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08))))\n\n(defrule determine-best-beer-attributes-if-he-is-going-to-smoke\n (declare (salience ?*medium-low-priority*))\n (smoker yes)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name best-color) (value pale) (certainty 0.07)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.05))))\n\n; determine best beer attributes for personal preferences recognized\n\n(defrule preferred-color-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-color ?color)\n (or (eq ?color pale)\n (eq ?color amber)\n (eq ?color brown)\n (eq ?color dark))\n =>\n (assert (attribute (name best-color) (value ?color) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.2))))\n\n(defrule preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n (or (eq ?carbonation low)\n (eq ?carbonation medium)\n (eq ?carbonation high))\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 0.2))))\n\n(defrule preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.2))))\n\n(defrule preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.2))))\n\n(defrule preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.2))))\n\n(defrule preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.2))))\n\n(defrule preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (or (preferred-flavor fruity)\n (preferred-flavor spicy))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.2))))\n\n(defrule preferred-flavor-is-sour\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sour)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.2))))\n\n; determine best beer attributes for meal type recognized\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (pizza-topping classic)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-cheese\n (declare (salience ?*medium-low-priority*))\n (pizza-topping cheese)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 0.8)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Creme\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e grain)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e legumes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich pork)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e vegetables)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fats)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (which-fats vegetable)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.5)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2))))\n\n(defrule determine-best-beer-attributes-if-creamy-dessert-is-fruit\n (declare (salience ?*medium-low-priority*))\n (creamy-dessert-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter\n (declare (salience ?*medium-low-priority*))\n (which-chocolate unsweetened\/bitter)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))","old_contents":"\n;;************************\n;;* BEER KNOWLEDGE RULES *\n;;************************\n\n; determine best beer attributes for user type and scenario recognized\n\n(defrule determine-best-beer-attributes-if-which-sex-is-male\n (declare (salience ?*medium-low-priority*))\n (which-sex male)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-color) (value brown) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-color) (value dark) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-sex-is-female\n (declare (salience ?*medium-low-priority*))\n (which-sex female)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-color) (value amber) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-color) (value pale) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05))\n\n(defrule determine-best-beer-attributes-if-which-age-is-18-23\n (declare (salience ?*medium-low-priority*))\n (which-age 18-23)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-24-29\n (declare (salience ?*medium-low-priority*))\n (which-age 24-29)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03))))\n\n(defrule determine-best-beer-attributes-if-which-age-is-more-or-equal-than-30\n (declare (salience ?*medium-low-priority*))\n (which-age >=30)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.03)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-autumn\n (declare (salience ?*medium-low-priority*))\n (which-season autumn)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-spring\n (declare (salience ?*medium-low-priority*))\n (which-season spring)\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.025)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.03)))\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.035)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.04)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-summer\n (declare (salience ?*medium-low-priority*))\n (which-season summer)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-which-season-is-winter\n (declare (salience ?*medium-low-priority*))\n (which-season winter)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.04)))\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.05)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.05))))\n\n(defrule determine-best-beer-attributes-if-he-is-not-a-regular-beer-drinker\n (declare (salience ?*medium-low-priority*))\n (regular-beer-drinker no)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08))))\n\n(defrule determine-best-beer-attributes-if-he-is-going-to-smoke\n (declare (salience ?*medium-low-priority*))\n (smoker yes)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.08)))\n (assert (attribute (name best-color) (value pale) (certainty 0.07)))\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.05)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.05))))\n\n; determine best beer attributes for personal preferences recognized\n\n(defrule preferred-color-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-color ?color)\n =>\n (assert (attribute (name best-color) (value ?color) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-low\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol low)\n =>\n (assert (attribute (name best-alcohol) (value not-detectable) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-mild\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol mild)\n =>\n (assert (attribute (name best-alcohol) (value mild) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol high)\n =>\n (assert (attribute (name best-alcohol) (value noticeable) (certainty 0.2))))\n\n(defrule preferred-alcohol-is-very-high\n (declare (salience ?*medium-low-priority*))\n (preferred-alcohol \"very high\")\n =>\n (assert (attribute (name best-alcohol) (value harsh) (certainty 0.2))))\n\n(defrule preferred-carbonation-is-any\n (declare (salience ?*medium-low-priority*))\n (preferred-carbonation ?carbonation)\n =>\n (assert (attribute (name best-carbonation) (value ?carbonation) (certainty 0.2))))\n\n(defrule preferred-flavor-is-clean\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor clean)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.2))))\n\n(defrule preferred-flavor-is-sweet\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sweet)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.2))))\n\n(defrule preferred-flavor-is-bitter\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor bitter)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.2))))\n\n(defrule preferred-flavor-is-roasty\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor roasty)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.2))))\n\n(defrule preferred-flavor-is-fruity\n (declare (salience ?*medium-low-priority*))\n (or (preferred-flavor fruity)\n (preferred-flavor spicy))\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.2))))\n\n(defrule preferred-flavor-is-sour\n (declare (salience ?*medium-low-priority*))\n (preferred-flavor sour)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.2))))\n\n; determine best beer attributes for meal type recognized\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-classic\n (declare (salience ?*medium-low-priority*))\n (pizza-topping classic)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy no)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-spicy-meat\n (declare (salience ?*medium-low-priority*))\n (meat-topping-is-spicy yes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted no)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-are-roasted-vegetables\n (declare (salience ?*medium-low-priority*))\n (vegetables-topping-are-roasted yes)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-pizza-topping-is-cheese\n (declare (salience ?*medium-low-priority*))\n (pizza-topping cheese)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-fresh\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style fresh)\n =>\n (assert (attribute (name best-style) (value \"Wheat Beer\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Mascarpone\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Mascarpone)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Ricotta-or-which-grain-is-bruschetta\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Ricotta)\n (which-grain-is-bruschetta))\n =>\n (assert (attribute (name best-name) (value \"Honey Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Chevre\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese Ch\u00e8vre)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Hefeweizen\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"European-Style Export\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Feta-or-which-pork-is-loin\n (declare (salience ?*medium-low-priority*))\n (or (which-fresh-cheese Feta)\n (which-pork loin))\n =>\n (assert (attribute (name best-name) (value \"California Common\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-fresh-cheese-is-Cream-Cheese\n (declare (salience ?*medium-low-priority*))\n (which-fresh-cheese \"Cream Cheese\")\n =>\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-semi-soft\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style semi-soft)\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style K\u00f6lsch\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Mozzarella\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Mozzarella)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"American Imperial Red Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Colby\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Colby)\n =>\n (assert (attribute (name best-name) (value \"German-Style Helles\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Havarti\n (declare (salience ?*medium-low-priority*))\n (which-semi-soft-cheese Havarti)\n =>\n (assert (attribute (name best-name) (value \"Berliner-Style Weisse\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-semi-soft-cheese-is-Monterey-Jack-or-shellfish-is-mild\n (declare (salience ?*medium-low-priority*))\n (or (which-semi-soft-cheese \"Monterey Jack\")\n (shellfish-is-mild yes))\n =>\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-firm-hard\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style firm\/hard)\n =>\n (assert (attribute (name best-style) (value \"Bock\") (certainty 0.8)))\n (assert (attribute (name best-style) (value \"Brown Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Swiss\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (attribute (name best-name) (value \"German-Style Maibock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Gouda\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda aged)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Baltic-Style Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Gouda-is-smoked\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Gouda smoked)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Cheddar\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-medium\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning medium)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-Cheddar-seasoning-is-aged\n (declare (salience ?*medium-low-priority*))\n (which-Cheddar-seasoning aged)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"English-Style IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Oatmeal Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Cheddar-is-sharp-or-which-rich-is-grilled-lamb\n (declare (salience ?*medium-low-priority*))\n (or (Cheddar-is-sharp yes)\n (and (meat-cooking-method grilled)\n (which-rich lamb)))\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-color-of-Cheddar-is-white-and-which-Cheddar-seasoning-is-mild\n (declare (salience ?*medium-low-priority*))\n (which-color-of-Cheddar white)\n (which-Cheddar-seasoning mild)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Emmental-or-which-bluefish-is-grilled-salmon\n (declare (salience ?*medium-low-priority*))\n (or (which-type-of-Swiss Emmental)\n (and (fish-cooking-method grilled)\n (which-bluefish salmon)))\n =>\n (assert (attribute (name best-name) (value \"German-Style Brown\/Altbier\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-type-of-Swiss-is-Gruyere\n (declare (salience ?*medium-low-priority*))\n (which-type-of-Swiss Gruy\u00e8re)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-Swiss-is-aged\n (declare (salience ?*medium-low-priority*))\n (Swiss-is-aged yes)\n =>\n (assert (attribute (name best-name) (value \"German-Style Bock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-firm-hard-cheese-is-Parmesan\n (declare (salience ?*medium-low-priority*))\n (which-firm\/hard-cheese Parmesan)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-is-blue\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style blue)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-style) (value \"India Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-blue-or-natural-rind-cheese-is-Stilton\n (declare (salience ?*medium-low-priority*))\n (or (which-blue-cheese Stilton)\n (which-natural-rind-cheese Stilton))\n =>\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-natural-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"natural rind\")\n =>\n (assert (attribute (name best-style) (value \"Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Barley Wine\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"British-Style Barley Wine Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Brie\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Brie)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Camembert\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Camembert)\n =>\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Triple-Creme\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese \"Triple Cr\u00e8me\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-natural-rind-cheese-is-Mimolette\n (declare (salience ?*medium-low-priority*))\n (which-natural-rind-cheese Mimolette)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-cheese-style-is-washed-rind\n (declare (salience ?*medium-low-priority*))\n (which-cheese-style \"washed rind\")\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Blonde Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Golden Strong Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-washed-rind-cheese-is-Taleggio\n (declare (salience ?*medium-low-priority*))\n (which-washed-rind-cheese Taleggio)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-grain\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e grain)\n =>\n (assert (attribute (name best-flavor) (value crisp-clean) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-chips\n (declare (salience ?*medium-low-priority*))\n (which-grain chips)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-is-spaghetti\n (declare (salience ?*medium-low-priority*))\n (which-grain spaghetti)\n =>\n (assert (attribute (name best-name) (value \"Blonde Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-grain-are-grits-or-which-shellfish-are-grilled-shrimps\n (declare (salience ?*medium-low-priority*))\n (or (which-grain grits)\n (and (fish-cooking-method grilled)\n (which-shellfish shrimps)))\n =>\n (assert (attribute (name best-name) (value \"American Black Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-legumes\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e legumes)\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-fish\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fish)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-fish-is-shellfish\n (declare (salience ?*medium-low-priority*))\n (which-fish shellfish)\n =>\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-mussels\n (declare (salience ?*medium-low-priority*))\n (which-shellfish mussels)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-shellfish-are-oysters\n (declare (salience ?*medium-low-priority*))\n (which-shellfish oysters)\n =>\n (assert (attribute (name best-name) (value \"Irish-Style Dry Stout\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-which-entree-is-meat\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e meat)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-barbecue\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method barbecue)\n =>\n (assert (attribute (name best-name) (value \"American Amber Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-braised-or-which-dessert-is-chocolate\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method braised)\n (which-dessert chocolate))\n =>\n (assert (attribute (name best-flavor) (value malty-sweet) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-meat-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Brown Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-rich-meats\n (declare (salience ?*medium-low-priority*))\n (which-meat rich)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-beef-or-which-rich-is-lamb\n (declare (salience ?*medium-low-priority*))\n (or (and (meat-cooking-method roasted)\n (which-rich beef))\n (which-rich lamb))\n =>\n (assert (attribute (name best-name) (value \"English-Style Old Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-beef-is-bresola\n (declare (salience ?*medium-low-priority*))\n (which-beef bresola)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-lamb\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich lamb)\n =>\n (assert (attribute (name best-name) (value \"French-Style Bi\u00e9re de Garde\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-pork\n (declare (salience ?*medium-low-priority*))\n (which-rich pork)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value fruity-spicy) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-rich-is-roasted-pork\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-rich pork)\n =>\n (assert (attribute (name best-name) (value \"English-Style Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-tenderloin\n (declare (salience ?*medium-low-priority*))\n (which-pork tenderloin)\n =>\n (assert (attribute (name best-name) (value \"Coffee Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-prosciutto\n (declare (salience ?*medium-low-priority*))\n (which-pork prosciutto)\n =>\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Saison\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-speck\n (declare (salience ?*medium-low-priority*))\n (which-pork speck)\n =>\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-mortadella\n (declare (salience ?*medium-low-priority*))\n (which-pork mortadella)\n =>\n (assert (attribute (name best-name) (value \"German-Style M\u00e4rzen\/Oktoberfest\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-sausage\n (declare (salience ?*medium-low-priority*))\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-pork-is-grilled-sausage\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method grilled)\n (which-pork sausage)\n =>\n (assert (attribute (name best-name) (value \"Smoke Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-capocollo\n (declare (salience ?*medium-low-priority*))\n (which-sausage capocollo)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-soppressata\n (declare (salience ?*medium-low-priority*))\n (which-sausage soppressata)\n =>\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-sausage-is-salame-piccante\n (declare (salience ?*medium-low-priority*))\n (which-sausage \"salame piccante\")\n =>\n (assert (attribute (name best-name) (value \"Imperial IPA\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Rye Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-chicken\n (declare (salience ?*medium-low-priority*))\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"German-Style Weizenbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-chicken\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry chicken)\n =>\n (assert (attribute (name best-name) (value \"English-Style Bitter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Dunkelweizen\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-poultry-is-roasted-turkey\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-poultry turkey)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Tripel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Pumpkin Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-game\n (declare (salience ?*medium-low-priority*))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-meat-is-grilled-or-roasted-game\n (declare (salience ?*medium-low-priority*))\n (or (meat-cooking-method grilled)\n (meat-cooking-method roasted))\n (which-meat game)\n =>\n (assert (attribute (name best-name) (value \"American Brett\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-wild-or-which-other-vegetables-are-mushrooms\n (declare (salience ?*medium-low-priority*))\n (or (which-game wild)\n (which-other-vegetables mushrooms))\n =>\n (assert (attribute (name best-name) (value \"English-Style Mild\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-game-is-birds\n (declare (salience ?*medium-low-priority*))\n (which-game birds)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-game-birds-is-roasted-duck\n (declare (salience ?*medium-low-priority*))\n (meat-cooking-method roasted)\n (which-game-birds duck)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-vegetables\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e vegetables)\n =>\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"Vienna-Style Lager\") (certainty 0.8)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.8))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-root\n (declare (salience ?*medium-low-priority*))\n (which-vegetables root)\n =>\n (assert (attribute (name best-flavor) (value sour-tart-funky) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-vegetables-is-salad\n (declare (salience ?*medium-low-priority*))\n (which-vegetables salad)\n =>\n (assert (attribute (name best-name) (value \"American Wheat\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Cream Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Bohemian-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Pilsener\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Fruit and Field Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-grilled\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method grilled)\n =>\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5)))\n (assert (attribute (name best-name) (value \"Smoke Beer\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-vegetables-cooking-method-is-roasted\n (declare (salience ?*medium-low-priority*))\n (vegetables-cooking-method roasted)\n =>\n (assert (attribute (name best-name) (value \"German-Style Dunkel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Irish-Style Red\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-entree-is-fats\n (declare (salience ?*medium-low-priority*))\n (which-entr\u00e9e fats)\n =>\n (assert (attribute (name best-flavor) (value hoppy-bitter) (certainty 0.5)))\n (assert (attribute (name best-flavor) (value dark-roasty) (certainty 0.5))))\n\n(defrule determine-best-beer-attributes-if-which-fats-is-vegetable\n (declare (salience ?*medium-low-priority*))\n (which-fats vegetable)\n =>\n (assert (attribute (name best-carbonation) (value high) (certainty 0.5)))\n (assert (attribute (name best-carbonation) (value medium) (certainty 0.2))))\n\n(defrule determine-best-beer-attributes-if-creamy-dessert-is-fruit\n (declare (salience ?*medium-low-priority*))\n (creamy-dessert-with-fruit yes)\n =>\n (assert (attribute (name best-name) (value \"Scotch Ale\/Wee Heavy\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Scottish-Style Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-white\n (declare (salience ?*medium-low-priority*))\n (which-chocolate white)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Witbier\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Brown Ale\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-milk\n (declare (salience ?*medium-low-priority*))\n (which-chocolate milk)\n =>\n (assert (attribute (name best-name) (value \"American Pale Ale\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"German-Style Doppelbock\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"English-Style Pale Ale (ESB)\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Amber Lager\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-semisweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate semisweet)\n =>\n (assert (attribute (name best-name) (value \"American Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American IPA\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-bittersweet\n (declare (salience ?*medium-low-priority*))\n (which-chocolate bittersweet)\n =>\n (assert (attribute (name best-name) (value \"American Imperial Stout\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Dubbel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Quadrupel\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Lambic\/Gueuze\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Robust Porter\") (certainty 0.9))))\n\n(defrule determine-best-beer-attributes-if-which-chocolate-is-unsweetened-bitter\n (declare (salience ?*medium-low-priority*))\n (which-chocolate unsweetened\/bitter)\n =>\n (assert (attribute (name best-name) (value \"Belgian-Style Flanders\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"Belgian-Style Fruit Lambic\") (certainty 0.9)))\n (assert (attribute (name best-name) (value \"American Sour\") (certainty 0.9))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"aa4c50545f9eb746fb1c84a521ac4d96ec44fde8","subject":"Eren uns parentesis \u00ac\u00ac","message":"Eren uns parentesis \u00ac\u00ac\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","old_contents":"; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio-Persona)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Thu May 05 20:09:37 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(nombre \"Flexiones\")\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(nombre \"Piernas\")\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 0.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 1)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n(defrule crea-programa\n\n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n\t\n\t(printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\n\t(bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t(bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440)\n\t(bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n\t\n\t(send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n(defrule generar\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_ejercicios (create$))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (= ?anadir 1) then (bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e)))\n\t)\n\t(assert (solucion ?lista_ejercicios))\n)\n\n(defrule imprimir-solucion\n\t(solucion $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) crlf))\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"adbe0dfa0c1c6b7f36b6bc601c0b563229256ea8","subject":"Added support for shrinking header-spans to the appropriate size","message":"Added support for shrinking header-spans to the appropriate size\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n(deftemplate heading-span\n \"Defines a span between two different headings\"\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule define-header-spans\n \"Defines spans between headers\"\n (file-line (type heading)\n (parent ?parent)\n (index ?i))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(< ?i2 ?i)))\n =>\n (bind ?difference (- ?i ?i2))\n (if (> ?difference 0) then\n (assert (heading-span (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c9b46359e3367458cce70f16705315a76419c97d","subject":"Fixed a bug in MergeRules.clp","message":"Fixed a bug in MergeRules.clp\n\nThe data for producers and consumers were being stored in the wrong multislots\n(they were flipped). This has been corrected.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-consume-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-produce-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-consumes)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-consume-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-produces)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-produce-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-consume-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-produce-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-consumes)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-consume-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-produces)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-produce-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d5912e99c33f338bcebe2ca295552e6afc883570","subject":"Fixed microcode\/input.clp","message":"Fixed microcode\/input.clp\n\nKeyboard events should be presented correctly now\n","repos":"DrItanium\/phoenix,DrItanium\/phoenix","old_file":"src\/polymer\/microcode\/input.clp","new_file":"src\/polymer\/microcode\/input.clp","new_contents":"(defrule process-mouse-input\n ?f <- (mouse ?a ?b ?c ?d)\n =>\n (retract ?f)\n (format mux \"(mouse %d %d %d %d)\" ?a ?b ?c ?d))\n\n(defrule keyboard-input\n ?f <- (key ?key)\n =>\n (format t \"pressed %d%n\" ?key)\n (retract ?f))\n","old_contents":"(defrule process-mouse-input\n ?f <- (mouse ?a ?b ?c ?d)\n =>\n (retract ?f)\n (format mux \"(mouse %d %d %d %d)\" ?a ?b ?c ?d))\n\n(defrule keyboard-input\n ?f <- (keyboard ?key)\n =>\n (format t \"pressed %d%n\" ?key)\n (retract ?f))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"ffe4ff4196413a9179a8c1c273a22f60d1e3ae30","subject":"Fixed a bug where macro-expand referred to wavefront-determinant","message":"Fixed a bug where macro-expand referred to wavefront-determinant\n\nThis should be wavefront-scheduling-determinant and has been fixed to reflect\nthis.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront-scheduling)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;this module is used to determine which regions should be targeted for pathing\n(defmodule wavefront-scheduling-determinant\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pre-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-code\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-final\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling::macro-expand-passes\n\t\t\t\"Pushes the modules that make up this pass into the pass-description\"\n\t\t\t?f <- (message (from pipeline)\n\t\t\t\t\t\t\t\t(to wavefront-scheduling)\n\t\t\t\t\t\t\t\t(action initial-fact))\n\t\t\t?p <- (object (is-a pass-description) (passes $?passes))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(modify-instance ?p (passes\n\t\t\t\t\t\t\t\t\t\tloop-region-merging\n\t\t\t\t\t\t\t\t\t\tdependency-analysis\n\t\t\t\t\t\t\t\t\t\twavefront-determinant\n\t\t\t\t\t\t\t\t\t\tpaths-conditional\n wavefront-scheduling-pre-init\n\t\t\t\t\t\t\t\t\t\twavefront-scheduling-code\n wavefront-scheduling-final\n\t\t\t\t\t\t\t\t\t\t$?passes)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"31c81ea316602bf1e302c53d5ce78320e7afdea5","subject":"added some more notes to the assembler","message":"added some more notes to the assembler\n","repos":"DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron","old_file":"Assembler.clp","new_file":"Assembler.clp","new_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(load* MachineCommon.clp)\n;-------------------------------------------------------------------------------\n(defglobal MAIN\n ?*symbol-label-instruction* = label\n )\n(deffacts macro-instructions\n (instruction (tag ?*symbol-label-instruction*)\n (arg-count 1)\n (is-macro TRUE)))\n;-------------------------------------------------------------------------------\n(deftemplate input-line\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot original-input\n (type STRING)\n (default ?NONE))\n (multislot raw-input))\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n;-------------------------------------------------------------------------------\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n;-------------------------------------------------------------------------------\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n;-------------------------------------------------------------------------------\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 1)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (original-input ?input)\n (raw-input (explode$ ?input))))\n else\n (assert (translate-input))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n\n(defrule invalid-line-found\n (declare (salience 2))\n (input-line (line-number ?i)\n (original-input ?line)\n (raw-input $?input))\n (test (> (length$ $?input) 4))\n =>\n (printout werror \"ERROR: line \" ?i \" is invalid\" crlf\n \" \" ?line crlf)\n (halt))\n\n(defrule is-invalid-instruction\n (declare (salience 2)) \n (input-line (raw-input ?op $?)\n (line-number ?l)\n (original-input ?input))\n (not (exists (instruction (tag ?op))))\n =>\n (printout werror \n (format nil \"ERROR: Instruction %s on line %d is invalid%n\" ?op ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n(defrule invalid-argument-count-for-operation\n (declare (salience 2))\n (input-line (raw-input ?operation $?rest)\n (line-number ?l)\n (original-input ?input))\n (instruction (tag ?operation)\n (arg-count ?ac&:(!= ?ac (length$ $?rest))))\n =>\n (printout werror \n (format nil \"ERROR: Invalid number of arguments for %s on line %d%n\"\n ?operation ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n\n(defrule process-input-line\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation $?rest)\n (line-number ?l))\n (instruction (tag ?operation)\n (arg-count =(length$ $?rest)))\n\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (arguments $?rest))))\n\n;TODO: Build assembly generator\n;TODO: Mark labels and data instructions as a way to setup a jump table ahead\n; of time.\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n;-------------------------------------------------------------------------------\n(reset) ; load the instruction information for our purposes\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;electron\n;Copyright (c) 2012-2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;-------------------------------------------------------------------------------\n; Assembler.clp - An assembler for the theoretical processor.\n;-------------------------------------------------------------------------------\n(load* MachineCommon.clp)\n;-------------------------------------------------------------------------------\n(defglobal MAIN\n ?*symbol-label-instruction* = label\n )\n(deffacts macro-instructions\n (instruction (tag ?*symbol-label-instruction*)\n (arg-count 1)\n (is-macro TRUE)))\n;-------------------------------------------------------------------------------\n(deftemplate input-line\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot original-input\n (type STRING)\n (default ?NONE))\n (multislot raw-input))\n;-------------------------------------------------------------------------------\n(deftemplate operation\n (slot line-number\n (type INTEGER)\n (default ?NONE))\n (slot operation\n (type SYMBOL)\n (default ?NONE))\n (multislot arguments))\n;-------------------------------------------------------------------------------\n(defgeneric to-char)\n;-------------------------------------------------------------------------------\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)) ; no negative numbers\n (?stream SYMBOL))\n (format ?stream \"%c\" ?i))\n\n(defmethod to-char\n ((?i INTEGER (>= ?i 0)))\n (to-char ?i nil))\n\n;-------------------------------------------------------------------------------\n; since we can't do \"knowledge construction\" in the standard sense we need to\n; pull input from standard-in.\n;-------------------------------------------------------------------------------\n(defrule initialize-assembler\n (initial-fact)\n =>\n (assert (read-to-end 1)))\n\n(defrule build-input-line\n ?f <- (read-to-end ?i)\n =>\n (retract ?f)\n (bind ?input (readline))\n (if (neq ?input EOF) then\n (assert (read-to-end (+ ?i 1))\n (input-line (line-number ?i)\n (original-input ?input)\n (raw-input (explode$ ?input))))\n else\n (assert (translate-input))))\n\n(defrule throw-out-empty-lines\n \"remove lines that are completely comments or just plain empty\"\n (declare (salience 2)) \n ?f <- (input-line (raw-input))\n =>\n (retract ?f))\n(defrule invalid-line-found\n (declare (salience 2))\n (input-line (line-number ?i)\n (original-input ?line)\n (raw-input $?input))\n (test (> (length$ $?input) 4))\n =>\n (printout werror \"ERROR: line \" ?i \" is invalid\" crlf\n \" \" ?line crlf)\n (halt))\n\n(defrule is-invalid-instruction\n (declare (salience 2)) \n (input-line (raw-input ?op $?)\n (line-number ?l)\n (original-input ?input))\n (not (exists (instruction (tag ?op))))\n =>\n (printout werror \n (format nil \"ERROR: Instruction %s on line %d is invalid%n\" ?op ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n(defrule invalid-argument-count-for-operation\n (declare (salience 2))\n (input-line (raw-input ?operation $?rest)\n (line-number ?l)\n (original-input ?input))\n (instruction (tag ?operation)\n (arg-count ?ac&:(!= ?ac (length$ $?rest))))\n =>\n (printout werror \n (format nil \"ERROR: Invalid number of arguments for %s on line %d%n\"\n ?operation ?l)\n (format nil \" Line: %s%n%n\" ?input))\n (halt))\n\n(defrule process-input-line\n (declare (salience 1)) ; evaluate each line as it goes through\n ?f <- (input-line (raw-input ?operation $?rest)\n (line-number ?l))\n (instruction (tag ?operation)\n (arg-count =(length$ $?rest)))\n\n =>\n (retract ?f)\n (assert (operation (line-number ?l)\n (operation ?operation)\n (arguments $?rest))))\n;-------------------------------------------------------------------------------\n; this becomes a script that reads from standard input\n;-------------------------------------------------------------------------------\n(reset) ; load the instruction information for our purposes\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"63d3357f1b9f93584b419ddadbae656453f78d4a","subject":"src\/tools\/conv\/gl\/Types\/Loader.clp: Removed the loading of Object.clp","message":"src\/tools\/conv\/gl\/Types\/Loader.clp: Removed the loading of Object.clp\n\nThis is necessary since Object.clp has been removed\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/Types\/Loader.clp","new_file":"src\/tools\/conv\/gl\/Types\/Loader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads all of the corresponding objects\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(batch* \"Types\/FileRelated.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Loader.clp - Loads all of the corresponding objects\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(batch* \"Types\/Object.clp\")\n(batch* \"Types\/FileRelated.clp\")\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c1270f0f9a57d6c320878ce47505ef6f7658ca03","subject":"Fixed a randomized crash issue with determine-indirect-claim","message":"Fixed a randomized crash issue with determine-indirect-claim\n\nIt seems that object-pattern-match-delay will cause intermittent crashes when\nit's contents are only modify-instance calls. The significant part about this is\nthat modify-instance also delays object pattern matching until finished.\nWithout perusing the associated clips c code, I can only guess that the issue\nhas to do with multiple layers of indirection being added. Fixing this issue\nrequired me to remove the object-pattern-match-delay command that surrounded\nthe modify-instance calls.\n\nI also cleaned up the code to look similar to the wavefront scheduling pass\ncode in terms of formatting.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/PathUpdate.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/PathUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-region\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?r))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t\t\t(parent ?r))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant \n\t\t\t\t\t\t\t\t(parent ?r)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-basicblock\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?b))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t\t\t(parent ?b))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant \n\t\t\t\t\t\t\t\t(parent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-population::populate-determinant\n\t\t\t?fct <- (message (to loop-region-merging) \n\t\t\t\t\t\t\t\t (action claim-owns) \n\t\t\t\t\t\t\t\t (arguments ?a => ?b))\n\t\t\t?obj <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t (parent ?b))\n\t\t\t?obj2 <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t (parent ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(object-pattern-match-delay \n\t\t\t (slot-insert$ ?obj2 PotentialChildren 1 ?b)\n\t\t\t (slot-insert$ ?obj Claims 1 ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-resolution::determine-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t(parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?v ?a $?x) \n\t\t\t\t\t\t\t\t(IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ~?b) \n\t\t\t\t\t (PotentialChildren $? ?b $?) \n\t\t\t\t\t (Claims $? ?a $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t(parent ?a) \n\t\t\t\t\t\t\t\t(PotentialChildren $?t ?b $?r))\n\t\t\t=>\n\t\t\t;let's see if this is faster\n\t\t\t(modify-instance ?t0 (IndirectClaims ?ic ?a) \n\t\t\t\t\t\t\t\t (Claims ?v ?x))\n\t\t\t(modify-instance ?t1 (PotentialChildren ?t ?r)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-indirect-resolution::determine-indirect-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t(parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?l ?a $?x) \n\t\t\t\t\t\t\t\t(IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ~?b&~?a) \n\t\t\t\t\t (IndirectClaims $? ?a $?) \n\t\t\t\t\t (PotentialChildren $? ?b $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) \n\t\t\t\t\t\t\t\t(parent ?a)\n\t\t\t\t\t\t\t\t(PotentialChildren $?z ?b $?q))\n\t\t\t=>\n\t\t\t(modify-instance ?t0 (IndirectClaims ?ic ?a) \n\t\t\t\t\t\t\t\t (Claims ?l ?x))\n\t\t\t(modify-instance ?t1 (PotentialChildren ?z ?q)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::delete-non-existent-references\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (contents $? ?b $?))\n\t\t\t(not (exists (object (id ?b))))\n\t\t\t=>\n\t\t\t(object-pattern-match-delay \n\t\t\t (bind ?ind0 (member$ ?b (send ?region get-contents)))\n\t\t\t (slot-delete$ ?region contents ?ind0 ?ind0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-region\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (Claims ?a))\n\t\t\t?obj <- (object (is-a Region) \n\t\t\t\t\t\t\t\t (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (Claims ?a))\n\t\t\t?obj <- (object (is-a BasicBlock) \n\t\t\t\t\t\t\t\t (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::add-new-child-to-target-region\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?p)\n\t\t\t\t\t (PotentialChildren $? ?a $?))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?p) \n\t\t\t\t\t\t\t\t\t (contents $?c))\n\t\t\t(test (not (member$ ?a ?c)))\n\t\t\t=>\n\t\t\t(slot-insert$ ?region contents 1 ?a))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::cleanup-ownership-determinants\n\t\t\t\"Deletes all of the OwnershipDeterminant objects in a single rule \n\t\t\tfire\"\n\t\t\t?f0 <- (delete ownership-determinants)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?obj (find-all-instances ((?list OwnershipDeterminant)) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t TRUE))\n\t\t\t\t\t (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-rename::remove-unowned-elements\n\t\t\t\"Now that we have figured out and updated ownership claims it is \n\t\t\tnecessary to remove leftover entries in other regions\"\n\t\t\t?r <- (object (is-a Region) \n\t\t\t\t\t\t\t (id ?t) \n\t\t\t\t\t\t\t (contents $?a ?b $?c))\n\t\t\t(object (is-a ParentedObject) \n\t\t\t\t\t (id ?b) \n\t\t\t\t\t (parent ~?t))\n\t\t\t=>\n\t\t\t(modify-instance ?r (contents $?a $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-too-many-claims-of-ownership\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?a) \n\t\t\t\t\t (Claims $?z&:(> (length$ ?z) 1))\n\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?name \" has more than one claim of ownership on\"\n\t\t\t\t\t\t \" it!\" crlf \"The claims are \" ?z crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-region\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?a) \n\t\t\t\t\t (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) \n\t\t\t\t\t (IndirectClaims $?ic))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?a) \n\t\t\t\t\t (IsTopLevelRegion FALSE))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) \n\t\t\t\t\t (parent ?a) \n\t\t\t\t\t (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) \n\t\t\t\t\t (IndirectClaims $?ic))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?a)) \n\t\t\t=>\n\t\t\t(printout t \"ERROR: BasicBlock \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-region\n\t\t\t(object (is-a Region) (id ?r))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?r))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?r)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-basicblock\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?b))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-population::populate-determinant\n \t\t\t?fct <- (message (to loop-region-merging) \n\t\t\t\t(action claim-owns) \n\t\t\t\t(arguments ?a => ?b))\n\t\t\t?obj <- (object (is-a OwnershipDeterminant) (parent ?b))\n\t\t\t?obj2 <- (object (is-a OwnershipDeterminant) (parent ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n (object-pattern-match-delay \n\t\t\t(slot-insert$ ?obj2 PotentialChildren 1 ?b)\n\t\t\t(slot-insert$ ?obj Claims 1 ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-resolution::determine-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?v ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b) \n\t\t\t\t\t (PotentialChildren $? ?b $?) (Claims $? ?a $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t\t\t\t(PotentialChildren $?t ?b $?r))\n\t\t\t=>\n\t\t\t;let's see if this is faster\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?v ?x))\n (modify-instance ?t1 (PotentialChildren ?t ?r))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-indirect-resolution::determine-indirect-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?l ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b&~?a) \n\t\t\t\t\t (IndirectClaims $? ?a $?) (PotentialChildren $? ?b $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a)\n\t\t\t\t\t\t\t\t(PotentialChildren $?z ?b $?q))\n\t\t\t=>\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?l ?x))\n (modify-instance ?t1 (PotentialChildren ?z ?q))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::delete-non-existent-references\n\t\t\t?region <- (object (is-a Region) (contents $? ?b $?))\n\t\t\t(not (exists (object (id ?b))))\n\t\t\t=>\n (object-pattern-match-delay \n\t\t\t(bind ?ind0 (member$ ?b (send ?region get-contents)))\n\t\t\t(slot-delete$ ?region contents ?ind0 ?ind0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) (Claims ?a))\n\t\t\t?obj <- (object (is-a Region) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) \n\t\t\t\t\t (Claims ?a))\n\t\t\t?obj <- (object (is-a BasicBlock) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::add-new-child-to-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p)\n\t\t\t\t\t (PotentialChildren $? ?a $?))\n\t\t\t?region <- (object (is-a Region) (id ?p) (contents $?c))\n (test (not (member$ ?a ?c)))\n\t\t\t=>\n\t\t\t(slot-insert$ ?region contents 1 ?a))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::cleanup-ownership-determinants\n\t\t\t\"Deletes all of the OwnershipDeterminant objects in a single rule \n\t\t\tfire\"\n\t\t\t?f0 <- (delete ownership-determinants)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?obj (find-all-instances ((?list OwnershipDeterminant)) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t TRUE))\n\t\t\t\t\t (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-rename::remove-unowned-elements\n\t\t\t\"Now that we have figured out and updated ownership claims it is \n\t\t\tnecessary to remove leftover entries in other regions\"\n\t\t\t?r <- (object (is-a Region) (id ?t) (contents $?a ?b $?c))\n\t\t\t(object (is-a ParentedObject) (id ?b) (parent ~?t))\n\t\t\t=>\n\t\t\t(modify-instance ?r (contents $?a $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-too-many-claims-of-ownership\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t (Claims $?z&:(> (length$ ?z) 1))\n\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?name \" has more than one claim of ownership on\"\n\t\t\t\t\t\t \" it!\" crlf \"The claims are \" ?z crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a Region) (id ?a) (IsTopLevelRegion FALSE))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a BasicBlock) (id ?a)) \n\t\t\t=>\n\t\t\t(printout t \"ERROR: BasicBlock \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d9dcb77153f5cab387339e3cdb18c1960a261b68","subject":"Fixed bugs found during testing in WavefrontBlockReopen.clp","message":"Fixed bugs found during testing in WavefrontBlockReopen.clp\n\nI forgot that subtypes of hint use values instead of contents as their storage\nmultislot.\n\nI also fixed an error in the name of a module for one of the rules\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontBlockReopen.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontBlockReopen.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::AssertReopenBlocksOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?failures))\n =>\n (modify-instance ?obj (Failures))\n (modify ?fct (action reopen)\n (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::ReopenBlockOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?a ?fail $?b)\n (values $?cnts))\n ?bb <- (object (is-a BasicBlock) \n (id ?fail) \n (IsOpen FALSE))\n ?pa <- (object (is-a PathAggregate) \n (parent ?fail)\n (InstructionList $?il)\n (ImpossibleCompensationPathVectors $?icpv))\n =>\n (modify-instance ?bb (IsOpen TRUE))\n (bind ?qs (create$))\n (progn$ (?q ?icpv)\n (bind ?qObj (instance-address (symbol-to-instance-name ?q)))\n (bind ?qs (create$ ?qs (send ?qObj get-parent))))\n (modify-instance ?pa (ImpossibleCompensationPathVectors)\n (InstructionList $?il ?qs)\n (TargetCompensationPathVectors $?icpv))\n (modify-instance ?wave (contents $?cnts ?fail) \n (Closed ?a ?b))\n (modify ?fct (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::ReaddFailureToCPV\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?c&:(not (member$ ?fail $?c))))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv)\n (Failures $?z))\n =>\n (modify ?fct (arguments ?cpv => $?failures))\n (modify-instance ?obj (Failures $?z ?fail)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::RetractEmptyReopenFact\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::AssertReopenBlocksOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?failures))\n =>\n (modify-instance ?obj (Failures))\n (modify ?fct (action reopen)\n (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen::ReopenBlockOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?a ?fail $?b)\n (contents $?cnts))\n ?bb <- (object (is-a BasicBlock) \n (id ?fail) \n (IsOpen FALSE))\n ?pa <- (object (is-a PathAggregate) \n (parent ?fail)\n (InstructionList $?il)\n (ImpossibleCompensationPathVectors $?icpv))\n =>\n (modify-instance ?bb (IsOpen TRUE))\n (bind ?qs (create$))\n (progn$ (?q ?icpv)\n (bind ?qObj (instance-address (symbol-to-instance-name ?q)))\n (bind ?qs (create$ ?qs (send ?qObj get-parent))))\n (modify-instance ?pa (ImpossibleCompensationPathVectors)\n (InstructionList $?il ?qs)\n (TargetCompensationPathVectors $?icpv))\n (modify-instance ?wave (contents $?cnts ?fail) \n (Closed ?a ?b))\n (modify ?fct (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::ReaddFailureToCPV\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?c&:(not (member$ ?fail $?c))))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv)\n (Failures $?z))\n =>\n (modify ?fct (arguments ?cpv => $?failures))\n (modify-instance ?obj (Failures $?z ?fail)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::RetractEmptyReopenFact\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"c0151d48180a4a747572f0e40e40c0b5187fe758","subject":"Used the modify command instead of a retract-assert combo in MergeRules.clp","message":"Used the modify command instead of a retract-assert combo in MergeRules.clp\n\nI realized that using the modify command allows me to retain the same memory\nspace while only changing the part that needs to be changed.\n\nI also modified the settify rules to completely settify one of the target\nmultislots if a single duplicate is found. This should reduce the number of\nexpensive matches overall.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/MergeRules.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-consume-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (action instruction-produce-list)\n\t\t\t\t\t (arguments ?id => ?a ?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?id => $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-consumes)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-consume-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-produces)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(modify ?f (action instruction-produce-list)\n\t\t\t\t\t (arguments ?b => ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target)))))\n\t\t\t (modify-instance ?inst (Consumers ?cons)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t (bind ?lds (create$ ?lds ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t (bind ?prods (create$ ?prods ?target)))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t;if we find one duplicate instance then just convert the whole thing\n\t\t\t;into a list\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Producers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (Consumers ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (LocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(bind ?mid (create$ ?b))\n\t\t\t(bind ?all (create$ ?a ?c ?d))\n\t\t\t(progn$ (?t ?all)\n\t\t\t (if (not (member$ ?t ?mid)) then\n\t\t\t\t\t\t (bind ?mid (insert$ ?mid (+ ?t-index 1) ?t))))\n\t\t\t(modify-instance ?inst (NonLocalDependencies ?mid)))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MergeRules.clp - Contains all of the merge rules used in the analysis stages\n; Written by Joshua Scoggins (11\/18\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => ?a ?b))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?a => ?id))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?b&~?a => ?id))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => ?a ?b))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a $?b))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Multi\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?b))\n\t\t\t(test (neq ?f0 ?f1))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?a $?b))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeConsumers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-consumes)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?b => ?a))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-merge::MergeProducers-Only\n\t\t\t(declare (salience -2))\n\t\t\t?f <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t(action instruction-produces)\n\t\t\t\t\t\t\t\t(arguments ?a => ?b))\n\t\t\t=>\n\t\t\t(retract ?f)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?b => ?a))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers-Producers-And-LocalDependencies\n\t\t\t\"Performs the actions of InjectConsumers and\n\t\t\tInjectProducersAndLocalDependencies in a single rule fire.\"\n\t\t\t(declare (salience 1))\n\t\t\t?f0 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t0))\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?t1))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?c) \n\t\t\t\t\t\t\t\t (Producers $?p) \n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?f0 ?f1)\n\t\t\t(bind ?cs $?c)\n\t\t\t(bind ?ps $?p)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?t0)\n\t\t\t\t\t\t (if (not (member$ ?target ?cs)) then\n\t\t\t\t\t\t\t(bind ?cs (insert$ ?cs 1 ?target))))\n\t\t\t (progn$ (?target ?t1)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?ps)) then\n\t\t\t\t\t\t\t(bind ?ps (insert$ ?ps 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cs) (Producers ?ps) \n\t\t\t\t\t\t\t\t\t (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectConsumers\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consume-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Consumers $?cs))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?cons $?cs)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?cons)) then\n\t\t\t\t\t\t\t(bind ?cons (insert$ ?cons 1 ?target))))\n\t\t\t (modify-instance ?inst (Consumers ?cons))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-inject::InjectProducersAndLocalDependencies\n\t\t\t\"Adds a given producer to the target instruction.\"\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produce-list)\n\t\t\t\t\t\t\t\t (arguments ?id => $?targets))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?id) \n\t\t\t\t\t\t\t\t (Producers $?ps)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ld))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(bind ?prods $?ps)\n\t\t\t(bind ?lds $?ld)\n\t\t\t(object-pattern-match-delay\n\t\t\t (progn$ (?target ?targets)\n\t\t\t\t\t\t (if (not (member$ ?target ?lds)) then\n\t\t\t\t\t\t\t(bind ?lds (insert$ ?lds 1 ?target)))\n\t\t\t\t\t\t (if (not (member$ ?target ?prods)) then\n\t\t\t\t\t\t\t(bind ?prods (insert$ ?prods 1 ?target))))\n\t\t\t (modify-instance ?inst (Producers ?prods) (LocalDependencies ?lds))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionProducers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Producers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(modify-instance ?inst (Producers $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyInstructionConsumers\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (Consumers $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(modify-instance ?inst (Consumers $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (LocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(modify-instance ?inst (LocalDependencies $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis-make-set::SetifyNonLocalDependencies\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (NonLocalDependencies $?a ?b $?c ?b $?d))\n\t\t\t=>\n\t\t\t(modify-instance ?inst (NonLocalDependencies $?a ?b $?c $?d)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"268ff0cd7bc28dff25edae32a023efe448d1ffef","subject":"","message":"\nMove the samples away from the main code branch for refactoring.\nKHK.\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1232 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"examples\/agent\/message.clp","new_file":"examples\/agent\/message.clp","new_contents":"(deftemplate agent-message\r\n (slot sender)\r\n (slot receivers)\r\n (multislot reply-to)\r\n (slot performative)\r\n (slot content)\r\n (slot language)\r\n (slot encoding)\r\n (slot ontology)\r\n (slot protocol)\r\n (slot conversation-id)\r\n (slot in-reply-to)\r\n (slot reply-with)\r\n (slot reply-by)\r\n (multislot user-properties)\r\n)\r\n\r\n(deftemplate agent-description\r\n (slot name)\r\n)\r\n\r\n(defrule incoming-message\r\n (agent-description\r\n (name ?receiver)\r\n )\r\n (agent-message\r\n (sender ?sender)\r\n (receivers ?receiver)\r\n (reply-to ?replyto)\r\n (performative ?performative)\r\n (content ?content)\r\n (language ?language)\r\n (encoding ?encoding)\r\n (ontology ?ontology)\r\n (protocol ?protocol)\r\n (conversation-id ?conversationid)\r\n (in-reply-to ?inreplyto)\r\n (reply-with ?replywith)\r\n (reply-by ?replyby)\r\n (user-properties ?userproperties)\r\n )\r\n =>\r\n (printout t ?receiver \" received a message\" crlf)\r\n (agent-send-message ?sender ?replyto ?performative ?content ?language ?encoding ?ontology ?protocol ?conversationid)\r\n)\r\n(assert (agent-description (name \"you\") ) )\r\n(assert (agent-message (sender \"me\")(receivers \"you\")(reply-to \"peter\" \"paul\" \"marry\")(performative \"yes\")(content \"hello\")(langauge \"en\")(encoding \"utf8\")(ontology \"none\")(protocol \"1\")(conversationid \"100\") ) )\r\n\r\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'examples\/agent\/message.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"dad1b21acb9e277dd27512d5c79de0e6d836b56c","subject":"cool things","message":"cool things\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"----------\" crlf \" Lunes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Martes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \"Miercoles\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Jueves\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Viernes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Sabado\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Domingo\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") (assert(preFitness -1000)) else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") (assert(preFitness -3000))else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") (assert(preFitness -2000)) else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") (assert(preFitness -1600))else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") (assert(preFitness -1200))else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") (assert(preFitness -700)) else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\") (assert(preFitness -300)) else (assert(preFitness 500)))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n (declare (salience 10))\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n ?ret <- (preFitness ?pre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness ?pre)\n (retract ?ret)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?lunes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes) (martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?martes))(not (member ?e ?lunes)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?martes))(not (member ?e2 ?lunes)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?martes))(not (member ?e3 ?lunes)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?miercoles))(not (member ?e ?martes)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 3 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?martes))(not (member ?e2 ?miercoles)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 3 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?martes))(not (member ?e3 ?miercoles)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?miercoles))(not (member ?e ?jueves)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 4 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?miercoles))(not (member ?e2 ?jueves)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 4 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?miercoles))(not (member ?e3 ?jueves)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?viernes))(not (member ?e ?jueves)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 5 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?viernes))(not (member ?e2 ?jueves)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 5 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?viernes))(not (member ?e3 ?jueves)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?viernes))(not (member ?e ?sabado)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 6 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?viernes))(not (member ?e2 ?sabado)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 6 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?viernes))(not (member ?e3 ?sabado)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(and (not (member ?e ?domingo))(not (member ?e ?sabado)))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 7 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(and (not (member ?e2 ?domingo))(not (member ?e2 ?sabado)))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 7 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(and (not (member ?e3 ?domingo))(not (member ?e3 ?sabado)))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -10))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"----------\" crlf \" Lunes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Martes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \"Miercoles\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Jueves\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Viernes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Sabado\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Domingo\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") (assert(preFitness -1000)) else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") (assert(preFitness -3000))else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") (assert(preFitness -2000)) else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") (assert(preFitness -1600))else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") (assert(preFitness -1200))else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") (assert(preFitness -700)) else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\") (assert(preFitness -300)) else (assert(preFitness 500)))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n (declare (salience 10))\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n ?ret <- (preFitness ?pre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness ?pre)\n (retract ?ret)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?lunes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?martes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 3 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 3 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?miercoles))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 4 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 4 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?jueves))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 5 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 5 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?viernes))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 6 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 6 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?sabado))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 7 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 7 ?tiempo_disponible)))))\n\t(not(ejercicio_tiempo (ejercicio ?e3&:(not (member ?e3 ?domingo))) (puntuacion ?p3&:(= ?p3 ?p)) (tiempo ?t3&:(< ?t3 ?t))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -10))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"2695fb4ba993ac04392820053706956f552e1ba7","subject":"update BeerEX.clp","message":"update BeerEX.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"BeerEX.clp","new_file":"BeerEX.clp","new_contents":"\n(load clips\/beerex.clp)\n\n(deffunction ask-question (?display ?allowed-values)\n (bind ?answer \"\")\n (while (not (member ?answer ?allowed-values))\n (if (not (member$ prev ?allowed-values))\n then (printout t crlf))\n (printout t \" \" ?display \" \" ?allowed-values \" \")\n (bind ?answer (readline))\n (if (eq (str-index \" \" ?answer) FALSE)\n then (bind ?answer (nth$ 1 (explode$ ?answer)))))\n ?answer)\n\n(deffunction next-UI-state ()\n (do-for-fact ((?s state-list)) TRUE (and (bind ?current-id ?s:current)\n (bind ?sequence ?s:sequence)))\n (do-for-fact ((?u UI-state)) (eq ?u:id ?current-id) (and (bind ?display ?u:display)\n (bind ?help ?u:help)\n (bind ?why ?u:why)\n (bind ?state ?u:state)\n (bind ?valid-answers ?u:valid-answers)))\n (if (eq ?state initial)\n then (assert (next ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?state middle)\n then (bind ?allowed-values ?valid-answers)\n (if (neq ?help nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) help)))\n (if (neq ?why nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) why)))\n (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) cancel))\n (if (> (length$ ?sequence) 2)\n then (bind ?allowed-values (insert$ ?allowed-values (length$ ?allowed-values) prev)))\n (bind ?answer (ask-question ?display ?allowed-values)))\n (if (eq ?state final)\n then (bind ?answer (ask-question ?display (create$ prev restart cancel))))\n (if (member$ ?answer ?valid-answers)\n then (assert (next ?current-id ?answer))\n (run)\n (next-UI-state))\n (if (eq ?answer help)\n then (printout t ?help crlf)\n (next-UI-state))\n (if (eq ?answer why)\n then (printout t ?why crlf)\n (next-UI-state))\n (if (eq ?answer prev)\n then (assert (prev ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?answer restart)\n then (reset)\n (run)\n (next-UI-state))\n (if (eq ?answer cancel)\n then (exit)))\n\n(reset)\n(run)\n\n(next-UI-state)\n","old_contents":"\n(load clips\/beerex.clp)\n\n(deffunction ask-question (?display ?allowed-values)\n (bind ?answer \"\")\n (while (not (member ?answer ?allowed-values))\n (printout t \" \"?display \" \" ?allowed-values \" \")\n (bind ?answer (readline))\n (if (eq (str-index \" \" ?answer) FALSE)\n then (bind ?answer (nth$ 1 (explode$ ?answer)))))\n ?answer)\n\n(deffunction next-UI-state ()\n (do-for-fact ((?s state-list)) TRUE (and (bind ?current-id ?s:current)\n (bind ?sequence ?s:sequence)))\n (do-for-fact ((?u UI-state)) (eq ?u:id ?current-id) (and (bind ?display ?u:display)\n (bind ?help ?u:help)\n (bind ?why ?u:why)\n (bind ?state ?u:state)\n (bind ?valid-answers ?u:valid-answers)))\n (if (eq ?state initial)\n then (assert (next ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?state middle)\n then (if (> (length$ ?sequence) 2)\n then (bind ?answer\n (ask-question ?display (insert$ ?valid-answers (+ (length$ ?valid-answers) 1) help why prev cancel)))\n else (bind ?answer\n (ask-question ?display (insert$ ?valid-answers (+ (length$ ?valid-answers) 1) help why cancel)))))\n (if (eq ?state final)\n then (bind ?answer (ask-question ?display (create$ prev restart cancel))))\n (if (member$ ?answer ?valid-answers)\n then (assert (next ?current-id ?answer))\n (run)\n (next-UI-state))\n (if (eq ?answer help)\n then (printout t ?help crlf)\n (next-UI-state))\n (if (eq ?answer why)\n then (printout t ?why crlf)\n (next-UI-state))\n (if (eq ?answer prev)\n then (assert (prev ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?answer restart)\n then (reset)\n (run)\n (next-UI-state))\n (if (eq ?answer cancel)\n then (exit)))\n\n(reset)\n(run)\n\n(next-UI-state)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"1cba76f0ff28d3f4dd7f77e7710373da1e85aa55","subject":"add track","message":"add track\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"frame.clp","new_file":"frame.clp","new_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2","old_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"2d16952bbc1884d60259e2cda1305821aaf66303","subject":"Imported more features from the old chicanery libs","message":"Imported more features from the old chicanery libs\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/chicanery.clp","new_file":"lib\/chicanery.clp","new_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n(defgeneric quickpoint)\n(defgeneric to-point)\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n\n(defmethod quickpoint\n ((?x INTEGER)\n (?y INTEGER))\n (new Point ?x ?y))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (= (length$ ?mf) 2)))\n (quickpoint (expand$ ?mf)))\n\n(defmethod to-point\n ((?mf INTEGER MULTIFIELD (> (length$ ?mf) 2)))\n (quickpoint (nth$ 1 ?mf)\n (nth$ 2 ?mf)))\n(defmethod to-point\n (($?mf INTEGER (>= (length$ ?mf) 2)))\n (to-point ?mf))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n\n(defgeneric quickrect)\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(defmethod quickrect\n ((?x INTEGER)\n (?y INTEGER)\n (?bx INTEGER)\n (?by INTEGER))\n (new Rectangle ?x ?y ?bx ?by))\n\n(defmethod quickrect\n ((?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect (expand$ (subseq$ ?mf 1 4))))\n\n(defmethod quickrect\n (($?mf MULTIFIELD INTEGER (>= (length$ ?mf) 4)))\n (quickrect ?mf))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n\n(defgeneric translate\/standard-color)\n(defgeneric intensity-to-cmap)\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defmethod translate\/standard-color\n ((?color LEXEME))\n (switch (lowcase (string-to-field ?color))\n (case opaque then 0)\n (case transparent then 1)\n (case black then 2)\n (case white then 3)\n (case red then 4)\n (case green then 5)\n (case blue then 6)\n (case cyan then 7)\n (case magenta then 8)\n (case yellow then 9)\n (case paleyellow then 10)\n (case darkyellow then 11)\n (case darkgreen then 12)\n (case palegreen then 13)\n (case medgreen then 14)\n (case darkblue then 15)\n (case palebluegreen then 16)\n (case paleblue then 17)\n (case bluegreen then 18)\n (case greygreen then 19)\n (case palegreygreen then 20)\n (case yellowgreen then 21)\n (case medblue then 22)\n (case greyblue then 23)\n (case palegreyblue then 24)\n (case purpleblue then 25)\n (case notacolor then 26)\n (case nofill then 27)\n (default 28)))\n\n(defmethod get-standard-color\n ((?color LEXEME INSTANCE-NAME))\n (get-standard-color \n (translate\/standard-color ?color)))\n\n(defmethod intensity-to-cmap\n \"Converts an intensity value to a greyscale color\"\n ((?intensity INTEGER (<= 0 ?intensity 255)))\n (rgb-to-cmap ?intensity\n ?intensity\n ?intensity))\n\n(defmethod rgb-to-cmap\n ((?tuple INTEGER MULTIFIELD (>= (length$ ?tuple) 3)))\n (rgb-to-cmap (nth$ 1 ?tuple)\n (nth$ 2 ?tuple)\n (nth$ 3 ?tuple)))\n\n(defclass image\n (is-a native-pointer)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (type INTEGER)\n (create-accessor read))\n (multislot buttons \n (type SYMBOL)\n (create-accessor read))\n (multislot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler query primary))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons\n (translate\/mouse\/buttons (mouse\/buttons)))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (bind ?self:keys (create$))\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:index 1)\n ?key)\n else\n (bind ?self:keys (create$ ?key)))\n (bind ?self:length (+ ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n\n","old_contents":"(defclass native-pointer\n (is-a USER)\n (role abstract)\n (slot pointer-class\n (type LEXEME)\n (visibility public)\n (access read-only)\n (default nil))\n (slot pointer\n (type EXTERNAL-ADDRESS)\n (storage local)\n (visibility public))\n (message-handler init around)\n (message-handler build-pointer primary)\n (message-handler get-native-arguments primary))\n\n(defmessage-handler native-pointer init around \n ()\n (call-next-handler)\n (send ?self build-pointer))\n\n(defmessage-handler native-pointer build-pointer primary\n ()\n (bind ?self:pointer\n (new (dynamic-get pointer-class)\n (expand$ (send ?self get-native-arguments)))))\n\n(defclass point\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Point))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler point get-native-arguments primary () \n (create$ ?self:x ?self:y))\n(definstances default-points\n (ZP of point\n (x 0)\n (y 0)))\n(defclass rectangle\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Rectangle))\n (slot x \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot y\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot bx \n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (slot by\n (type INTEGER)\n (range 0 ?VARIABLE)\n (visibility public)\n (storage local)\n (default ?NONE))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler rectangle get-native-arguments primary\n ()\n (create$ ?self:x ?self:y ?self:bx ?self:by))\n\n(definstances default-rectangle-types\n (pixel of rectangle\n (x 0)\n (y 0)\n (bx 1)\n (by 1)))\n(defclass color\n (is-a USER)\n (slot red\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot green\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (slot blue\n (type INTEGER)\n (range 0 255)\n (visibility public))\n (message-handler to-native-color primary))\n\n(defmessage-handler color to-native-color primary \n ()\n (rgb-to-cmap ?self:red\n ?self:green\n ?self:blue))\n(defclass image\n (is-a native-pointer)\n (slot pointer-class\n (source composite)\n (default Image))\n (slot rectangle\n (type INSTANCE)\n (allowed-classes rectangle)\n (storage local)\n (visibility public)\n (default ?NONE))\n (slot replicate\n (type SYMBOL)\n (allowed-symbols FALSE TRUE)\n (visibility public))\n (slot color\n (type INSTANCE INTEGER)\n (allowed-classes color)\n (storage local)\n (default-dynamic 0))\n (message-handler get-native-arguments primary))\n\n(defmessage-handler image get-native-arguments primary\n ()\n (create$ (send ?self:rectangle get-pointer)\n (if ?self:replicate then 1 else 0)\n (if (instancep ?self:color) then\n (send ?self:color to-native-color)\n else\n ?self:color)))\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?mask image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (send ?mask get-pointer)\n (send ?p get-pointer)))\n\n(defmethod screen\/draw\n ((?r rectangle)\n (?src image)\n (?p point))\n (screen\/draw (send ?r get-pointer)\n (send ?src get-pointer)\n (new Image)\n (send ?p get-pointer)))\n\n(defglobal MAIN\n ?*default-screen-flush-behavior* = TRUE)\n(defmethod screen\/flush\n ((?vis SYMBOL (not (neq ?vis TRUE FALSE))))\n (screen\/flush (if ?vis then 1 else 0)))\n\n(defmethod screen\/flush \n ()\n (screen\/flush ?*default-screen-flush-behavior*))\n\n(defmethod screen\/draw-text\n ((?p point)\n (?src image)\n (?sp point)\n (?str LEXEME))\n (screen\/draw-text (send ?p get-pointer)\n (send ?src get-pointer)\n (send ?sp get-pointer)\n ?str))\n\n(defgeneric translate\/kbd\/query)\n(defgeneric translate\/mouse\/buttons)\n(defgeneric bool)\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defmethod translate\/kbd\/query\n ()\n ; This method has to be defined by the programmer because it is application\n ; specific. By default, if we don't know what the value is then just return\n ; the original rune value.\n (bind ?rune (kbd\/query))\n (return (switch ?rune\n (case -1 then NIL)\n (case 0 then NIL)\n (case 27 then ESC)\n (case 61454 then UP)\n (case 63488 then DOWN) ; Plan9's down :\/\n (case 128 then DOWN) ; this is the value I get for down\n (case 61457 then LEFT)\n (case 61458 then RIGHT)\n (default ?rune))))\n(defclass mouse\n (is-a USER)\n (multislot position\n (type INTEGER)\n (create-accessor read))\n (multislot buttons \n (type SYMBOL)\n (create-accessor read))\n (multislot timestamp\n (type INTEGER)\n (create-accessor read))\n (message-handler query primary))\n\n(defmessage-handler mouse query primary\n ()\n (bind ?out (mouse\/query))\n (if ?out then\n (bind ?self:position (bind ?tmp (mouse\/position)))\n (bind ?self:buttons\n (translate\/mouse\/buttons (mouse\/buttons)))\n (bind ?self:timestamp (mouse\/timestamp)))\n (return ?out))\n(definstances mouse-object\n (mouse of mouse))\n\n(defclass keyboard\n (is-a USER)\n (multislot keys\n (type SYMBOL INTEGER)\n (create-accessor read))\n (slot length\n (type INTEGER)\n (create-accessor read))\n ; behavior slots\n ; should we append to the list of keys?\n (slot append-on-query\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n ; Should we attempt to convert from raw codes to symbols?\n (slot raw-keycodes\n (type SYMBOL)\n (allowed-symbols FALSE TRUE))\n (message-handler clear primary)\n (message-handler query primary))\n\n(defmessage-handler keyboard clear primary \n () \n (bind ?self:keys (create$))\n (bind ?self:length 0))\n\n(defmessage-handler keyboard query primary\n \"Get a key from the native runtime queue\"\n ()\n (bind ?key (if ?self:raw-keycodes then\n (kbd\/query)\n else\n (translate\/kbd\/query)))\n\n (if ?self:append-on-query then\n (slot-direct-insert$ keys \n (+ ?self:index 1)\n ?key)\n else\n (bind ?self:keys (create$ ?key)))\n (bind ?self:length (+ ?self:length 1))\n (return ?key))\n\n(definstances keyboard-interface\n (keyboard of keyboard))\n\n(defgeneric quickmenu)\n(defgeneric quickmenu\/show)\n(defgeneric translate-menu-id)\n(defclass menu\n (is-a native-pointer)\n (role concrete)\n (pattern-match reactive)\n (slot pointer-class\n (source composite)\n (default Menu))\n (multislot menu-entries \n (type LEXEME)\n (storage local)\n (visibility public)\n (default ?NONE))\n (message-handler get-native-arguments primary)\n (message-handler show-menu primary))\n\n(defmessage-handler menu get-native-arguments primary\n ()\n ?self:menu-entries)\n(defmessage-handler menu show-menu primary \n \"shows the target menu and translates it to the corresponding symbolic\n representation\"\n (?button)\n (translate-menu-id (menu\/show ?self:pointer ?button)\n ?self:menu-elements))\n\n(defmethod quickmenu\/show \n \"Construct a quick list and return a symbolic representation\"\n ((?elements MULTIFIELD LEXEME)\n (?button INTEGER))\n (translate-menu-id (menu\/show (quickmenu ?elements) ?button) ?elements))\n\n(defmethod quickmenu \n \"Defines a menu pointer without any associated object\"\n (($?entries LEXEME))\n (quickmenu ?entries))\n\n(defmethod quickmenu\n \"Defines a menu pointer without any associated object\"\n ((?entries MULTIFIELD LEXEME))\n (new menu (expand$ ?entries)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER (> ?id -1))\n (?elements MULTIFIELD LEXEME))\n ; We are one indexed while libevent is zero indexed\n (return (nth$ (+ ?id 1) ?elements)))\n\n(defmethod translate-menu-id\n \"Translates numeric input from menu\/show to symbolic representation\"\n ((?id INTEGER)\n ($?elements LEXEME))\n (translate-menu-id ?id ?elements))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"f9c6f0b83cee525ce8e60cb5b0c778785485d1a0","subject":"Fixed bugs in WavefrontPropagation.clp","message":"Fixed bugs in WavefrontPropagation.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n (\/ (length$ $?elements) 2) \n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?ip))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (modify-instance ?pa (InstructionPropagation $?ip ?targ ?alias ?z !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (Parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n (\/ (length$ $?elements) 2) \n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (Parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"06f40468e62213fabb31512613b5b78b2cb0fa92","subject":"Added SetExtensions.clp","message":"Added SetExtensions.clp\n\nIt contains a list of functions that are useful for set operations\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/SetExtensions.clp","new_file":"modules\/core\/SetExtensions.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; SetExtensions.clp - Contains set operations such as superset and equality\n;------------------------------------------------------------------------------\n(deffunction core::superset (?a ?b)\n\t\t\t\t (and (>= (length$ ?a) (length$ ?b))\n\t\t\t\t\t\t(subsetp ?b ?a) (not (subsetp ?a ?b))))\n;------------------------------------------------------------------------------\n(deffunction core::equal$ (?a ?b)\n\t\t\t\t (and \n\t\t\t\t\t(= (length$ ?a) (length$ ?b))\n\t\t\t\t\t(subsetp ?b ?a) \n\t\t\t\t\t(subsetp ?a ?b)))\n;------------------------------------------------------------------------------\n(deffunction core::has-common-element (?a ?b)\n\t\t\t\t (progn$ (?c ?a)\n\t\t\t\t\t\t\t(if (member$ ?c ?b) then (return TRUE)))\n\t\t\t\t (return FALSE))\n;------------------------------------------------------------------------------\n(deffunction core::disjoint (?a ?b)\n\t\t\t\t (not (has-common-element ?a ?b)))\n;------------------------------------------------------------------------------\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'modules\/core\/SetExtensions.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"f951d2a78e8da8d540175fa04b87583fcdc4d813","subject":"Deleted shell.clp","message":"Deleted shell.clp\n\nIt is no longer necessary in the new filesystem\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-filesystem","old_file":"logic\/shell.clp","new_file":"logic\/shell.clp","new_contents":"","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; shell.clp - starts up the electron shell with all libraries loaded\n;\n; This file has to be batched\n;------------------------------------------------------------------------------\n(load* (fs \/sys\/core\/message.clp))\n(load* (fs \/sys\/core\/strings.clp))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"675dfd8ae8e1d0020bb75199ddaf6c7fe4f86a4e","subject":"Added an example configuration file for srv\/interface","message":"Added an example configuration file for srv\/interface\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"conf\/srv\/interface.clp","new_file":"conf\/srv\/interface.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; \/conf\/srv\/interface.clp - example config file for an interface server\n;\n;------------------------------------------------------------------------------\n\n(deffacts interface\n (message (action declare-target-interface)\n (contents int0 (fs \/dev\/int0))))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'conf\/srv\/interface.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"554b3194c46d791cf43abf32167ee4cb70fda7e9","subject":"Formatting changes","message":"Formatting changes\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/main\/logic.clp","new_file":"lib\/durandal\/modules\/main\/logic.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012-2015, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule MAIN::run\n \"Starts the process of invoking a pass within clips. The fact asserted is \n generated by LLVM and passed into CLIPS automatically.\"\n ?fct <- (passes $?passes) \n =>\n (retract ?fct)\n (assert (message (from MAIN) \n (to pipeline)\n (action pass-description)\n (arguments $?passes)))\n (focus pipeline))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule MAIN::run\n \"Starts the process of invoking a pass within clips. The fact asserted is \n generated by LLVM and passed into CLIPS automatically.\"\n ?fct <- (passes $?passes) \n =>\n (retract ?fct)\n (assert (message (from MAIN) (to pipeline)\n\t\t\t (action pass-description)\n\t\t\t (arguments $?passes)))\n (focus pipeline))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"163d003f3c92aed5c8641a2bdd6b6c3622e6c836","subject":"Create task4.clp","message":"Create task4.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task4.clp","new_file":"ssu-ai-level-2\/chapter7\/task4.clp","new_contents":"(deffunction str-stars (?str ?n)\n (while (> ?n 0) do\n (bind ?str (str-cat ?str \"*\"))\n (bind ?n (- ?n 1))\n )\n ?str\n)\n\n(defrule str_start\n=>\n(bind ?str1 (read))\n(bind ?str2 (read))\n(if (> (str-length ?str1) (str-length ?str2)) then\n (bind ?diff (- (str-length ?str1) (str-length ?str2)))\n (printout t ?str1 crlf)\n (printout t (str-stars ?str2 ?diff) crlf)\nelse\n (bind ?diff (- (str-length ?str2) (str-length ?str1)))\n (printout t (str-stars ?str1 ?diff) crlf)\n (printout t ?str2 crlf)\n))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter7\/task4.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"767915739e5d9cd0fdca5a3eb4f1f2e473cc731e","subject":"two files changed for knowledge engineering class","message":"two files changed for knowledge engineering class\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"person.clp","new_file":"person.clp","new_contents":"(clear)\n\n(deftemplate person \"People in actuarial database\"\n (slot age)\n (slot name)\n (slot gender))\n\n\n(assert (person (name \"Bob Smith\") (age 34) (gender Male)))\n(assert (person (gender Male) (name \"Tom Smith\") (age 32) (gender Male)))\n(assert (person (name \"Mary Smith\") (age 34) (gender Female)))\n(assert (person (gender Female) (age 66)))\n\n(defglobal ?*count* = 0)\n(defglobal ?*agemin* = 1000)\n(defrule male-ages\n (person (name ?n) (age ?a) (gender Male) )\n =>\n (printout t ?n \" is \" ?a \" years old \" crlf))\n(defrule male-counted \n\t(person (gender Male))\n\t=>\n\t(bind ?*count* (+ 1 ?*count*))\n)\n\n(deffunction show-male-counted ()\n\t(printout t \"amount: \" ?*count* \" Males \"crlf)\n)\n(defrule youngest \n\t(person (age ?x))\n\t=>\n\t(if (< ?x ?*agemin*)\n\tthen\n\t(bind ?*agemin* ?x)\n\t)\n)\n\n(deffunction show-youngest ()\n\t(printout t \"youngest: \" ?*agemin* crlf)\n)\n(run)\n\n(show-male-counted)\n(show-youngest)","old_contents":"","returncode":1,"stderr":"error: pathspec 'person.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"b4531ef1a1d7d9b6b27f3373a385e9e38c44f1c7","subject":"Update task5.clp","message":"Update task5.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task5.clp","new_file":"ssu-ai-level-2\/chapter7\/task5.clp","new_contents":"(deffunction trim (?str)\n (bind ?str2 \"\")\n (bind ?space TRUE)\n (bind ?n (str-length ?str))\n (bind ?i 0)\n (while (<= ?i ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n\n (if (= 0 (str-compare ?c1 \" \")) then\n (if (and ?space TRUE) then\n (bind ?space FALSE)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n\n else\n\n (bind ?space TRUE)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n (bind ?i (+ ?i 1))\n )\n ?str2\n)\n","old_contents":"(deffunction trim (?str)\n (bind ?str2 \"\")\n (bind ?space True)\n (bind ?n (str-length ?str))\n (bind ?i 0)\n (while (< ?i ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n\n (if (= 0 (str-compare ?c1 \" \")) then\n (if (and (?space True)) then\n (printout t \"kefal\")\n (bind ?space False)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n\n else\n\n (bind ?space True)\n (bind ?str2 (str-cat ?str2 ?c1))\n )\n (bind ?i (+ ?i 1))\n )\n ?str2\n)\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"e248093365a83f8b8b95316ee0726776772c6d4f","subject":"Fixed another instance where is-registered is called instead of pass-registered","message":"Fixed another instance where is-registered is called instead of pass-registered\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (is-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5a4606dab932938a2c9d04f7b2fa0a70e3d93e7b","subject":"fixed a bug in WavefrontOperandRename when calling get-Pointer","message":"fixed a bug in WavefrontOperandRename when calling get-Pointer\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontOperandRename.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontOperandRename.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Now we need to rename operands as need be within the blocks that these\n; instructions have been scheduled into\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::AssertReplacementActions\n \"Iterates through the replacement actions multifield and asserts facts \n related to the replacement of given values with another value\"\n (declare (salience 100))\n (object (is-a PathAggregate) \n (parent ?e) \n (ReplacementActions $? ?orig ?new ! $?))\n =>\n ; I have turned you into a cheese sandwich, what do you say to that?\n (assert (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig \n with ?new \n block ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUses\n (declare (salience 20))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig\n with ?new\n block ?e))\n (object (is-a Instruction) \n (id ?orig) \n (pointer ?oPtr))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $? ?new $?rest))\n =>\n (bind ?ptrList (create$))\n (bind ?symList (create$))\n (bind ?i0 1)\n (progn$ (?var $?rest)\n (bind ?obj (instance-address * (symbol-to-instance-name ?var)))\n (bind ?oOps (send ?obj get-Operands))\n (if (member$ ?orig ?oOps) then\n (bind ?ptrTmp (send ?obj get-pointer))\n (bind ?ptrList (insert$ ?ptrList ?i0 ?ptrTmp))\n (bind ?symList (insert$ ?symList ?i0 ?var))\n (bind ?i0 (+ ?i0 1))))\n ;reuse ?fct's memory\n (modify ?fct (action replace-uses-clips)\n (arguments ?orig => ?new for ?symList))\n (assert (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?oPtr => ?nPtr for ?ptrList))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInLLVM\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?from => ?to for $?p2))\n =>\n (if (llvm-replace-uses ?from ?to ?p2) then \n (retract ?fct) \n else\n (printout t\n \"Some kind of error occured when trying to replace uses. \" \n crlf \"Make sure that you've done arguments correctly. \" \n crlf \"The failing rule is ReplaceUsesInLLVM.\" crlf\n \"?from = \" ?from crlf\n \"?to = \" ?to crlf\n \"?p2 = \" ?p2 crlf\n \"Now I'm halting execution\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ?from => ?to for ?symbol $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol) \n (Operands $?operands) \n (LocalDependencies $?locDep)\n (NonLocalDependencies $?nLocDep))\n =>\n (modify-instance ?inst (Operands) \n (LocalDependencies) \n (NonLocalDependencies))\n (modify ?fct (arguments ?from => ?to for $?rest))\n (assert (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?from => ?to\n replacement ?symbol\n operands $?operands))\n (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?locDep))\n (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?nLocDep))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS-End\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ? => ? for))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (modify-instance ?inst (LocalDependencies $?locDep ?curr))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (object-pattern-match-delay\n (modify-instance ?inst (LocalDependencies $?locDep ?to))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?curr))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?to))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?op&~?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?op))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?t))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Empty\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ? => ? \n replacement ?\n operands))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Now we need to rename operands as need be within the blocks that these\n; instructions have been scheduled into\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::AssertReplacementActions\n \"Iterates through the replacement actions multifield and asserts facts \n related to the replacement of given values with another value\"\n (declare (salience 100))\n (object (is-a PathAggregate) \n (parent ?e) \n (ReplacementActions $? ?orig ?new ! $?))\n =>\n ; I have turned you into a cheese sandwich, what do you say to that?\n (assert (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig \n with ?new \n block ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUses\n (declare (salience 20))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses)\n (arguments of ?orig\n with ?new\n block ?e))\n (object (is-a Instruction) \n (id ?orig) \n (pointer ?oPtr))\n (object (is-a Instruction) \n (id ?new) \n (pointer ?nPtr))\n (object (is-a BasicBlock) \n (id ?e) \n (contents $? ?new $?rest))\n =>\n (bind ?ptrList (create$))\n (bind ?symList (create$))\n (bind ?i0 1)\n (progn$ (?var $?rest)\n (bind ?obj (instance-address * (symbol-to-instance-name ?var)))\n (bind ?oOps (send ?obj get-Operands))\n (if (member$ ?orig ?oOps) then\n (bind ?ptrTmp (send ?obj get-Pointer))\n (bind ?ptrList (insert$ ?ptrList ?i0 ?ptrTmp))\n (bind ?symList (insert$ ?symList ?i0 ?var))\n (bind ?i0 (+ ?i0 1))))\n ;reuse ?fct's memory\n (modify ?fct (action replace-uses-clips)\n (arguments ?orig => ?new for ?symList))\n (assert (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?oPtr => ?nPtr for ?ptrList))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInLLVM\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-llvm)\n (arguments ?from => ?to for $?p2))\n =>\n (if (llvm-replace-uses ?from ?to ?p2) then \n (retract ?fct) \n else\n (printout t\n \"Some kind of error occured when trying to replace uses. \" \n crlf \"Make sure that you've done arguments correctly. \" \n crlf \"The failing rule is ReplaceUsesInLLVM.\" crlf\n \"?from = \" ?from crlf\n \"?to = \" ?to crlf\n \"?p2 = \" ?p2 crlf\n \"Now I'm halting execution\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ?from => ?to for ?symbol $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol) \n (Operands $?operands) \n (LocalDependencies $?locDep)\n (NonLocalDependencies $?nLocDep))\n =>\n (modify-instance ?inst (Operands) \n (LocalDependencies) \n (NonLocalDependencies))\n (modify ?fct (arguments ?from => ?to for $?rest))\n (assert (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?from => ?to\n replacement ?symbol\n operands $?operands))\n (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?locDep))\n (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to \n in ?symbol\n contents $?nLocDep))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceUsesInCLIPS-End\n (declare (salience -1))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-uses-clips)\n (arguments ? => ? for))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (modify-instance ?inst (LocalDependencies $?locDep ?curr))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (LocalDependencies $?locDep))\n =>\n (object-pattern-match-delay\n (modify-instance ?inst (LocalDependencies $?locDep ?to))\n (modify ?fct (arguments ?from => ?to \n in ?symbol \n contents $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?curr&~?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?curr))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualNonLocalDependencyEntries-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-non-local-dependencies)\n (arguments ?from => ?to\n in ?symbol\n contents ?from $?rest))\n ?inst <- (object (is-a Instruction) \n (id ?symbol)\n (NonLocalDependencies $?nld))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?to))\n (modify ?fct (arguments ?from => ?to\n in ?symbol\n contents $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-NoMatch\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?op&~?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?op))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Match\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ?f => ?t \n replacement ?s\n operands ?f $?ops))\n ?inst <- (object (is-a Instruction) \n (id ?s)\n (Operands $?operands))\n =>\n (modify-instance ?inst (Operands $?operands ?t))\n (modify ?fct (arguments ?f => ?t \n replacement ?s\n operands $?ops)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-rename::ReplaceIndividualInstructionUses-Empty\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action replace-operands)\n (arguments ? => ? \n replacement ?\n operands))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"390af5d8f3ba83247f251963fab524a4c8270ac4","subject":"rendomly changed","message":"rendomly changed\n","repos":"krnan9525\/CC-Class3,krnan9525\/CC-Class3,krnan9525\/CC-Class3","old_file":"frame.clp","new_file":"frame.clp","new_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2\n;;howareyougit \n;;sadasdh\n;asdhasdhoas;shdklfjhsdjk","old_contents":"; -*- clips -*-\n\n;; **********************************************************************\n;; Frame.clp\n;;\n;; A nifty example of building a a Swing GUI using jess reflection.\n;; Using this package, we can create java objects, call their methods,\n;; access their fields, and respond to GUI events.\n;; You can therefore build an entire GUI application without actually\n;; writing any Java code!\n;;\n;; **********************************************************************\n\n;; ******************************\n;; Declarations\n\n(import javax.swing.*)\n;; Explicit import so we get JFrame.EXIT_ON_CLOSE\n(import javax.swing.JFrame) \n(import java.awt.event.ActionListener)\n(import java.awt.BorderLayout)\n(import java.awt.Color)\n\n;; ******************************\n;; DEFGLOBALS\n\n(defglobal ?*f* = 0)\n(defglobal ?*c* = 0)\n(defglobal ?*d* = 0)\n(defglobal ?*e* = 0)\n\n(defglobal ?*m* = 0)\n(defglobal ?*envi* = 0)\n\n;; ******************************\n;; DEFFUNCTIONS\n\n(deffunction create-frame ()\n (bind ?*f* (new JFrame \"Jess Reflection Demo\"))\n (bind ?*c* (?*f* getContentPane)) \n (set ?*c* background (Color.magenta)))\n\n\n(deffunction add-widgets ()\n (?*c* add (new JLabel \"This is: \") (BorderLayout.CENTER))\n (bind ?*m* (new JComboBox))\n (bind ?*d* (new JComboBox))\n (bind ?*e* (new JComboBox))\n (?*m* addItem \"paper\")\n (?*m* addItem \"tools\")\n (?*m* addItem \"buildings\")\n (?*m* addItem \"numbers\")\n (?*c* add ?*m* (BorderLayout.SOUTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*)) \n (?*e* addItem \"paper\")\n (?*e* addItem \"tools\")\n (?*e* addItem \"buildings\")\n (?*e* addItem \"numbers\")\n (?*c* add ?*e* (BorderLayout.NORTH))\n (bind ?*envi* ?*m* selectedItem)\n (assert (environment ?*envi*))\n (?*d* addItem \"paper\")\n (?*d* addItem \"tools\")\n (?*d* addItem \"buildings\")\n (?*d* addItem \"numbers\")\n (?*c* add ?*d* )\n (bind ?*envi* ?*d* selectedItem )\n (assert (environment ?*envi*)))\n\n\n(deffunction add-behaviours ()\n (?*f* setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE))\n \n (?*m* addActionListener (implement ActionListener using\n (lambda (?name ?event)\n (printout t \"You chose: \" (get ?*m* selectedItem) crlf)))))\n\n(deffunction show-frame ()\n ;(?*f* pack)\n (?*f* setSize 200 300)\n (?*f* setVisible TRUE))\n\n\n;; ******************************\n;; Run the program\n\n(defrule init-rule\n (initial-fact)\n =>\n (create-frame)\n (add-widgets)\n (add-behaviours)\n (show-frame))\n\n(reset)\n(run)\n\n;;test now 2\n;;howareyougit ","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9552fc6bc6cf5eb09fcbdb2915ec8ec278aecb48","subject":"added functions to help compute unix permissions","message":"added functions to help compute unix permissions\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"sys\/os\/unix\/permissions.clp","new_file":"sys\/os\/unix\/permissions.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; permissions.clp - provides functions to compute unix file permissions\n;------------------------------------------------------------------------------\n\n;------------------------------------------------------------------------------\n; Make umask, mkdir, and mkfifo a little less raw to work with\n;------------------------------------------------------------------------------\n(defgeneric compute-perms)\n;------------------------------------------------------------------------------\n(defmethod compute-perms\n ((?self INTEGER (and (>= ?self 0)\n (< ?self 8)))\n (?group INTEGER (and (>= ?group 0)\n (< ?group 8)))\n (?all INTEGER (and (>= ?all 0)\n (< ?all 8))))\n (binary-or (left-shift ?self 6) \n (binary-or (left-shift ?group 3)\n ?all)))\n(defmethod compute-perms \n ((?self SYMBOL)\n (?group SYMBOL)\n (?all SYMBOL))\n (compute-perms (compute-perms ?self)\n (compute-perms ?group)\n (compute-perms ?all)))\n\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set r))) 4)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set w))) 2)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set x))) 1)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rwx))) 7)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rw))) 6)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rx))) 5)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set wx))) 3)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'sys\/os\/unix\/permissions.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4151a9d04649484f7abaf20deb570ca63ce47edd","subject":"Deleted \/sys\/os\/unix\/permissions.clp","message":"Deleted \/sys\/os\/unix\/permissions.clp\n\nThis is a little too much os specific functionality for my tastes\n","repos":"DrItanium\/electron-filesystem,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"sys\/os\/unix\/permissions.clp","new_file":"sys\/os\/unix\/permissions.clp","new_contents":"","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; permissions.clp - provides functions to compute unix file permissions\n;------------------------------------------------------------------------------\n\n;------------------------------------------------------------------------------\n; Make umask, mkdir, and mkfifo a little less raw to work with\n;------------------------------------------------------------------------------\n(defgeneric compute-perms)\n;------------------------------------------------------------------------------\n(defmethod compute-perms\n ((?self INTEGER (and (>= ?self 0)\n (< ?self 8)))\n (?group INTEGER (and (>= ?group 0)\n (< ?group 8)))\n (?all INTEGER (and (>= ?all 0)\n (< ?all 8))))\n (binary-or (left-shift ?self 6) \n (binary-or (left-shift ?group 3)\n ?all)))\n(defmethod compute-perms \n ((?self SYMBOL)\n (?group SYMBOL)\n (?all SYMBOL))\n (compute-perms (compute-perms ?self)\n (compute-perms ?group)\n (compute-perms ?all)))\n\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set r))) 4)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set w))) 2)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set x))) 1)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rwx))) 7)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rw))) 6)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set rx))) 5)\n(defmethod compute-perms\n ((?set SYMBOL (eq ?set wx))) 3)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"37b1282c5b448399bea5b2412b2a8c53898181a6","subject":"Fixed a bug with incorrect parents for paths starting with regions","message":"Fixed a bug with incorrect parents for paths starting with regions\n\nI used the parent of the basic block that was not directly owned by the region\nbeing pathed. This has been changed to the name of the region itself (?id)\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/conditional\/PathConstruction.clp","new_file":"lib\/durandal\/passes\/path\/conditional\/PathConstruction.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-region\n (declare (salience 3))\n (message (to paths-conditional)\n (action build-path))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?) \n (contents $? ?z $?))\n (object (is-a Region&~Loop) \n (id ?z) \n (parent ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n&~?id))\n =>\n (retract ?fct)\n (make-instance of Path \n (parent ?id) \n (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-basicblock\n (declare (salience 3))\n (message (to paths-conditional)\n (action build-path))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n))\n =>\n (retract ?fct)\n (make-instance of Path \n (parent ?n) \n (values ?a)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-region\n (declare (salience 3))\n (message (to paths-conditional)\n (action build-path))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?) \n (contents $? ?z $?))\n (object (is-a Region) \n (id ?z) \n (parent ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n&~?id))\n =>\n (retract ?fct)\n (make-instance of Path \n (parent ?n) \n (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths-conditional::initialize-path-construction-basicblock\n (declare (salience 3))\n (message (to paths-conditional)\n (action build-path))\n ?fct <- (message (to paths-conditional)\n (action valid-pathing-target)\n (arguments ?id))\n ?r0 <- (object (is-a Region) \n (id ?id) \n (Entrances $? ?a $?))\n (object (is-a BasicBlock) \n (id ?a) \n (parent ?n))\n =>\n (retract ?fct)\n (make-instance of Path \n (parent ?n) \n (values ?a)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"af6bb4c63eed639ede100734fafacab488541a27","subject":"Create task4.clp","message":"Create task4.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task4.clp","new_file":"ssu-ai-level-2\/chapter5\/task4.clp","new_contents":"(defrule easy_summ\n =>\n (printout t \"n=\")\n (bind ?n (read))\n (bind ?s 0)\n (bind ?i 2)\n (while (<= ?i (* 2 ?n)) do\n (bind ?s (+ ?s (\/ 1 (* ?i ?i))))\n (bind ?i (+ ?i 2))\n )\n (printout t \"summ is:\")\n (printout t ?s)\n (printout t \"\")\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task4.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"6ae7d1dfaf8dd4ecc09beb44ab00d775e086d8da","subject":"WidgetElement.clp: Added slots for children, width, and height","message":"WidgetElement.clp: Added slots for children, width, and height\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/lib\/widget\/WidgetElement.clp","new_file":"src\/lib\/widget\/WidgetElement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER))\n (multislot children (type SYMBOL))\n (slot width (type NUMBER))\n (slot height (type NUMBER))\n (message-handler raise-event primary))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"71198d1144d93b0d50b22cfcc04ca65b26b3d137","subject":"Changed the module for the Path type to be types::Path","message":"Changed the module for the Path type to be types::Path\n\nThe use of the generic types module allows one to define types that are meant\nto be exposed globally.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/Path.clp","new_file":"lib\/durandal\/passes\/path\/Path.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n(defclass types::Path \n (is-a ParentedHint)\n (slot Exit (type SYMBOL))\n (slot Closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::Path init after\n ()\n (bind ?self:Type Path))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Path.clp - Contains the definition of the pass class\n;------------------------------------------------------------------------------\n(defclass path::Path \n (is-a ParentedHint)\n (slot Exit (type SYMBOL))\n (slot Closed (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defmessage-handler path::Path init after\n ()\n (bind ?self:Type Path))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2e35412d25502f70fdd11e19e56e6b748b9eacdd","subject":"reset-run-exit now uses the 2 clause BSD license","message":"reset-run-exit now uses the 2 clause BSD license\n","repos":"DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"lib\/sys\/chunks\/reset-run-exit.clp","new_file":"lib\/sys\/chunks\/reset-run-exit.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; reset-run-exit.clp - Calls reset, run, and then exits. This is useful for \n; expert systems that are meant to run and then exit\n; \n; Obviously, this prevent shell access.\n;------------------------------------------------------------------------------\n(reset)\n(run)\n(exit)\n","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; reset-run-exit.clp - Calls reset, run, and then exits. This is useful for \n; expert systems that are meant to run and then exit\n; \n; Obviously, this prevent shell access.\n;------------------------------------------------------------------------------\n(reset)\n(run)\n(exit)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"0e10e05b4a005d020dc01a1487b1b44030d98c4c","subject":"Added a type field to file-line","message":"Added a type field to file-line\n\nI added a rule as well to mark lines that are group headings\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-blank-lines\n ?f <- (file-line (contents))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (contents \/* $? *\/) (type UNKNOWN))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-blank-lines\n ?f <- (file-line (contents))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"2e9cbcf0e68d12eb5e121e040966225e46668476","subject":"WidgetElement.clp: Added x and y slot positions to describe location","message":"WidgetElement.clp: Added x and y slot positions to describe location\n","repos":"DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/lib\/widget\/WidgetElement.clp","new_file":"src\/lib\/widget\/WidgetElement.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object)\n (slot position-x (type NUMBER))\n (slot position-y (type NUMBER)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; WidgetElement.clp - Base class of all widgets \n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n(defclass widget::WidgetElement \n \"Base class of all widgets in the adventure engine\"\n (is-a Object))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"af3afe57bdd4765e0e09047acdab5d4413e6331b","subject":"Deleted references to lobe and dendrite from LoadEngine.clp","message":"Deleted references to lobe and dendrite from LoadEngine.clp\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron","old_file":"LoadEngine.clp","new_file":"LoadEngine.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(initialize-adventure-engine)\n;------------------------------------------------------------------------------\n(load-library cortex)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LoadEngine.clp - Runs the GLConstantConversion expert system\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(initialize-adventure-engine)\n;------------------------------------------------------------------------------\n(load-library cortex)\n(load-library dendrite)\n(load-library lobe)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"e29195dc5fc98723bd212bc40382db2cfb8f3666","subject":"Modified GLAPIConversion.clp to maintain an arg index in an unordered fashion","message":"Modified GLAPIConversion.clp to maintain an arg index in an unordered fashion\n\nBy using the number of preceeding commas + 1 it is possible to figure out the\nposition of a given argument without having to maintain state that would be\ndifficult to keep correct. The tradeoff is a linear count of the number of\ncommas for each argument on each call. This tradeoff only makes the code a\nlittle less efficient while making it far easier to maintain.\n","repos":"DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t ; this is going backwards, we defer the index field\n\t\t\t\t\t\t\t\t ; by setting it as an offset of the length, which we\n\t\t\t\t\t\t\t\t ; don't know until we actually generate these\n\t\t\t\t\t\t\t\t ; arguments.\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?sentry))\n\t\t\t;we use the number of commas before plus 1 to determine index\n\t\t\t(bind ?index (+ (count-commas ?sentry) 1))\n\t\t\t;the problem is determining the direction to spit out an argument in\n\t\t\t;I don't want to assume backwards or forwards to tell the truth. So\n\t\t\t;that means that we just mark $?rest with the target index and move on\n\t\t\t;\n\t\t\t;This method is technically out of order due to the use of the , as a\n\t\t\t;fix point\n\t\t\t(duplicate ?fct (action build-argument)\n\t\t\t (arguments ?o ?index => $?rest)))\n;------------------------------------------------------------------------------\n(defrule build-groups::create-last-argument\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t=>\n\t\t\t;The last element doesn't contain any commas and thus must be zero \n\t\t\t(modify ?fct (action build-argument)\n\t\t\t (arguments ?o 0 => $?all)))\n;------------------------------------------------------------------------------\n(defrule build-groups::retract-empty-parse-message\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n;(defrule build-groups::argument-is-fixed-array\n;\t\t\t(declare (salience 1))\n;\t\t\t?fct <- (message (to build-groups)\n;\t\t\t\t\t\t\t\t (action build-argument)\n;\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?field \"[\" ?size \"]\"))\n;\t\t\t=>\n;\t\t\t(modify ?fct (to grouping-update)\n;\t\t\t\t\t (action populate-argument)\n;\t\t\t\t\t (arguments ?name => $?field))\n;\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n;\t\t\t\t\t\t\t\t(parent ?o)\n;\t\t\t\t\t\t\t\t(array-size ?size)\n;\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n;(defrule build-groups::argument-is-generic\n;\t\t\t?fct <- (message (to build-groups)\n;\t\t\t\t\t\t\t\t (action build-argument)\n;\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?input))\n;\t\t\t=>\n;\t\t\t(modify ?fct (to grouping-update)\n;\t\t\t\t\t (action populate-argument)\n;\t\t\t\t\t (arguments ?name => $?input))\n;\t\t\t(make-instance ?name of GLAPIArgument\n;\t\t\t\t\t\t\t\t(parent ?o)\n;\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t ; this is going backwards\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(bind ?ind (send ?obj add-argument ?name))\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(duplicate ?fct (action build-argument)\n\t\t\t\t\t\t (arguments ?o ?name ?ind => $?sentry)))\n;------------------------------------------------------------------------------\n(defrule build-groups::create-last-argument\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(bind ?ind (send ?obj add-argument ?name))\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?name ?ind => $?all)))\n;------------------------------------------------------------------------------\n(defrule build-groups::retract-empty-parse-message\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?input))\n\t\t\t=>\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4fafcc47491d28dbeca0f7f6092c448ff5e53252","subject":"Added is-macro to the Pass class","message":"Added is-macro to the Pass class\n\nis-macro allows the pipeline to replace the given pass name with a set of\nsubpasses. This replacement will only occur once a given element is the first\nelement of the list of passes left to execute.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n ; this slot will allow us to expand passes that consist of multiple modules\n ; before changing focus to that module. This can be set to false even if\n ; there are submodules so that the programmer can control the process\n ; themselves. This is a convience feature more than anything else.\n (slot is-macro (type SYMBOL) (allowed-symbols FALSE TRUE))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (> (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (> (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5c2bd40b65d1194d70011a0a2f9abda40aaaf999","subject":"+ Added JDBC link snippet for testing","message":"+ Added JDBC link snippet for testing\n\nTim\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@700 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/jdbclink.clp","new_file":"samples\/jdbclink.clp","new_contents":"(deftemplate jdbc_test (slot id) (slot test_fact))\n(assert\n (jdbclink\n (ConnectionName \"testcon\")\n (TableName \"jamocha_facts\")\n (TemplateName \"jdbc_test\")\n (Username \"tim\")\n (Password \"jamocha\")\n (JDBCurl \"jdbc:postgresql:\/\/localhost:5432\/tim\")\n (JDBCdriver \"org.postgresql.Driver\")\n )\n)\n(jdbclink 2 \"import\" \"foo\")\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'samples\/jdbclink.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"d7d11135fdde43eeaf833b1bf6bbcc085e36a630","subject":"Updated lib\/durandal\/Init.clp","message":"Updated lib\/durandal\/Init.clp\n\nThe contents of the Init.clp file now also reference the pass registry as well\nas defining the main module\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/Init.clp","new_file":"lib\/durandal\/Init.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t\t\t \"modules\/llvm\/ModuleHeader.clp\"\n\t\t\t \"modules\/rampancy\/ModuleHeader.clp\"\n\t\t\t \"modules\/indirect\/ModuleHeader.clp\"\n\t\t\t \"modules\/types\/ModuleHeader.clp\"\n\t\t\t \"modules\/pipeline\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t \"passes\/PassRegistry.clp\"\n\t\t\t ))\n\n(defmodule MAIN \n\t\t\t (import core ?ALL) \n\t\t\t (import llvm ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (export ?ALL))\n\n(reset)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Init.clp - Default Entry Point for a expert system optimization\n;------------------------------------------------------------------------------\n; Usually this only contains elements necessary to start the load process\n; With the modifications I made to CLIPS for LLVM this usually manifests \n; itself as being a batch-load command which allows multiple loads to occur as \n; a single command\n;------------------------------------------------------------------------------\n(batch-load \n (create$ \"modules\/core\/ModuleHeader.clp\"\n\t \"modules\/llvm\/ModuleHeader.clp\"\n \t \"modules\/rampancy\/ModuleHeader.clp\"\n\t\t\t \"modules\/indirect\/ModuleHeader.clp\"\n\t\t\t \"modules\/types\/ModuleHeader.clp\"\n\t\t\t \"modules\/pipeline\/ModuleHeader.clp\"\n\t\t\t ; Add entries to other modules here\n\t\t\t ))\n;(defmodule MAIN (import core ?ALL) (import llvm ?ALL))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"391b8440951a18fbb1a914bb5f70547993ee3620","subject":"Finished WavefrontBlockReopen.clp porting.","message":"Finished WavefrontBlockReopen.clp porting.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontBlockReopen.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontBlockReopen.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::AssertReopenBlocksOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (Failures $?failures))\n =>\n (modify-instance ?obj (Failures))\n (modify ?fct (action reopen)\n (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen::ReopenBlockOnWavefront\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?a ?fail $?b)\n (contents $?cnts))\n ?bb <- (object (is-a BasicBlock) \n (id ?fail) \n (IsOpen FALSE))\n ?pa <- (object (is-a PathAggregate) \n (parent ?fail)\n (InstructionList $?il)\n (ImpossibleCompensationPathVectors $?icpv))\n =>\n (modify-instance ?bb (IsOpen TRUE))\n (bind ?qs (create$))\n (progn$ (?q ?icpv)\n (bind ?qObj (instance-address (symbol-to-instance-name ?q)))\n (bind ?qs (create$ ?qs (send ?qObj get-parent))))\n (modify-instance ?pa (ImpossibleCompensationPathVectors)\n (InstructionList $?il ?qs)\n (TargetCompensationPathVectors $?icpv))\n (modify-instance ?wave (contents $?cnts ?fail) \n (Closed ?a ?b))\n (modify ?fct (arguments ?cpv => $?failures)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::ReaddFailureToCPV\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ?cpv => ?fail $?failures))\n ?wave <- (object (is-a Wavefront) \n (Closed $?c&:(not (member$ ?fail $?c))))\n ?obj <- (object (is-a CompensationPathVector) \n (id ?cpv)\n (Failures $?z))\n =>\n (modify ?fct (arguments ?cpv => $?failures))\n (modify-instance ?obj (Failures $?z ?fail)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-reopen-blocks::RetractEmptyReopenFact\n ?fct <- (message (to wavefront-scheduling)\n (action reopen)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule AssertReopenBlocksOnWavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage ReopenBlocks $?)\n\t\t\t?fct <- (Reopen blocks from ?cpv)\n\t\t\t?obj <- (object (is-a CompensationPathVector) (ID ?cpv) \n\t\t\t\t\t\t\t\t (Failures $?failures))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (Failures))\n\t\t\t(assert (From ?cpv reopen $?failures)))\n;------------------------------------------------------------------------------\n(defrule ReopenBlockOnWavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage ReopenBlocks $?)\n\t\t\t?fct <- (From ?cpv reopen ?fail $?failures)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?w) (Closed $?a ?fail $?b)\n\t\t\t\t\t\t\t\t (Contents $?cnts))\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?fail) (IsOpen FALSE))\n\t\t\t?pa <- (object (is-a PathAggregate) (Parent ?fail)\n\t\t\t\t\t\t\t\t(ImpossibleCompensationPathVectors $?icpv))\n\t\t\t=>\n\t\t\t(modify-instance ?bb (IsOpen TRUE))\n\t\t\t(modify-instance ?pa (ImpossibleCompensationPathVectors)\n\t\t\t\t\t\t\t\t (TargetCompensationPathVectors $?icpv))\n\t\t\t(progn$ (?q ?icpv)\n\t\t\t\t\t (slot-insert$ ?pa InstructionList 1 \n\t\t\t\t\t\t\t\t\t\t (send (symbol-to-instance-name ?q) get-Parent)))\n\t\t\t(modify-instance ?wave (Contents $?cnts ?fail) (Closed ?a ?b))\n\t\t\t(retract ?fct)\n\t\t\t(assert (From ?cpv reopen $?failures)))\n;------------------------------------------------------------------------------\n(defrule ReaddFailureToCPV\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage ReopenBlocks $?)\n\t\t\t?fct <- (From ?cpv reopen ?fail $?failures)\n\t\t\t?wave <- (object (is-a Wavefront) (ID ?w) (Closed $?c))\n\t\t\t(test (not (member$ ?fail $?c)))\n\t\t\t?obj <- (object (is-a CompensationPathVector) (ID ?cpv))\n\t\t\t=>\n\t\t\t(slot-insert$ ?obj Failures 1 ?fail)\n\t\t\t(retract ?fct)\n\t\t\t(assert (From ?cpv reopen $?failures)))\n;------------------------------------------------------------------------------\n(defrule RetractEmptyReopenFact\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage ReopenBlocks $?)\n\t\t\t?fct <- (From ? reopen)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"45f87618b715d805d998aed60d3b0be441132498","subject":"Fixed a typo in the visibility fields in Object.clp","message":"Fixed a typo in the visibility fields in Object.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"modules\/core\/Object.clp","new_file":"modules\/core\/Object.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Base class of all objects \n;------------------------------------------------------------------------------\n(defclass core::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visibility public) (access initialize-only))\n (slot class (type SYMBOL) (visibility public) (access initialize-only)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Object init around \n\t\t\t\t\t\t \"Initializes the object, setting the id and class of the \n\t\t\t\t\t\t object\" ()\n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;we want to set this information as the last thing before \n\t\t\t\t\t\t ;we return \n\t\t\t\t\t\t (bind ?self:id (instance-name-to-symbol \n\t\t\t\t\t\t\t\t\t\t\t\t (instance-name ?self)))\n\t\t\t\t\t\t (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Object.clp - Base class of all objects \n;------------------------------------------------------------------------------\n(defclass core::Object \n \"Base class of all objects\"\n (is-a USER)\n (slot id (type SYMBOL) (visiblity public) (access initialize-only))\n (slot class (type SYMBOL) (visiblity public) (access initialize-only)))\n;------------------------------------------------------------------------------\n(defmessage-handler core::Object init around \n\t\t\t\t\t\t \"Initializes the object, setting the id and class of the \n\t\t\t\t\t\t object\" ()\n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;we want to set this information as the last thing before \n\t\t\t\t\t\t ;we return \n\t\t\t\t\t\t (bind ?self:id (instance-name-to-symbol \n\t\t\t\t\t\t\t\t\t\t\t\t (instance-name ?self)))\n\t\t\t\t\t\t (bind ?self:class (class ?self)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"12dd1726a1dec0731e42310059d7edd604cf8394","subject":"Fixed a bug where instances of scan path were not be retracted when finished","message":"Fixed a bug where instances of scan path were not be retracted when finished\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/ValidBlockIdentification.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) \n (id ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) \n (id ?path) \n (values $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?path ?block => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n;defmodule is wavefront-scheduling-identify\n(defrule wavefront-scheduling-identify::AssertIdentifySpansInitial\n (declare (salience 5))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ;select only BasicBlocks\n (object (is-a BasicBlock) \n (id ?e))\n =>\n (assert (Picked ?e for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpanSkips-InvalidBlock\n (declare (salience 4))\n ?fct <- (Picked ?e for ?r)\n ?bb <- (object (is-a BasicBlock) \n (id ?e) \n (Successors $?a&:(not (eq (length$ $?a) 1))))\n =>\n ;we don't need to assert anything since the block isn't going to get\n ;scheduled\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::IdentifySpans\n (declare (salience 4))\n ?fct <- (Picked ?block for ?)\n ?bb <- (object (is-a BasicBlock) \n (id ?block) \n (Successors ?) ; we only have one successor\n (Paths $?paths))\n =>\n (retract ?fct)\n (modify-instance ?bb (IsOpen TRUE))\n ; originally I had a rule here that took a fact asserted in the form\n ; ?e => $?paths which would be inverted individually by separate rule\n ; fires. While this is more like an expert system, it is extremely\n ; inefficient because the agenda has to be updated after each rule\n ; fire. Using this technique allows me to minimize the number of rule\n ; fires to one yet do the same amount of work.\n (progn$ (?path $?paths)\n (assert (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block)))))\n;------------------------------------------------------------------------------\n; defmodule is wavefront-scheduling-pathing\n(defrule wavefront-scheduling-pathing::GetFactsBeforePathing\n (declare (salience 10000))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"BEFORE: Wavefront Pathing \" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::DispatchDivideBlock\n (declare (salience 200))\n ?fct <- (message (to wavefront-scheduling)\n (action check-path)\n (arguments ?path for block ?block))\n (object (is-a Path) \n (id ?path) \n (values $? ?block $?rest))\n ;we don't need to explicitly match for ?block\n =>\n (retract ?fct)\n (assert (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?path ?block => $?rest))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a BasicBlock) \n (id ?curr) \n (Successors $?succ)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (bind ?sLen (length$ $?succ))\n (if (= 0 ?sLen) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if (or (> ?sLen 1) ?hcb) then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else \n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr))))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::AnalyzePathElements-Region\n ?fct <- (message (to wavefront-scheduling-pathing)\n (action scan-path)\n (arguments ?p ?e => ?curr $?rest))\n ?bb <- (object (is-a Region)\n (id ?curr)\n (HasCallBarrier ?hcb)\n (HasMemoryBarrier ?hmb))\n =>\n (if ?hcb then\n (assert (message (to wavefront-scheduling)\n (action completely-invalid-blocks)\n (arguments ?e => $?rest))\n (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))\n (retract ?fct)\n else\n (if ?hmb then\n (assert (message (to wavefront-scheduling)\n (action element-has-memory-barrier)\n (arguments ?curr => ?e))))\n (modify ?fct (arguments ?p ?e => $?rest))\n (assert (message (to wavefront-scheduling)\n (action potentially-valid-blocks)\n (arguments ?e => ?curr)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::RetractCompletedFact\n ?fct <- (message (to wavefront-scheduling)\n (action scan-path)\n (arguments ? ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pathing::PrintoutCompletedFacts \n (declare (salience -999))\n (message (action Debug))\n (message (action Facts))\n =>\n (printout t \"AFTER: Wavefront Pathing\" crlf crlf)\n (facts)\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"7e4f87be5a0188193962d70cf3c115ade4b7ad8b","subject":"nothing really2","message":"nothing really2\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Sabado\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Domingo\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\n)\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"9a62e35e6e0c0c3086792e4bb45cdd926b39c9d7","subject":"Fixed bugs in WavefrontInstructionMerging.clp","message":"Fixed bugs in WavefrontInstructionMerging.clp\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontInstructionMerging.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::AssertScheduleCPVIntoTargetBlock \n (object (is-a Wavefront) \n (values $? ?e $?))\n (object (is-a Diplomat) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (MovableCompensationPathVectors \n $?cpvs&:(<> 0 (length$ $?cpvs))))\n =>\n (modify-instance ?agObj (MovableCompensationPathVectors))\n (progn$ (?cpv $?cpvs)\n (assert (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsMove\n \"This rule attempts to determine if the CPV should be moved into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;the two sets are the same\n (test (equal$ ?paths ?cpvPaths))\n =>\n ;change the action...nothing more :D\n (modify ?fct (action move-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsCompensate\n \"This rule attempts to determine if the CPV should be copied into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted.\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;there are more paths in the CPV than in the block\n (test (subsetp ?paths ?cpvPaths))\n =>\n (modify ?fct (action clone-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::RemoveScheduleStyleForCPV\n (declare (salience 1))\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (parent ?i)\n (Paths $?cpvPaths))\n (test (not (subsetp ?paths ?cpvPaths)))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n ;TODO: Put code in here to delete a given instruction from the target\n ; instruction list as well. \n ;\n ; Eventually, I will detect if we are in a loop. If we are then it is\n ; necessary to figure out which paths remain in the loop and those\n ; that exit. \n ;this should prevent a potential infinite loop\n ;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::MoveInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last)\n (Produces $?nBProds))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n (class ?class))\n ?oldBlock <- (object (is-a BasicBlock) \n (id ?otherBlock) \n (Produces $?pBefore ?inst $?pRest)\n (contents $?before ?inst $?rest))\n ;TODO: add another rule where we have to update the consumers list as\n ; well\n =>\n (object-pattern-match-delay\n ;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n (modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n (modify-instance ?oldBlock (contents $?before $?rest) \n (Produces $?pBefore $?pRest))\n ;(modify-instance ?cpvObject (Paths))\n (modify ?fct (action remove-evidence)\n (arguments ?inst => $?niConsumers))\n (assert (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?otherBlock)))\n (if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n else\n (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (contents $?blockBefore ?newName ?last))\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (Producers) \n (Consumers)\n (NonLocalDependencies) \n (LocalDependencies)\n (TimeIndex ?ti) \n (parent ?e))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::CloneInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst) \n (Paths $?cpvPaths))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (class ?class))\n =>\n ;we also need to update all CPVs within \n (object-pattern-match-delay\n (bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n ;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n ; \" as \" ?newName crlf)\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (parent ?e)\n (TimeIndex (+ ?ti 1)))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n ;we add the original name so that we don't have to do\n ; an insane number of updates to the CPVs that follow\n ; this object\n (if (eq StoreInstruction ?class) then \n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n else\n (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n (slot-insert$ ?newBlock Produces 1 ?register)\n (modify-instance ?newBlock (contents $?blockBefore ?newName ?last))\n (slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n (slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n (slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify ?fct (action recompute-block)\n (arguments ?otherBlock))\n (assert (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv)))\n (bind ?leftOvers (create$))\n (progn$ (?z ?cpvPaths)\n (bind ?cPath (symbol-to-instance-name ?z))\n (if (not (member$ ?e (send ?cPath get-contents))) then\n (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n (modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-CLONE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-MOVE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-SCHEDULE-STYLE\n (declare (salience -768))\n (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p)\n (Aliases $?aliases)\n (Paths $?cpvPaths))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Instruction) \n (id ?p) \n (parent ?bb))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r) \n (Paths $?paths))\n (object (is-a Wavefront) \n (parent ?r) \n (values $?z) \n (Closed $?y))\n (object (is-a Region) \n (id ?r) \n (Entrances ?x $?))\n (object (is-a BasicBlock) \n (id ?x) \n (Paths $?allPaths))\n =>\n (printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n \" which is targeted for \" ?e crlf\n \"Blocks on the wavefront = \" ?z crlf\n \"Closed Blocks = \" ?y crlf\n \"For reference ?cpvPaths = \" ?cpvPaths crlf\n \"For reference aliases of ?cpv are = \" $?aliases crlf\n \"For reference ?paths = \" ?paths crlf\n \"Parent of \" ?p \" is \" ?bb crlf\n \"Printing out the path aggregate for \" ?p crlf )\n (send ?pa print)\n (progn$ (?apath ?allPaths)\n (bind ?aObj (instance-name (symbol-to-instance-name ?apath)))\n (printout t \" \" ?apath \" = \" (send ?aObj get-contents) crlf))\n (facts)\n (halt))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Contains rules associated with the act of actually scheduling instructions\n; into blocks on the wavefront\n;\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::AssertScheduleCPVIntoTargetBlock \n (object (is-a Wavefront) \n (contents $? ?e $?))\n (object (is-a Diplomat) \n (id ?e) \n (IsOpen TRUE))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e) \n (MovableCompensationPathVectors \n $?cpvs&:(<> 0 (length$ $?cpvs))))\n =>\n (modify-instance ?agObj (MovableCompensationPathVectors))\n (progn$ (?cpv $?cpvs)\n (assert (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e)))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsMove\n \"This rule attempts to determine if the CPV should be moved into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;the two sets are the same\n (test (equal$ ?paths ?cpvPaths))\n =>\n ;change the action...nothing more :D\n (modify ?fct (message (action move-instruction))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::ScheduleStyleForCPVIsCompensate\n \"This rule attempts to determine if the CPV should be copied into the \n given block on the wavefront. If this is true then the fact to perform \n this action will be asserted.\"\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n ;there are more paths in the CPV than in the block\n (test (subsetp ?paths ?cpvPaths))\n =>\n (modify ?fct (action clone-instruction)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::RemoveScheduleStyleForCPV\n (declare (salience 1))\n ?fct <- (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a BasicBlock) \n (id ?e) \n (Paths $?paths))\n (object (is-a CompensationPathVector) \n (id ?cpv)\n (Paths $?cpvPaths))\n (test (not (subsetp ?paths ?cpvPaths)))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionList $?il))\n =>\n ;TODO: Put code in here to delete a given instruction from the target\n ; instruction list as well. \n ;\n ; Eventually, I will detect if we are in a loop. If we are then it is\n ; necessary to figure out which paths remain in the loop and those\n ; that exit. \n ;this should prevent a potential infinite loop\n ;(printout t \"Preventing \" ?i \" from being scheduled into \" ?e crlf)\n (retract ?fct)\n (bind ?ind (member$ ?i $?il))\n (if ?ind then (slot-delete$ ?agObj InstructionList ?ind ?ind)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::MoveInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last)\n (Produces $?nBProds))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e)\n (InstructionPropagation $?agIP)\n (ScheduledInstructions $?agSI)\n (ReplacementActions $?agRA))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst)\n (ScheduleTargets $?cpvST)\n (Aliases $?cpvAliases))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Consumers $?niConsumers)\n (Class ?class))\n ?oldBlock <- (object (is-a BasicBlock) \n (id ?otherBlock) \n (Produces $?pBefore ?inst $?pRest)\n (Contents $?before ?inst $?rest))\n ;TODO: add another rule where we have to update the consumers list as\n ; well\n =>\n (object-pattern-match-delay\n ;(printout t \"Scheduled \" ?inst \" into \" ?e crlf)\n (modify-instance ?terminator (TimeIndex (+ ?ti 1)))\n ;(modify-instance ?newBlock (Produces ?nBProds ?register))\n (modify-instance ?oldBlock (Contents $?before $?rest) \n (Produces $?pBefore $?pRest))\n ;(modify-instance ?cpvObject (Paths))\n (modify ?fct (action remove-evidence)\n (arguments ?inst => $?niConsumers))\n (assert (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?otherBlock)))\n (if (eq StoreInstruction ?class) then \n (modify-instance ?agObj \n (ScheduledInstructions $?agSI ?inst ?register)\n (ReplacementActions $?agRA ?inst ?inst !))\n ;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?inst ?last))\n (modify-instance ?cpvObject \n (Paths)\n (ScheduleTargets ?cpvST ?e ?inst)\n (Aliases $?cpvAliases ?inst ?e))\n (llvm-unlink-and-move-instruction-before ?nPtr ?tPtr)\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?inst)\n ;(slot-insert$ ?cpvObject Aliases 1 ?inst ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?inst !)\n else\n (bind ?newName (sym-cat movedinstruction. (gensym*) . ?inst))\n (modify-instance ?cpvObject (Paths)\n (ScheduleTargets ?cpvST ?e ?newName)\n (Aliases ?cpvAliases ?newName ?e))\n ;(slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n ;(slot-insert$ ?cpvObject Aliases 1 ?newName ?e)\n ;(slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify-instance ?newBlock \n (Produces $?nBProds ?register)\n (Contents $?blockBefore ?newName ?last))\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (id ?newName) \n (Name ?newName)\n (pointer ?newPtr) \n (Producers) \n (Consumers)\n (NonLocalDependencies) \n (LocalDependencies)\n (TimeIndex ?ti) \n (parent ?e))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n (slot-insert$ ?oldBlock UnlinkedInstructions 1 ?inst)\n (modify-instance ?agObj (ReplacementActions $?agRA ?inst ?newName !)\n (InstructionPropagation $?agIP ?inst ?newName ?e !)\n (ScheduledInstructions $?agSI ?inst)))))\n;(slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n;(slot-insert$ ?agObj ScheduledInstructions 1 ?inst))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::CloneInstructionIntoBlock\n \"Moves the given object into bottom of the given block\"\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n ?newBlock <- (object (is-a BasicBlock) \n (id ?e) \n (contents $?blockBefore ?last))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?e))\n ?terminator <- (object (is-a TerminatorInstruction) \n (pointer ?tPtr) \n (id ?last) \n (TimeIndex ?ti) \n (parent ?e))\n ?cpvObject <- (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?inst) \n (Paths $?cpvPaths))\n ?newInst <- (object (is-a Instruction) \n (id ?inst) \n (pointer ?nPtr) \n (parent ?otherBlock) \n (DestinationRegisters ?register) \n (Class ?class))\n =>\n ;we also need to update all CPVs within \n (object-pattern-match-delay\n (bind ?newName (sym-cat compensation.copy. (gensym*) . ?inst))\n ;(printout t \"Scheduled \" ?inst \" into \" ?e \" from \" ?otherBlock \n ; \" as \" ?newName crlf)\n (bind ?newPtr (llvm-clone-instruction ?nPtr ?newName))\n ;purge the list of producers and consumers\n (duplicate-instance ?inst to ?newName \n (ID ?newName) \n (Name ?newName)\n (Pointer ?newPtr) \n (Parent ?e)\n (TimeIndex (+ ?ti 1)))\n (llvm-move-instruction-before ?newPtr ?tPtr)\n ;we add the original name so that we don't have to do\n ; an insane number of updates to the CPVs that follow\n ; this object\n (if (eq StoreInstruction ?class) then \n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst ?register)\n else\n (slot-insert$ ?agObj InstructionPropagation 1 ?inst ?newName ?e !)\n (slot-insert$ ?agObj ScheduledInstructions 1 ?inst))\n (slot-insert$ ?newBlock Produces 1 ?register)\n (modify-instance ?newBlock (contents $?blockBefore ?newName ?last))\n (slot-insert$ ?cpvObject ScheduleTargets 1 ?e ?newName)\n (slot-insert$ ?cpvObject Aliases 1 ?newName ?e) \n (slot-insert$ ?agObj ReplacementActions 1 ?inst ?newName !)\n (modify ?fct (action recompute-block)\n (arguments ?otherBlock))\n (assert (message (to wavefront-scheduling)\n (action reopen-blocks)\n (arguments ?cpv)))\n (bind ?leftOvers (create$))\n (progn$ (?z ?cpvPaths)\n (bind ?cPath (symbol-to-instance-name ?z))\n (if (not (member$ ?e (send ?cPath get-contents))) then\n (bind ?leftOvers (insert$ ?leftOvers 1 ?z))))\n (modify-instance ?cpvObject (Paths ?leftOvers))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-CLONE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action clone-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't clone \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-MOVE\n (declare (salience -768))\n ?fct <- (message (to wavefront-scheduling)\n (action move-instruction)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (parent ?p))\n =>\n (printout t \"ERROR: Didn't move \" ?p \" into \" ?e crlf)\n (halt))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge::FAILURE-SCHEDULE-STYLE\n (declare (salience -768))\n (message (to wavefront-scheduling)\n (action determine-schedule-style)\n (arguments ?cpv => ?e))\n (object (is-a CompensationPathVector) \n (id ?cpv) \n (Parent ?p)\n (Aliases $?aliases)\n (Paths $?cpvPaths))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Instruction) \n (id ?p) \n (Parent ?bb))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r) \n (Paths $?paths))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $?z) \n (Closed $?y))\n (object (is-a Region) \n (id ?r) \n (Entrances ?x $?))\n (object (is-a BasicBlock) \n (id ?x) \n (Paths $?allPaths))\n =>\n (printout t \"ERROR: Couldn't figure out scheduling stype for \" ?p \n \" which is targeted for \" ?e crlf\n \"Blocks on the wavefront = \" ?z crlf\n \"Closed Blocks = \" ?y crlf\n \"For reference ?cpvPaths = \" ?cpvPaths crlf\n \"For reference aliases of ?cpv are = \" $?aliases crlf\n \"For reference ?paths = \" ?paths crlf\n \"Parent of \" ?p \" is \" ?bb crlf\n \"Printing out the path aggregate for \" ?p crlf )\n (send ?pa print)\n (progn$ (?apath ?allPaths)\n (bind ?aObj (instance-name (symbol-to-instance-name ?apath)))\n (printout t \" \" ?apath \" = \" (send ?aObj get-contents) crlf))\n (facts)\n (halt))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"65a4e84350f5d0f9137df14b7ab37da0e23ef335","subject":"Defined splitting of * in GLAPI calls.","message":"Defined splitting of * in GLAPI calls.\n","repos":"DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n identify-symbols-with-asterisks \n \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n; Alright, we now need to build a corresponding procedure from each heading\n; There are several ways to do this. The easiest would be to just do it\n; procedurally in a single rule fire. \n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\") == 0) {\" \n (if ?if then \"if\" else \"} else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-constant-conversion-procedure\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (> (length$ $?entries) 0))\n =>\n (unmake-instance ?obj)\n (bind ?target (format nil \"\/\/%s\" ?group))\n (bind ?header (format nil \"extern GLenum To%s(char* input) {\" ?group))\n (bind ?first (to-conditional-field (nth$ 1 (first$ ?entries)) TRUE))\n (bind ?result (create$ ?target ?header ?first))\n (progn$ (?e (rest$ ?entries))\n (bind ?result \n (create$ ?result (to-conditional-field ?e FALSE))))\n (bind ?result (create$ ?result \"} else {\" \"return 0;\" \"}\" \"}\"))\n (progn$ (?r ?result) (printout t ?r crlf))\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule grouping-update::skip-constant-conversion\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (= (length$ $?entries) 0))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (object (is-a heading-span)\n (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (type #define)\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify-instance ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-still-existing-elements\n (declare (salience -100))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n; Alright, we now need to build a corresponding procedure from each heading\n; There are several ways to do this. The easiest would be to just do it\n; procedurally in a single rule fire. \n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\") == 0) {\" \n (if ?if then \"if\" else \"} else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-constant-conversion-procedure\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (> (length$ $?entries) 0))\n =>\n (unmake-instance ?obj)\n (bind ?target (format nil \"\/\/%s\" ?group))\n (bind ?header (format nil \"extern GLenum To%s(char* input) {\" ?group))\n (bind ?first (to-conditional-field (nth$ 1 (first$ ?entries)) TRUE))\n (bind ?result (create$ ?target ?header ?first))\n (progn$ (?e (rest$ ?entries))\n (bind ?result \n (create$ ?result (to-conditional-field ?e FALSE))))\n (bind ?result (create$ ?result \"} else {\" \"return 0;\" \"}\" \"}\"))\n (progn$ (?r ?result) (printout t ?r crlf))\n (printout t crlf crlf))\n;------------------------------------------------------------------------------\n(defrule grouping-update::skip-constant-conversion\n ?obj <- (object (is-a heading-span)\n (header-name ?group)\n (contents $?entries))\n (test (= (length$ $?entries) 0))\n =>\n (unmake-instance ?obj))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"f92d2fa6b6e0b9e34e540882e2f39958311dbaf0","subject":"Added the concepts of the player and item","message":"Added the concepts of the player and item\n","repos":"DrItanium\/AdventureEngine,DrItanium\/AdventureEngine","old_file":"world.clp","new_file":"world.clp","new_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The concept of a world for a player to explore\n;------------------------------------------------------------------------------\n(defmodule world\n (import constants defglobal ?ALL)\n (import core defclass thing)\n (export defclass \n item\n room\n player))\n\n(defclass world::player\n \"The inventory container that the player uses \/ self\"\n (is-a thing)\n (multislot items\n (type INSTANCE)\n (allowed-classes item)\n (visibility public)))\n\n(defclass world::item\n \"An thing that can be moved around\"\n (is-a thing))\n\n(defclass world::room\n \"A place that contains items and can be exited from one of the four cardinal directions\"\n (is-a thing)\n (multislot contents)\n ; TODO: eventually implement a description of the door\n (slot north\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot south\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot east \n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot west\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE)))\n\n\n\n","old_contents":";------------------------------------------------------------------------------\n;The Adventure Engine\n;Copyright (c) 2012-2016, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of The Adventure Engine nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; The concept of a world for a player to explore\n;------------------------------------------------------------------------------\n(defmodule world\n (import constants defglobal ?ALL)\n (import core defclass thing))\n\n(defclass world::room\n \"A place that contains items and can be exited from one of the four cardinal directions\"\n (is-a thing)\n (multislot contents)\n ; TODO: eventually implement a description of the door\n (slot north\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot south\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot east \n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE))\n (slot west\n (type INSTANCE\n SYMBOL)\n (visibility public)\n (allowed-classes room)\n (allowed-symbols FALSE)))\n\n\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"44664a9e3e0b788db361b7a5ebf5c68e7a719fc6","subject":"update BeerEX.clp","message":"update BeerEX.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"BeerEX.clp","new_file":"BeerEX.clp","new_contents":"\n(load clips\/beerex.clp)\n\n(undefrule load-beer-question-rules)\n(load clips\/beer-questions.clp)\n\n(undefrule load-beer-knowledge-rules)\n(load clips\/beer-knowledge.clp)\n\n(deffunction ask-question (?display ?allowed-values)\n (bind ?answer \"\")\n (if (or (not (member$ prev ?allowed-values))\n (member$ restart ?allowed-values))\n then (printout t crlf))\n (while (not (member$ ?answer ?allowed-values))\n (printout t ?display \" \")\n (bind ?i 1)\n (progn$ (?value ?allowed-values)\n (printout t ?i \".\" ?value \" \")\n (bind ?i (+ ?i 1)))\n (printout t \"-> \")\n (if (neq (bind ?number (read-number)) \"*** READ ERROR ***\")\n then (bind ?answer (nth$ ?number ?allowed-values)))\n (if (member$ restart ?allowed-values)\n then (printout t crlf)))\n ?answer)\n\n(deffunction next-UI-state ()\n (do-for-fact ((?s state-list)) TRUE (and (bind ?current-id ?s:current)\n (bind ?sequence ?s:sequence)))\n (do-for-fact ((?u UI-state)) (eq ?u:id ?current-id) (and (bind ?display ?u:display)\n (bind ?help ?u:help)\n (bind ?why ?u:why)\n (bind ?state ?u:state)\n (bind ?valid-answers ?u:valid-answers)))\n (if (eq ?state middle)\n then (bind ?allowed-values ?valid-answers)\n (if (neq ?help nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) help)))\n (if (neq ?why nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) why)))\n (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) cancel))\n (if (> (length$ ?sequence) 2)\n then (bind ?allowed-values (insert$ ?allowed-values (length$ ?allowed-values) prev)))\n (bind ?answer (ask-question ?display ?allowed-values))\n else (if (eq ?state final)\n then (bind ?answer (ask-question ?display (create$ prev restart cancel)))\n else (assert (next ?current-id))\n (run)\n (next-UI-state)))\n (if (member$ ?answer ?valid-answers)\n then (assert (next ?current-id ?answer))\n (run)\n (next-UI-state)\n else (if (eq ?answer help)\n then (printout t crlf)\n (printout t ?help crlf)\n (printout t crlf)\n (next-UI-state))\n (if (eq ?answer why)\n then (printout t crlf)\n (printout t ?why crlf)\n (printout t crlf)\n (next-UI-state))\n (if (eq ?answer prev)\n then (assert (prev ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?answer restart)\n then (reset)\n (run)\n (next-UI-state))\n (if (eq ?answer cancel)\n then (exit))))\n\n(reset)\n(run)\n\n(next-UI-state)\n","old_contents":"\n(load clips\/beerex.clp)\n\n(undefrule load-beer-knowledge-rules)\n(undefrule load-beer-question-rules)\n\n(load clips\/beer-questions.clp)\n(load clips\/beer-knowledge.clp)\n\n(deffunction ask-question (?display ?allowed-values)\n (bind ?answer \"\")\n (if (or (not (member$ prev ?allowed-values))\n (member$ restart ?allowed-values))\n then (printout t crlf))\n (while (not (member ?answer ?allowed-values))\n (printout t ?display \" \" ?allowed-values \" \")\n (bind ?answer (readline))\n (if (member$ restart ?allowed-values)\n then (printout t crlf))\n (if (eq (str-index \" \" ?answer) FALSE)\n then (bind ?answer (nth$ 1 (explode$ ?answer)))))\n ?answer)\n\n(deffunction next-UI-state ()\n (do-for-fact ((?s state-list)) TRUE (and (bind ?current-id ?s:current)\n (bind ?sequence ?s:sequence)))\n (do-for-fact ((?u UI-state)) (eq ?u:id ?current-id) (and (bind ?display ?u:display)\n (bind ?help ?u:help)\n (bind ?why ?u:why)\n (bind ?state ?u:state)\n (bind ?valid-answers ?u:valid-answers)))\n (if (eq ?state middle)\n then (bind ?allowed-values ?valid-answers)\n (if (neq ?help nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) help)))\n (if (neq ?why nil)\n then (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) why)))\n (bind ?allowed-values (insert$ ?allowed-values (+ (length$ ?allowed-values) 1) cancel))\n (if (> (length$ ?sequence) 2)\n then (bind ?allowed-values (insert$ ?allowed-values (length$ ?allowed-values) prev)))\n (bind ?answer (ask-question ?display ?allowed-values))\n else (if (eq ?state final)\n then (bind ?answer (ask-question ?display (create$ prev restart cancel)))\n else (assert (next ?current-id))\n (run)\n (next-UI-state)))\n (if (member$ ?answer ?valid-answers)\n then (assert (next ?current-id ?answer))\n (run)\n (next-UI-state)\n else (if (eq ?answer help)\n then (printout t crlf)\n (printout t ?help crlf)\n (printout t crlf)\n (next-UI-state))\n (if (eq ?answer why)\n then (printout t crlf)\n (printout t ?why crlf)\n (printout t crlf)\n (next-UI-state))\n (if (eq ?answer prev)\n then (assert (prev ?current-id))\n (run)\n (next-UI-state))\n (if (eq ?answer restart)\n then (reset)\n (run)\n (next-UI-state))\n (if (eq ?answer cancel)\n then (exit))))\n\n(reset)\n(run)\n\n(next-UI-state)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"6b49a3c0dd78fb2d3bcbde5e67e2985a91abf145","subject":"Rewrote the argument parsing to not use a linear search","message":"Rewrote the argument parsing to not use a linear search\n\nI split the target fact at a given , which creates a range. This range is then\nused to determine the positions of the arguments in each section. When the\nbegin and end positions are the same then we only have a single value and the\ncorrect index.\n","repos":"DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (+ ?start (count-commas $?a)))\n\t\t\t(bind ?startb (+ ?cca 1))\n\t\t\t(bind ?ccb (+ ?startb (count-commas $?b)))\n\t\t\t(modify ?fct (arguments ?o ?start ?cca => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb (+ ?startb ?ccb) => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::parse-arguments\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t ; this is going backwards, we defer the index field\n\t\t\t\t\t\t\t\t ; by setting it as an offset of the length, which we\n\t\t\t\t\t\t\t\t ; don't know until we actually generate these\n\t\t\t\t\t\t\t\t ; arguments.\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?sentry))\n\t\t\t;we use the number of commas before plus 1 to determine index\n\t\t\t(bind ?index (+ (count-commas ?sentry) 1))\n\t\t\t;the problem is determining the direction to spit out an argument in\n\t\t\t;I don't want to assume backwards or forwards to tell the truth. So\n\t\t\t;that means that we just mark $?rest with the target index and move on\n\t\t\t;\n\t\t\t;This method is technically out of order due to the use of the , as a\n\t\t\t;fix point\n\t\t\t(duplicate ?fct (action build-argument)\n\t\t\t (arguments ?o ?index => $?rest)))\n;------------------------------------------------------------------------------\n(defrule build-groups::create-last-argument\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t=>\n\t\t\t;The last element doesn't contain any commas and thus must be zero \n\t\t\t(modify ?fct (action build-argument)\n\t\t\t (arguments ?o 0 => $?all)))\n;------------------------------------------------------------------------------\n(defrule build-groups::retract-empty-parse-message\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n;(defrule build-groups::argument-is-fixed-array\n;\t\t\t(declare (salience 1))\n;\t\t\t?fct <- (message (to build-groups)\n;\t\t\t\t\t\t\t\t (action build-argument)\n;\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?field \"[\" ?size \"]\"))\n;\t\t\t=>\n;\t\t\t(modify ?fct (to grouping-update)\n;\t\t\t\t\t (action populate-argument)\n;\t\t\t\t\t (arguments ?name => $?field))\n;\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n;\t\t\t\t\t\t\t\t(parent ?o)\n;\t\t\t\t\t\t\t\t(array-size ?size)\n;\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n;(defrule build-groups::argument-is-generic\n;\t\t\t?fct <- (message (to build-groups)\n;\t\t\t\t\t\t\t\t (action build-argument)\n;\t\t\t\t\t\t\t\t (arguments ?o ?name ?ind => $?input))\n;\t\t\t=>\n;\t\t\t(modify ?fct (to grouping-update)\n;\t\t\t\t\t (action populate-argument)\n;\t\t\t\t\t (arguments ?name => $?input))\n;\t\t\t(make-instance ?name of GLAPIArgument\n;\t\t\t\t\t\t\t\t(parent ?o)\n;\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"3dfb8ab35b72274d67fa6c940974d14afba0c880","subject":"changed sfp-test.clp","message":"changed sfp-test.clp\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@946 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/sfp-test.clp","new_file":"samples\/sfp-test.clp","new_contents":"\n(deftemplate wurst \n\t(slot name (type STRING))\n\t(multislot zutaten (default \"Fleisch\" \"Salz\" \"Wasser\"))\n\t(slot gewicht (type INTEGER))\n\t(slot laenge (type INTEGER) (default 25))\n\t(slot hersteller (type STRING))\n)\n\n(deftemplate bier \n\t(slot name (type STRING))\n\t(slot gewicht (type INTEGER))\n\t(slot hersteller (type STRING))\n)\n\n(assert (wurst\n\t\t(name \"Fischwurst\")\n\t\t(gewicht 200)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"Fischwurst\")\n\t\t(gewicht 100)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (bier \n\t\t(name \"Birburger\")\n\t\t(gewicht 100)\n\t\t)\n)\n\n(defrule wurst-meter-langsam \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(wurst (laenge 100) (gewicht 200))\n\t(bier (gewicht 100))\n\t\n;;\ty <- (wurst (laenge ?x)\n\t=>\n\t(printout t \"Eine Wurst gefunden.\")\n)\n\n\n\n(defrule wurst-meter \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(declare (rule-version \"performance version\") (salience 101) (auto-focus TRUE))\n\t(wurst (gewicht ?x))\n\t(wurst (laenge 100))\n\t(bier (gewicht ?x))\n;;\ty <- (wurst (laenge ?x)\n\t=>\n\t(printout t \"Lebensmittel die zusammenpassen.\")\n)\n\n\n\n\n\n;modify test:\n(deftemplate modifywurst\n\t(slot name)\n\t(slot laenge)\n\t(multislot zutaten)\n)\n\n(assert (modifywurst\n\t\t(name \"zukurz\")\n\t\t(laenge 25)\n\t\t(zutaten \"wasser\" \"salz\" \"pferd\")\n\t)\n)\n\n(defrule bessereWurst\n\t ?wurstFact <-(modifywurst (laenge 25)(zutaten $?zutatenlist))\n\t=>\n\t(modify ?wurstFact (laenge 35) )\n\t;(printout t $?zutatenlist )\t\n\t(printout t \"laengere wurst\" )\n\t(foreach ?i $?zutatenlist (printout t ?i)) \n )\n\n","old_contents":"\n(deftemplate wurst \n\t(slot name (type STRING))\n\t(multislot zutaten (default \"Fleisch\" \"Salz\" \"Wasser\"))\n\t(slot gewicht (type INTEGER))\n\t(slot laenge (type INTEGER) (default 25))\n\t(slot hersteller (type STRING))\n)\n\n(deftemplate bier \n\t(slot name (type STRING))\n\t(slot gewicht (type INTEGER))\n\t(slot hersteller (type STRING))\n)\n\n\n\n\n\n(assert (wurst\n\t\t(name \"Fischwurst\")\n\t\t(gewicht 200)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"Fischwurst\")\n\t\t(gewicht 100)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (bier \n\t\t(name \"Birburger\")\n\t\t(gewicht 100)\n\t\t)\n)\n\n\n(defrule wurst-meter \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(declare (rule-version \"performance version\") (salience 101) (auto-focus TRUE))\n\t(wurst (gewicht ?x))\n\t(bier (gewicht ?x))\n;;\ty <- (wurst (laenge ?x)\n\t=>\n\t(printout t \"Lebensmittel die zusammenpassen.\")\n)\n\n(defrule wurst-meter-langsam \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(wurst (laenge 100) (gewicht 200))\n\t(bier (gewicht 100))\n\t\n;;\ty <- (wurst (laenge ?x)\n\t=>\n\t(printout t \"Eine Wurst gefunden.\")\n)\n\n\n\n;modify test:\n(deftemplate modifywurst\n\t(slot name)\n\t(slot laenge)\n\t(multislot zutaten)\n)\n\n(assert (modifywurst\n\t\t(name \"zukurz\")\n\t\t(laenge 25)\n\t\t(zutaten \"wasser\" \"salz\" \"pferd\")\n\t)\n)\n\n(defrule bessereWurst\n\t ?wurstFact <-(modifywurst (laenge 25)(zutaten $?zutatenlist))\n\t=>\n\t(modify ?wurstFact (laenge 35) )\n\t;(printout t $?zutatenlist )\t\n\t(printout t \"laengere wurst\" )\n\t(foreach ?i $?zutatenlist (printout t ?i)) \n )\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"bc606aa31ee1e87d65fe68d6664aec56c7ea83d8","subject":"Cleaned up painter.clp","message":"Cleaned up painter.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n\n(defglobal MAIN\n\t ?*system-initialized* = FALSE)\n\n(deffacts query-operation\n\t (query input)\n\t (defmenu menu1 cut copy paste)\n\t (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n\t (declare (salience 10000))\n\t (initial-fact)\n\t =>\n\t (if (not ?*system-initialized*) then\n\t (eresized 0)\n\t (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n\t (declare (salience 9999))\n\t ?f <- (defmenu ?a $?b)\n\t =>\n\t (retract ?f)\n\t (defmenu ?a ?b))\n\n(defrule on-resized\n\t (declare (salience 1000))\n\t ?f <- (event resized new ?value)\n\t =>\n\t (if (and ?value (< (getwindow) 0)) then\n\t (printout werror \"ERROR: couldn't reattach to window\" crlf)\n\t (exit)\n\t else\n\t (retract ?f)))\n\n(defrule query-input \n\t ?f <- (query input)\n\t =>\n\t (retract ?f)\n\t (mouse\/query)\n\t (assert (input mouse\n\t\t\tbuttons: (translate\/mouse\/buttons)\n\t\t\tposition: (mouse\/position)\n\t\t\ttime-stamp: (mouse\/timestamp))\n\t\t (input keyboard\n\t\t\tbutton: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n\t (declare (salience -1))\n\t ?f <- (input mouse\n\t\t buttons: $?\n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n\t ?f <- (input mouse \n\t\t buttons: button3 \n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t ; Display a menu\n\t (printout t (send [menu1] show-menu 3) crlf)\n\t (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n\t ?f <- (input mouse \n\t\t buttons: button2\n\t\t position: ? ?\n\t\t time-stamp: ?)\n\t =>\n\t (retract ?f)\n\t ; Display a menu\n\t (printout t (send [menu2] show-menu 2) crlf)\n\t (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n\t (declare (salience 1))\n\t ?f <- (input keyboard \n\t\t button: ESC)\n\t =>\n\t (retract ?f)\n\t (exit))\n\n(defrule process-keyboard-inputs:nil\n\t (declare (salience 1))\n\t ?f <- (input keyboard button: NIL)\n\t =>\n\t (retract ?f)\n\t (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n\t ?f <- (input keyboard\n\t\t button: ?b)\n\t =>\n\t (retract ?f)\n\t (printout t \"Pressed \" ?b crlf)\n\t (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n\t ?f <- (query keyboard)\n\t ?f2 <- (query mouse)\n\t =>\n\t (retract ?f ?f2)\n\t (assert (query input)))\n","old_contents":"(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?a $?b)\n =>\n (retract ?f)\n (defmenu ?a ?b))\n\n(defrule on-resized\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:passthrough\n (declare (salience 1))\n ?f <- (input keyboard button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"e35e8c0aaeb158f2fcd88c1b03839a0da75d807f","subject":"Added documentation to CLIPS function send-response.","message":"Added documentation to CLIPS function send-response.\n","repos":"BioRoboticsUNAM\/BBCLIPS","old_file":"CLIPS\/BB_interface.clp","new_file":"CLIPS\/BB_interface.clp","new_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tDEFTEMPLATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deftemplate waiting\n\t(slot cmd (type STRING))\n\t(slot id (type INTEGER))\n\t(slot args (type STRING))\n\t(slot timeout\n\t\t(type INTEGER)\n\t\t(range 0 ?VARIABLE)\n\t)\n\t(slot attempts\n\t\t(type INTEGER)\n\t\t(range 1 ?VARIABLE)\n\t)\n\t(slot symbol\n\t\t(type SYMBOL)\n\t)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tBB FUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction send-command\n\t; Receives: command, symbol identifier, cmd_params and optionally\n\t;timeout and number of attempts in case it times out or fails.\n\t; Symbol identifier is useful for tracking responses through rules.\n\t(?cmd ?sym ?args $?settings)\n\t(bind ?timeout ?*defaultTimeout*)\n\t(bind ?attempts ?*defaultAttempts*)\n\t(switch (length$ $?settings)\n\t\t(case 1 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t)\n\t\t(case 2 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t\t(bind ?attempts (nth$ 2 $?settings))\n\t\t)\n\t)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(if (> ?timeout 0) then\n\t\t(setCmdTimer ?timeout ?cmd ?id)\n\t)\n\t(assert\n\t\t(waiting (cmd ?cmd) (id ?id) (args ?args) (timeout ?timeout) (attempts ?attempts) (symbol ?sym) )\n\t)\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n\t(return ?id)\n)\n\n(deffunction send-response\n\t; Receives: command, id, result and params\n\t(?cmd ?id ?result ?params)\n\t(python-call SendResponse ?cmd ?id ?result ?params)\n\t(log-message INFO \"Sent response: '\" ?cmd \"' - id: \" ?id \" - result: \" ?result \"params: \" ?params)\n;\t(halt)\n)\n\n(deffunction create-shared_var\n\t; Receives: type and name\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name)\n\t(bind ?resp (python-call CreateSharedVar ?type ?name))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Created SharedVar: \" ?name)\n\telse\n\t\t(log-message WARNING \"SharedVar: '\" ?name \"' could NOT be created!\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction write-shared_var\n\t; Receives: type, name and data\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name $?data)\n\t(bind ?resp (python-call WriteSharedVar ?type ?name $?data))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Written to SharedVar: '\" ?name \"' - \" $?data)\n\telse\n\t\t(log-message WARNING \"Could NOT write to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction subscribe_to-shared_var\n\t; Receives: name and optionally subscription type and report type\n\t; Subscription type is one of: creation | writemodule | writeothers | writeany\n\t; report type is one of: content | notify\n\t(?name $?options)\n\t(bind ?resp (python-call SubscribeToSharedVar ?name $?options) )\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Subscribed to SharedVar: '\" ?name \"'\")\n\t\t(assert \n\t\t\t(BB_subscribed_to_var ?name)\n\t\t)\n\telse\n\t\t(log-message WARNING \"Could NOT subscribe to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tRULES TO HANDLE BB (PYTHON) ASSERTS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-waiting-timedout-without_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts 1) (args ?args) (timeout ?timeout&~0) (symbol ?sym) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(assert \n\t\t(BB_answer ?cmd ?sym 0 ?args)\n\t)\n\t(retract ?w ?BB)\n\t(log-message WARNING \"Command timedout w\/o attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms\")\n)\n\n(defrule BB-waiting-timedout-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command timedout w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(bind ?attempts (- ?attempts 1))\n\t(modify ?w (id ?id) (attempts ?attempts))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-failed-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_received ?cmd ?id 0 ?)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command failed w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - attempts: \" ?attempts)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(modify ?w (id ?id) (attempts (- ?attempts 1)))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-set_answer\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts ?attempts) (symbol ?sym))\n\t?BB <-(BB_received ?cmd ?id ?result ?params)\n\t(test (or (eq ?result 1) (eq ?attempts 1)))\n\t=>\n\t(retract ?w ?BB)\n\t(assert \n\t\t(BB_answer ?cmd ?sym ?result ?params)\n\t)\n\t(log-message INFO \"Answer received: '\" ?cmd \"' - id: \" ?id \" - successful: \" ?result \" - response: \" ?params)\n)\n\n(defrule BB-clear-timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?t)\n\t(log-message INFO \"Clearing timer for command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_response\n\t(declare (salience -1000))\n\t?BB <-(BB_received ?cmd ?id $?)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Clearing unhandled response from command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_answer\n\t(declare (salience -1000))\n\t?BB <-(BB_answer ?cmd ?sym ?result ?params)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Clearing answer from command: '\" ?cmd \"' - sym: \" ?sym \"' - result: \" ?result \"' - params: \" ?params)\n)\n\n\n;\tHANDLE SHARED VAR UPDATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-set_sv_update\n\t?BB <-(BB_sv_updated ?var $?values)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Shared var updated: \" ?var \"\\t\\t-\\t\\tvalue: \" $?values)\n\t;(printout t \"Shared var updated: \" ?var crlf \"value: \" $?values crlf)\n)\n\n(defrule BB-clear_sv_update\n\t(declare (salience -10000))\n\t?BB <-(BB_sv_updated $?)\n\t=>\n\t(retract ?BB)\n)\n\n(defrule BB-unknown-command\n\t(declare (salience -10000))\n\t?BB <-(BB_cmd ?cmd ?id ?params)\n\t=>\n\t(retract ?BB)\n\t(send-response ?cmd ?id FALSE \"unknown command\")\n\t(log-message WARNING \"Unhandled command received: \" ?cmd)\n;\t(halt)\n)\n","old_contents":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tDEFTEMPLATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deftemplate waiting\n\t(slot cmd (type STRING))\n\t(slot id (type INTEGER))\n\t(slot args (type STRING))\n\t(slot timeout\n\t\t(type INTEGER)\n\t\t(range 0 ?VARIABLE)\n\t)\n\t(slot attempts\n\t\t(type INTEGER)\n\t\t(range 1 ?VARIABLE)\n\t)\n\t(slot symbol\n\t\t(type SYMBOL)\n\t)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tBB FUNCTIONS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(deffunction send-command\n\t; Receives: command, symbol identifier, cmd_params and optionally\n\t;timeout and number of attempts in case it times out or fails.\n\t; Symbol identifier is useful for tracking responses through rules.\n\t(?cmd ?sym ?args $?settings)\n\t(bind ?timeout ?*defaultTimeout*)\n\t(bind ?attempts ?*defaultAttempts*)\n\t(switch (length$ $?settings)\n\t\t(case 1 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t)\n\t\t(case 2 then\n\t\t\t(bind ?timeout (nth$ 1 $?settings))\n\t\t\t(bind ?attempts (nth$ 2 $?settings))\n\t\t)\n\t)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(if (> ?timeout 0) then\n\t\t(setCmdTimer ?timeout ?cmd ?id)\n\t)\n\t(assert\n\t\t(waiting (cmd ?cmd) (id ?id) (args ?args) (timeout ?timeout) (attempts ?attempts) (symbol ?sym) )\n\t)\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n\t(return ?id)\n)\n\n(deffunction send-response\n\t(?cmd ?id ?result ?params)\n\t(python-call SendResponse ?cmd ?id ?result ?params)\n\t(log-message INFO \"Sent response: '\" ?cmd \"' - id: \" ?id \" - result: \" ?result \"params: \" ?params)\n;\t(halt)\n)\n\n(deffunction create-shared_var\n\t; Receives: type and name\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name)\n\t(bind ?resp (python-call CreateSharedVar ?type ?name))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Created SharedVar: \" ?name)\n\telse\n\t\t(log-message WARNING \"SharedVar: '\" ?name \"' could NOT be created!\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction write-shared_var\n\t; Receives: type, name and data\n\t;type is one of: byte[] | int | int[] | long | long[] | \n\t; double | double[] | string | matrix | RecognizedSpeech | var\n\t(?type ?name $?data)\n\t(bind ?resp (python-call WriteSharedVar ?type ?name $?data))\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Written to SharedVar: '\" ?name \"' - \" $?data)\n\telse\n\t\t(log-message WARNING \"Could NOT write to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n(deffunction subscribe_to-shared_var\n\t; Receives: name and optionally subscription type and report type\n\t; Subscription type is one of: creation | writemodule | writeothers | writeany\n\t; report type is one of: content | notify\n\t(?name $?options)\n\t(bind ?resp (python-call SubscribeToSharedVar ?name $?options) )\n\t(if (eq ?resp 1) then\n\t\t(log-message INFO \"Subscribed to SharedVar: '\" ?name \"'\")\n\t\t(assert \n\t\t\t(BB_subscribed_to_var ?name)\n\t\t)\n\telse\n\t\t(log-message WARNING \"Could NOT subscribe to SharedVar: '\" ?name \"'\")\n\t)\n\t(return ?resp)\n)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;\t\tRULES TO HANDLE BB (PYTHON) ASSERTS\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-waiting-timedout-without_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts 1) (args ?args) (timeout ?timeout&~0) (symbol ?sym) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(assert \n\t\t(BB_answer ?cmd ?sym 0 ?args)\n\t)\n\t(retract ?w ?BB)\n\t(log-message WARNING \"Command timedout w\/o attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms\")\n)\n\n(defrule BB-waiting-timedout-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(BB_received ?cmd ?id $?)\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command timedout w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(bind ?attempts (- ?attempts 1))\n\t(modify ?w (id ?id) (attempts ?attempts))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-failed-with_attempts\n\t?w <-(waiting (cmd ?cmd) (id ?id) (args ?args) (attempts ?attempts&~1) (timeout ?timeout&~0) )\n\t?BB <-(BB_received ?cmd ?id 0 ?)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Command failed w\/ attempts: '\" ?cmd \"' - id: \" ?id \" - attempts: \" ?attempts)\n\t(bind ?id (python-call SendCommand ?cmd ?args))\n\t(setCmdTimer ?timeout ?cmd ?id)\n\t(modify ?w (id ?id) (attempts (- ?attempts 1)))\n\t(log-message INFO \"Sent command: '\" ?cmd \"' - id: \" ?id \" - timeout: \" ?timeout \"ms - attempts: \" ?attempts)\n)\n\n(defrule BB-set_answer\n\t?w <-(waiting (cmd ?cmd) (id ?id) (attempts ?attempts) (symbol ?sym))\n\t?BB <-(BB_received ?cmd ?id ?result ?params)\n\t(test (or (eq ?result 1) (eq ?attempts 1)))\n\t=>\n\t(retract ?w ?BB)\n\t(assert \n\t\t(BB_answer ?cmd ?sym ?result ?params)\n\t)\n\t(log-message INFO \"Answer received: '\" ?cmd \"' - id: \" ?id \" - successful: \" ?result \" - response: \" ?params)\n)\n\n(defrule BB-clear-timers\n\t(declare (salience -1000))\n\t?t <-(BB_timer ?cmd ?id)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?t)\n\t(log-message INFO \"Clearing timer for command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_response\n\t(declare (salience -1000))\n\t?BB <-(BB_received ?cmd ?id $?)\n\t(not\n\t\t(waiting (cmd ?cmd) (id ?id))\n\t)\n\t=>\n\t(retract ?BB)\n\t(log-message WARNING \"Clearing unhandled response from command: '\" ?cmd \"' - id: \" ?id)\n)\n\n(defrule BB-clear_answer\n\t(declare (salience -1000))\n\t?BB <-(BB_answer ?cmd ?sym ?result ?params)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Clearing answer from command: '\" ?cmd \"' - sym: \" ?sym \"' - result: \" ?result \"' - params: \" ?params)\n)\n\n\n;\tHANDLE SHARED VAR UPDATES\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n(defrule BB-set_sv_update\n\t?BB <-(BB_sv_updated ?var $?values)\n\t=>\n\t(retract ?BB)\n\t(log-message INFO \"Shared var updated: \" ?var \"\\t\\t-\\t\\tvalue: \" $?values)\n\t;(printout t \"Shared var updated: \" ?var crlf \"value: \" $?values crlf)\n)\n\n(defrule BB-clear_sv_update\n\t(declare (salience -10000))\n\t?BB <-(BB_sv_updated $?)\n\t=>\n\t(retract ?BB)\n)\n\n(defrule BB-unknown-command\n\t(declare (salience -10000))\n\t?BB <-(BB_cmd ?cmd ?id ?params)\n\t=>\n\t(retract ?BB)\n\t(send-response ?cmd ?id FALSE \"unknown command\")\n\t(log-message WARNING \"Unhandled command received: \" ?cmd)\n;\t(halt)\n)\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"754aa66be4110b36ccfb072261152b76110f93da","subject":"Added the file that contains the Message template definition","message":"Added the file that contains the Message template definition\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"src\/clips\/modules\/engine\/Message.clp","new_file":"src\/clips\/modules\/engine\/Message.clp","new_contents":"; Message.clp - a basic template type that is used to pass messages between\n; different modules\n; Written by Joshua Scoggins\n(deftemplate engine::message\n\t\t\t\t \"A standardized way to pass facts between modules\"\n\t\t\t\t (slot from)\n\t\t\t\t (slot to)\n\t\t\t\t (slot action)\n\t\t\t\t (multislot arguments))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/clips\/modules\/engine\/Message.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c73e14cb826d7084d8833d89854f2ddb57a2dd02","subject":"Objetivos","message":"Objetivos\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-altura ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad mas quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n \n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona Persona:objetivos 1 (nth$ ?respuesta ?lista_objetivos))\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n)\n\n","old_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-altura ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"2bde51440d79efe4c7f5a868e1022ebe72841514","subject":"Added example product for catharsis","message":"Added example product for catharsis\n","repos":"DrItanium\/catharsis","old_file":"catharsis.clp","new_file":"catharsis.clp","new_contents":"; Entry point into catharsis\n; Modify this to fit your system.\n(defglobal MAIN \n ?*catharsis-root* = (str-cat (get-shell-variable HOME) \n \"\/dev\/catharsis\"))\n\n(defmountpoint catharsis ?*catharsis-root*)\n\n(batch* (proton: \/lib\/core.clp))\n(batch* (proton: \/lib\/neutron.clp))\n; begin catharsis\n(defglobal MAIN\n ?*old-point-x* = 0\n ?*old-point-y* = 0)\n\n(deftemplate pen-size\n (slot min \n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1))\n (slot max\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 128))\n (slot current\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1)))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit))\n (bind ?two-thirds (\/ 2 3))\n (bind ?width (screen\/dimensions\/width))\n (bind ?height (screen\/dimensions\/height))\n (bind ?point-dim (as-point:screen\/dimensions))\n (bind ?f2\/3-width (* ?width ?two-thirds))\n (bind ?f2\/3-height (* ?height ?two-thirds))\n (bind ?f2\/3-point (new Point ?f2\/3-width ?f2\/3-height))\n (bind ?p0height-point (new Point 0 ?height))\n (bind ?pwidth0-point (new Point ?width 0))\n (bind ?zpointer (send [ZP] get-pointer))\n (bind ?pipointer (send [pixel-image] get-pointer))\n (screen\/draw-line ?zpointer\n ?p0height-point\n 0\n 0\n 8 \n ?pipointer\n ?zpointer)\n (screen\/draw-line ?p0height-point\n ?point-dim\n 0\n 0\n 8 \n ?pipointer\n ?zpointer)\n (screen\/draw-line ?point-dim\n ?pwidth0-point\n 0\n 0\n 8 \n ?pipointer\n ?zpointer)\n (screen\/draw-line ?zpointer\n ?pwidth0-point\n 0\n 0\n 8 \n ?pipointer\n ?zpointer)\n (screen\/draw-line (new Point 0 ?f2\/3-height)\n ?f2\/3-point\n 0\n 0\n 8\n ?pipointer\n ?zpointer)\n (screen\/draw-line (new Point ?f2\/3-width 0)\n (new Point ?f2\/3-width ?height)\n 0\n 0\n 8\n ?pipointer\n ?zpointer)\n )\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input)\n (pen-size (min 1)\n (max 128)\n (current 1)))\n\n\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n ;?rect <- (object (is-a rectangle)\n ; (name [scratch-rect]))\n (pen-size (current ?factor))\n =>\n (retract ?f)\n ;(modify-instance ?rect (x ?x) (y ?y)\n ; (bx (+ ?x ?factor)) \n ; (by (+ ?y ?factor)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n ;(send ?rect build-pointer)\n (screen\/draw-line (new Point ?*old-point-x* ?*old-point-y*)\n (new Point ?x ?y)\n 0\n 0\n ?factor \n (send [pixel-image] get-pointer)\n (send [ZP] get-pointer))\n (screen\/draw-line (new Point ?*old-point-x* ?y)\n (new Point ?x ?*old-point-y*)\n 0\n 0\n ?factor \n (send [pixel-image] get-pointer)\n (send [ZP] get-pointer))\n (screen\/draw-line (new Point ?x ?y)\n (new Point ?*old-point-x* ?*old-point-y*)\n 0\n 0\n ?factor \n (send [pixel-image] get-pointer)\n (send [ZP] get-pointer))\n (screen\/draw-line (new Point ?x ?*old-point-y*)\n (new Point ?*old-point-x* ?y)\n 0\n 0\n ?factor \n (send [pixel-image] get-pointer)\n (send [ZP] get-pointer))\n (bind ?*old-point-x* ?x)\n (bind ?*old-point-y* ?y)\n (assert (query mouse)))\n\n;(screen\/draw ?rect [pixel-image] [ZP])\n;(assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n(defrule process-keyboard-inputs:left\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys LEFT))\n =>\n (retract ?f)\n (assert (query keyboard))\n (halt))\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?pen <- (pen-size \n (current ?factor)\n (max ?max))\n =>\n (if (< ?factor ?max) then\n (modify ?pen (current (+ ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?pen <- (pen-size (min ?min)\n (current ?factor))\n =>\n (if (> ?factor ?min) then\n (modify ?pen (current (- ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n\n\n\n(batch* (proton: \/lib\/reset-run-exit.clp))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'catharsis.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"227fb66b34aad464a9a7191bc67cff7393814143","subject":"Added painter.clp[","message":"Added painter.clp[\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"logic\/painter.clp","new_file":"logic\/painter.clp","new_contents":"(load* \/lib\/chicanery\/input.clp)\n(load* \/lib\/chicanery\/menu.clp)\n\n(defglobal MAIN\n ?*system-initialized* = FALSE)\n\n(deffacts query-operation\n (query input)\n (defmenu menu1 cut copy paste)\n (defmenu menu2 eat sleep drink))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule build-menus\n (declare (salience 9999))\n ?f <- (defmenu ?a $?b)\n =>\n (retract ?f)\n (defmenu ?a ?b))\n\n(defrule on-resized\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n\n(defrule query-input \n ?f <- (query input)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (input mouse\n buttons: (translate\/mouse\/buttons)\n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))\n (input keyboard\n button: (translate\/kbd\/query))))\n\n\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (input mouse\n buttons: $?\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n ?f <- (input mouse \n buttons: button3 \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n ?f <- (input mouse \n buttons: button2\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (input keyboard button: ESC)\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:passthrough\n (declare (salience 1))\n ?f <- (input keyboard button: NIL)\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (input keyboard\n button: ?b)\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (assert (query input)))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'logic\/painter.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"858d439f1193e4dbc309ade9a972e5d559db64eb","subject":"added one more sfc test. khk.","message":"added one more sfc test.\nkhk.\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1075 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"samples\/sfp-test.clp","new_file":"samples\/sfp-test.clp","new_contents":"\n(deftemplate wurst \n\t(slot name (type STRING))\n\t(multislot zutaten (default \"Fleisch\" \"Salz\" \"Wasser\"))\n\t(slot gewicht (type INTEGER))\n\t(slot laenge (type INTEGER) (default 25))\n\t(slot hersteller (type STRING))\n)\n\n(deftemplate bier \n\t(slot name )\n\t(slot gewicht )\n\t(slot hersteller )\n)\n\n(deftemplate senf \n\t(slot gewicht)\n\t(slot name)\n) \n\n(assert (wurst\n\t\t(name \"Fischwurst schwer\")\n\t\t(gewicht 200)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"Fischwurst2\")\n\t\t(gewicht 100)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"miniwurst\")\n\t\t(gewicht 10)\n\t\t(laenge 15)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n\n(assert (bier \n\t\t(name \"Bitburger\")\n\t\t(gewicht 100)\n\t\t)\n)\n\n\n\n(assert (bier \n\t\t(name \"Eifel Champus\")\n\t\t(gewicht 200)\n\t\t)\n)\n\n\n\n(assert (senf (name scharf) (gewicht 100)))\n\n(assert (senf (name auchscharf) (gewicht 200)))\n\n(assert (senf (name nix) (gewicht 1)))\n\n\n(defrule wurst-meter \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(declare (rule-version \"performance version\") (salience 101) (auto-focus TRUE))\n\t(wurst (gewicht ?x) (name ?y))\n\t(bier (gewicht ?x) (name ?z))\n\t(senf (gewicht ?x) (name ?w))\n\t=>\n\t(printout t \"Lebensmittel die zusammenpassen. wurst:\" ?y \" Bier: \" ?z \"Senf: \" ?w \" Gewicht: \" ?x)\n)\n\n\n\n(defrule wurst-meter-langsam \"Regel zur Ausgabe der Wurst-Laenge\" \n\t(wurst (laenge 100) (gewicht 200))\n\t(bier (gewicht 100))\n\t=>\n\t(printout t \"Eine Wurst gefunden.\")\n)\n\n\n;modify test:\n(deftemplate modifywurst\n\t(slot name)\n\t(slot laenge)\n\t(multislot zutaten)\n)\n\n(assert (modifywurst\n\t\t(name \"zukurz\")\n\t\t(laenge 25)\n\t\t(zutaten \"wasser\" \"salz\" \"pferd\")\n\t)\n)\n\n(defrule bessereWurst\n\t ?wurstFact <-(modifywurst (laenge 25)(zutaten $?zutatenlist))\n\t=>\n\t(modify ?wurstFact (laenge 35) )\n\t;(printout t $?zutatenlist )\t\n\t(printout t \"laengere wurst\" )\n\t(foreach ?i $?zutatenlist (printout t ?i)) \n )\n\n; binding tests\n\n(defrule bier-senf-vergleich\n\t (bier (gewicht ?x)(name ?y))\n\t (wurst (gewicht ?x)(name ?z))\n\t=>\n\t(printout t \"das bier \" ?y \" und die wurst \" ?z \" haben das gewicht \" ?x \" !\" )\n )\n\n\n","old_contents":"\n(deftemplate wurst \n\t(slot name (type STRING))\n\t(multislot zutaten (default \"Fleisch\" \"Salz\" \"Wasser\"))\n\t(slot gewicht (type INTEGER))\n\t(slot laenge (type INTEGER) (default 25))\n\t(slot hersteller (type STRING))\n)\n\n(deftemplate bier \n\t(slot name )\n\t(slot gewicht )\n\t(slot hersteller )\n)\n\n(deftemplate senf \n\t(slot gewicht)\n\t(slot name)\n) \n\n(assert (wurst\n\t\t(name \"Fischwurst schwer\")\n\t\t(gewicht 200)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"Fischwurst2\")\n\t\t(gewicht 100)\n\t\t(laenge 100)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n(assert (wurst\n\t\t(name \"miniwurst\")\n\t\t(gewicht 10)\n\t\t(laenge 15)\n\t\t(hersteller \"Nordmann\")\n\t)\n)\n\n\n(assert (bier \n\t\t(name \"Bitburger\")\n\t\t(gewicht 100)\n\t\t)\n)\n\n\n\n(assert (bier \n\t\t(name \"Eifel Champus\")\n\t\t(gewicht 200)\n\t\t)\n)\n\n\n\n(assert (senf (name scharf) (gewicht 100)))\n\n(assert (senf (name auchscharf) (gewicht 200)))\n\n(assert (senf (name nix) (gewicht 1)))\n\n\n(defrule wurst-meter \"Regel zur Ausgabe der Wurst-Lnge\" \n\t(declare (rule-version \"performance version\") (salience 101) (auto-focus TRUE))\n\t(wurst (gewicht ?x) (name ?y))\n\t(bier (gewicht ?x) (name ?z))\n\t(senf (gewicht ?x) (name ?w))\n\t=>\n\t(printout t \"Lebensmittel die zusammenpassen. wurst:\" ?y \" Bier: \" ?z \"Senf: \" ?w \" Gewicht: \" ?x)\n)\n\n\n\n(defrule wurst-meter-langsam \"Regel zur Ausgabe der Wurst-Laenge\" \n\t(wurst (laenge 100) (gewicht 200))\n\t(bier (gewicht 100))\n\t=>\n\t(printout t \"Eine Wurst gefunden.\")\n)\n\n\n;modify test:\n(deftemplate modifywurst\n\t(slot name)\n\t(slot laenge)\n\t(multislot zutaten)\n)\n\n(assert (modifywurst\n\t\t(name \"zukurz\")\n\t\t(laenge 25)\n\t\t(zutaten \"wasser\" \"salz\" \"pferd\")\n\t)\n)\n\n(defrule bessereWurst\n\t ?wurstFact <-(modifywurst (laenge 25)(zutaten $?zutatenlist))\n\t=>\n\t(modify ?wurstFact (laenge 35) )\n\t;(printout t $?zutatenlist )\t\n\t(printout t \"laengere wurst\" )\n\t(foreach ?i $?zutatenlist (printout t ?i)) \n )\n\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"6e50822436062e550401e912caedeb06297a6351","subject":"gordo","message":"gordo\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"----------\" crlf \" Lunes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Martes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \"Miercoles\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Jueves\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Viernes\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Sabado\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"----------\" crlf \" Domingo\" crlf \"----------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") (assert(preFitness -1000)) else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") (assert(preFitness -3000))else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") (assert(preFitness -2000)) else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") (assert(preFitness -1600))else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") (assert(preFitness -1200))else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") (assert(preFitness -700)) else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\") (assert(preFitness -300)) else (assert(preFitness 500)))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n (declare (salience 10))\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n ?ret <- (preFitness ?pre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness ?pre)\n (retract ?ret)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n(deffunction print-program (?programa)\n (printout t \"-----Programa propuesto-----\"crlf)\n (printout t crlf\"--------\" clrf \" Lunes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-lunes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Martes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-martes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Miercoles\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-miercoles))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Jueves\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-jueves))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Viernes\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-viernes))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Sabado\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-sabado))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n\n (printout t crlf\"--------\" clrf \" Domingo\" crlf \"--------\" crlf)\n (bind ?lista (send ?programa get-domingo))\n (loop-for-count (?i 1 (length$ ?lista)) do\n (bind ?aux (nth$ ?i ?lista))\n (printout t (send ?aux get-nombre) crlf)\n )\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n\n)\n(defrule final\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"573a1a5dd90568665231a3ec2eb51539d8f5c49a","subject":"lib\/cortex\/Library.clp: Rewrote Library.clp to take advantage of library-files","message":"lib\/cortex\/Library.clp: Rewrote Library.clp to take advantage of library-files\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/lib\/cortex\/Library.clp","new_file":"src\/lib\/cortex\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without ;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the cortex module and loads all other corresponding\n; files.\n; \n; Written by Joshua Scoggins \n; Started on 2\/14\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule cortex \n (import init ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(library-files \"cortex\"\n \"core\/Loader.clp\"\n \"io\/Loader.clp\"\n \"parsing\/Loader.clp\")\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the cortex module and loads all other corresponding\n; files.\n; \n; Written by Joshua Scoggins \n; Started on 2\/14\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule cortex (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/cortex\/core\/Loader.clp\")\n(batch* \"lib\/cortex\/io\/Loader.clp\")\n(batch* \"lib\/cortex\/parsing\/Loader.clp\")\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"5a3e4a6af76d1864453a21cc42bf619a9d63c009","subject":"Added another simple application","message":"Added another simple application\n\nThis one shows off how to do menus and have areas which different things\ncan occur in.\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"logic\/area.clp","new_file":"logic\/area.clp","new_contents":"(load* \/lib\/core.clp)\n(load* \/lib\/chicanery.clp)\n\n(deftemplate pen-size\n (slot min \n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1))\n (slot max\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 128))\n (slot current\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1)))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (assert (setup background))))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (region0 of rectangle (x 0) (y 0) (bx 128) (by 32))\n (point0 of point (x 0) (y 32))\n (drawing-field of rectangle (x 4) (y 37) (bx 1020) (by 1020))\n (drawing-field-border of rectangle (x 0) (y 33) (bx 1024) (by 1024))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (text of image (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color black)))\n (inset-rect0 of image (rectangle [drawing-field-border])\n (replicate TRUE)\n (color (get-standard-color black)))\n (field0 of image (rectangle [drawing-field])\n (replicate TRUE)\n (color (get-standard-color white)))\n (button-background of image (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color paleyellow)))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input)\n (pen-size (min 1)\n (max 128)\n (current 1)))\n\n(defrule setup-background \n (declare (salience 10000))\n ?f <- (setup background)\n =>\n (retract ?f)\n (screen\/draw [drawing-field-border] [inset-rect0] [ZP])\n (screen\/draw [drawing-field] [field0] [ZP])\n (screen\/draw [region0] [button-background] [ZP])\n (screen\/draw-text [ZP] [text] [ZP] \"File\")\n (screen\/flush 1))\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n (test (intersects ?x ?y [drawing-field]))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n (pen-size (current ?factor))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?factor)) \n (by (+ ?y ?factor)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3)\n (position ?x ?y))\n (test (intersects ?x ?y [region0]))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?pen <- (pen-size \n (current ?factor)\n (max ?max))\n =>\n (if (< ?factor ?max) then\n (modify ?pen (current (+ ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?pen <- (pen-size (min ?min)\n (current ?factor))\n =>\n (if (> ?factor ?min) then\n (modify ?pen (current (- ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n(batch* \/lib\/reset-run-exit.clp)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'logic\/area.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4d31bbbcd01c12628486a4f3b1a9d14d3794b917","subject":"Added the Object base type.","message":"Added the Object base type.\n\nThe object base type is my own object class that all other objects in the\nadventure engine inherit from. Not only, does this class provide basic\nreflection capabilities but also provides a parent field to define ownership.\n","repos":"DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron","old_file":"src\/adventure\/Object.clp","new_file":"src\/adventure\/Object.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defclass Object (is-a USER)\n \"Custom base type of all objects in the adventure engine. It has automatic\n reflective capabilities in the form of the Class and ID fields.\"\n (slot class (visibility public) (type SYMBOL))\n (slot id (visibility public) (type SYMBOL))\n (slot parent (visibility public) (default-dynamic nil)))\n\n(defmessage-handler TaggedObject init after ()\n (bind ?self:ID (instance-name-to-symbol (instance-name ?self)))\n (bind ?self:Class (class ?self)))\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/adventure\/Object.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4078ea0231f1f2a9a78968cb75413dc7b41fe0ae","subject":"Reduced rule complexity in the Store and Load dependency rules","message":"Reduced rule complexity in the Store and Load dependency rules\n\nI realized that having the complex pattern match occur as the first rule will\nreduce the match set because there are usually fewer basic blocks than\ninstructions. The complexity of the pattern match is offset by reducing the\nnumber of elements in the associated match network.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/BlockDependencyCreation.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/BlockDependencyCreation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockDependencyCreation.clp - Contains rules pertaining to the creation of\n; data dependencies between different instructions inside of a basic block\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency-Call\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (ArgumentOperands $? ?o $?))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (id ?o) \n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency \n\t\t\t(object (is-a Instruction&~CallInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (Operands $? ?o $?))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (id ?o) \n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-WritesToMemory\n\t\t\t;the parent is implied by the fact that it's part of the basic block\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $?before ?n0 $?))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?n0) \n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?before)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-HasSideEffects\n\t\t\t;the parent is implied by the fact that it's part of the basic block\n\t\t\t(Stage Analysis $?)\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $?a ?n0 $?))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?n0) \n\t\t\t\t\t (MayHaveSideEffects TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?a)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-ModifiesMemory\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call could modify memory.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent match reduces join network complexity\n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-InlineAsm\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent reduces join network complexity\n\t\t\t\t\t (IsInlineAsm TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-SideEffects\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call has side effects.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent reduces join network complexity \n\t\t\t\t\t (MayHaveSideEffects TRUE)) \n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t (id ?p)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p))\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t(object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t (id ?p)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t(object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Set\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency FALSE))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?inst (HasCallDependency TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Ignore\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency TRUE))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::StoreDependency-UNKNOWN\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget UNKNOWN))\n\t\t\t(object (is-a StoreInstruction|LoadInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::LoadDependency-UNKNOWN\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (MemoryTarget UNKNOWN))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>LoadDependency\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>StoreDependency\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Load=>StoreDependency\n\t\t\t(object (is-a BasicBlock)\n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN)) \n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; BlockDependencyCreation.clp - Contains rules pertaining to the creation of\n; data dependencies between different instructions inside of a basic block\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency-Call\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (ArgumentOperands $? ?o $?))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (id ?o) \n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkLocalDependency \n\t\t\t(object (is-a Instruction&~CallInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (Operands $? ?o $?))\n\t\t\t(object (is-a Instruction) \n\t\t\t\t\t (id ?o) \n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?o => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?o))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-WritesToMemory\n\t\t\t;the parent is implied by the fact that it's part of the basic block\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $?before ?n0 $?))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?n0) \n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?before)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkInstructionsThatHappenBeforeCall-HasSideEffects\n\t\t\t;the parent is implied by the fact that it's part of the basic block\n\t\t\t(Stage Analysis $?)\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (contents $?a ?n0 $?))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?n0) \n\t\t\t\t\t (MayHaveSideEffects TRUE))\n\t\t\t=>\n\t\t\t(progn$ (?n1 ?a)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n1 => ?n0))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?n0 => ?n1)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-ModifiesMemory\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call could modify memory.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent match reduces join network complexity\n\t\t\t\t\t (MayWriteToMemory TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-InlineAsm\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent reduces join network complexity\n\t\t\t\t\t (IsInlineAsm TRUE))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MarkCallInstructionDependency-SideEffects\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call has side effects.\"\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?name $?rest))\n\t\t\t(object (is-a CallInstruction) \n\t\t\t\t\t (id ?name) \n\t\t\t\t\t ;removing parent reduces join network complexity \n\t\t\t\t\t (MayHaveSideEffects TRUE)) \n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?p)))\n\t\t\t(progn$ (?following ?rest)\n\t\t\t\t\t (assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?following))\n\t\t\t\t\t\t\t\t ;(message (to dependency-analysis)\n\t\t\t\t\t\t\t\t ;\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t ;\t\t (arguments ?following => ?name))\n\t\t\t\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t\t\t\t (arguments ?name => ?following)))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t (id ?p)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p))\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-HasParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t (id ?p)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::FlagCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier FALSE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?d (HasCallBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::PropagateCallBarrierForDiplomat-NoParent\n\t\t\t;(declare (salience -10))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action element-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?z))\n\t\t\t?d <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t (id ?z) \n\t\t\t\t\t\t\t (HasCallBarrier TRUE)\n\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Set\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency FALSE))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?inst (HasCallDependency TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis-update::MarkHasACallDependency-Ignore\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-has-a-call-barrier)\n\t\t\t\t\t\t\t\t (arguments ?target))\n\t\t\t?inst <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (id ?target) \n\t\t\t\t\t\t\t\t (HasCallDependency TRUE))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::StoreDependency-UNKNOWN\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (MemoryTarget UNKNOWN)\n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction|LoadInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::LoadDependency-UNKNOWN\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0) \n\t\t\t\t\t (MemoryTarget UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>LoadDependency\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Store=>StoreDependency\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-extended-memory-analysis::Load=>StoreDependency\n\t\t\t(object (is-a LoadInstruction) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (id ?t0)\n\t\t\t\t\t (MemoryTarget ?sym0&~UNKNOWN)) \n\t\t\t(object (is-a BasicBlock)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (contents $? ?t0 $? ?t1 $?))\n\t\t\t(object (is-a StoreInstruction) \n\t\t\t\t\t (id ?t1) \n\t\t\t\t\t (MemoryTarget ?sym0))\n\t\t\t=>\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-consumes)\n\t\t\t\t\t\t\t\t (arguments ?t1 => ?t0))\n\t\t\t\t\t (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action instruction-produces)\n\t\t\t\t\t\t\t\t (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"b253d175c588b023cd110e895a3230d32ba327f9","subject":"Fixed symbol-to-pointer-list to use instance-address","message":"Fixed symbol-to-pointer-list to use instance-address\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(deffunction types::symbol-to-pointer-list\n\t\t\t\t \"Converts a given list of symbols that represent InteropObjects and pulls the\n\t\t\t\t pointer value out of it. This function assumes order is important\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?result (create$))\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(bind ?obj (instance-address * \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t (symbol-to-instance-name ?e)))\n\t\t\t\t\t\t\t(bind ?result (create$ ?result (send ?obj get-Pointer))))\n\t\t\t\t (return ?result))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n\n(deffunction types::symbol-to-pointer-list\n\t\t\t\t \"Converts a given list of symbols that represent InteropObjects and pulls the\n\t\t\t\t pointer value out of it. This function assumes order is important\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?result (create$))\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t (bind ?obj (symbol-to-instance-name ?e))\n\t\t\t\t\t\t\t (bind ?result (create$ ?result (send ?obj get-Pointer))))\n\t\t\t\t (return ?result))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"378cc4e611f3232a1ea7f2bc96ea4f81f7f73358","subject":"Replaced is-executing-environment with is-currently-executing-environment","message":"Replaced is-executing-environment with is-currently-executing-environment\n\nI had set \"is-currently-executing-environment\" as the name of the function that\nwas used to find out if the currently executing environment. So I changed the\nreference to is-executing-environment to is-currently-executing-environment\nsince the new term is more descriptive\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-currently-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-currently-executing-environment primary () \n (return (is-currently-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-currently-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-currently-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-currently-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-currently-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-currently-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-currently-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6f9e118312cde619b64bd39b27861349d0e86b63","subject":"Fuck generating everything","message":"Fuck generating everything\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot puntuacion) (slot tiempo))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (puntuacion -1)))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n\t(assert (limit-program 1000))\n)\n\n(defrule juntar-puntuacion \n\t?f1<-(ejercicio_tiempo (ejercicio ?e) (puntuacion ?p))\n\t(ejercicio_puntuado (ejercicio ?e2&:(eq ?e ?e2)) (puntuacion ?p1&:(not (eq ?p ?p1))))\n\t=>\n\t(modify ?f1 (puntuacion ?p1))\n)\n\n(defrule genera-lunes\n\t?programa<-(object (is-a Programa)\n\t\t(lunes $?lunes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?lunes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?lunes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-lunes (insert$ ?lunes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 1 1\n\t\t\t(-(nth$ 1 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-martes\n\t?programa<-(object (is-a Programa)\n\t\t(martes $?martes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?martes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 2 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?martes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 2 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-martes (insert$ ?martes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 2 2\n\t\t\t(-(nth$ 2 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-miercoles\n\t?programa<-(object (is-a Programa)\n\t\t(miercoles $?miercoles)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?miercoles))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?miercoles))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-miercoles (insert$ ?miercoles 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 3 3\n\t\t\t(-(nth$ 3 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-jueves\n\t?programa<-(object (is-a Programa)\n\t\t(jueves $?jueves)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?jueves))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?jueves))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-jueves (insert$ ?jueves 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 4 4\n\t\t\t(-(nth$ 4 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-viernes\n\t?programa<-(object (is-a Programa)\n\t\t(viernes $?viernes)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?viernes))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?viernes))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-viernes (insert$ ?viernes 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 5 5\n\t\t\t(-(nth$ 5 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-sabado\n\t?programa<-(object (is-a Programa)\n\t\t(sabado $?sabado)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?sabado))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?sabado))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-sabado (insert$ ?sabado 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 6 6\n\t\t\t(-(nth$ 6 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule genera-domingo\n\t?programa<-(object (is-a Programa)\n\t\t(domingo $?domingo)\n\t\t(tiempo+diario+disponible $?tiempo_disponible))\n\t(ejercicio_tiempo (ejercicio ?e&:(not (member ?e ?domingo))) (puntuacion ?p) (tiempo ?t&:(< ?t (nth$ 1 ?tiempo_disponible))))\n\t(not(ejercicio_tiempo (ejercicio ?e2&:(not (member ?e2 ?domingo))) (puntuacion ?p2&:(> ?p2 ?p)) (tiempo ?t2&:(< ?t2 (nth$ 1 ?tiempo_disponible)))))\n\t=>\n\t(send ?programa put-domingo (insert$ ?domingo 1 ?e))\n\t(send ?programa put-tiempo+diario+disponible \n\t\t(replace$ ?tiempo_disponible 7 7\n\t\t\t(-(nth$ 7 ?tiempo_disponible) ?t)\n\t\t)\n\t)\n)\n(defrule final\n\t(declare (salience -1))\n\t?programa<-(object (is-a Programa))\n\t=>\n\t(print-program ?programa)\n)\n\n\t\n\t\t\n\n","old_contents":"; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot persona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Persona)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_max\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones_min\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot gradoActividad\n\t\t(type INTEGER)\n\t\t(range -50 50)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pasteleria\n;+\t\t(comment \"veces a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(multislot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(definstances instances\n; Mon May 23 17:02:01 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.2)\n\t(duracion+maxima 120)\n\t(duracion+minima 20)\n\t(edad+maxima 80)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[Rebajar+Peso]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]\n\t\t[CouchPotato_Class6]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Hacer colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Comprar\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(objetivos\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[CouchPotato_Class14]\n\t\t[CouchPotato_Class21])\n\t(nombre \"Pecho\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class10001] of Persona\n\n\t(altura 1.7)\n\t(edad 50)\n\t(imc 22.0)\n\t(nombre \"Test1\")\n\t(peso 75.0)\n\t(pMax 100.0)\n\t(pMin 80.0))\n\n([CouchPotato_Class11] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.0)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio])\n\t(nombre \"Hombro\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class12] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.4)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares [B%C3%ADceps])\n\t(nombre \"Biceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Brazos]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Brazos])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class13] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.6)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16])\n\t(grupos+musculares [Tr%C3%ADceps])\n\t(nombre \"Triceps\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Rodillas])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class14] of Grupo+muscular\n\n\t(nombre \"Pectoral\"))\n\n([CouchPotato_Class15] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 3.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class16]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Dorsal])\n\t(nombre \"Espalda\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados [Espalda])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class16] of Ejercicio+con+pesas\n\n\t(calorias+quemadas 4.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class12]\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class11]\n\t\t[CouchPotato_Class10]\n\t\t[CouchPotato_Class13])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos])\n\t(nombre \"Piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[Articular])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class17] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 5.1)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[CouchPotato_Class14])\n\t(nombre \"Flexiones\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class8]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class3])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Articular])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class20] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 2.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class9]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[CouchPotato_Class21]\n\t\t[Gluteos])\n\t(nombre \"Hipopresivos\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Rodillas]\n\t\t[CouchPotato_Class2]\n\t\t[Presion+alta])\n\t(repeticiones+maximas 50)\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class21] of Grupo+muscular\n\n\t(nombre \"Abdominales\"))\n\n([CouchPotato_Class24] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Brazos\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Brazos])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class25] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class26])\n\t(nombre \"Piernas\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class26] of Estiramientos\n\n\t(calorias+quemadas 1.0)\n\t(duracion+maxima 5)\n\t(duracion+minima 2)\n\t(edad+maxima 100)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class24]\n\t\t[CouchPotato_Class25])\n\t(grupos+musculares\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Trapecio])\n\t(nombre \"Espalda\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Cuello]\n\t\t[Espalda])\n\t(repeticiones+maximas 4)\n\t(repeticiones+minimas 2))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class30] of Musculacion\n\n\t(nombre \"Musculacion\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n\n\t(calorias+quemadas 4.5)\n\t(duracion+maxima 20)\n\t(duracion+minima 5)\n\t(edad+maxima 80)\n\t(edad+minima 5)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class17]\n\t\t[CouchPotato_Class20])\n\t(grupos+musculares [CouchPotato_Class21])\n\t(nombre \"Abdominales\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Espalda]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2]\n\t\t[Cuello])\n\t(repeticiones+maximas 100)\n\t(repeticiones+minimas 10))\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Estar de pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(gradoActividad 10)\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(gradoActividad 15)\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 20)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -2)\n\t(nombre \"Leer\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(gradoActividad 20)\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(gradoActividad 5)\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 30)\n\t(nombre \"Pasear\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 35)\n\t(nombre \"Pasear mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 15)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(duracion+maxima 120)\n\t(duracion+minima 10)\n\t(edad+maxima 100)\n\t(edad+minima 10)\n\t(ejercicios+combinan\n\t\t[CouchPotato_Class15]\n\t\t[CouchPotato_Class26]\n\t\t[CouchPotato_Class17])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(objetivos\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco]\n\t\t[CouchPotato_Class30])\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(problemas+contraindicados\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class2]\n\t\t[Brazos]\n\t\t[Presion+alta]\n\t\t[CouchPotato_Class2])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad 50)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(gradoActividad -2)\n\t(nombre \"Estar sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(edad+minima 14)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(objetivos\n\t\t[Equilibrio]\n\t\t[Mantenimiento]\n\t\t[Ponerse+en+forma]\n\t\t[Rebajar+Peso]\n\t\t[Sistema+Card%C3%ADaco])\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(gradoActividad -5)\n\t(nombre \"Ver la television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n )\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n\t(bind ?edad (pregunta-numerica \"Edad (anos): \" 0.0 100.0))\n (send ?persona put-edad ?edad)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?respuesta (si-o-no-p \"Tienes trabajo? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"trabajo\")))\n\t(bind ?respuesta (si-o-no-p \"Llevas a cabo tareas domesticas regularmente? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"domesticas\")))\n\t(bind ?respuesta (si-o-no-p \"Haces otras actividades? \"))\n\t(if (eq ?respuesta TRUE) then (assert(actividad \"otras\")))\n\t(bind ?respuesta (si-o-no-p \"Tienes problemas musculo-esqueleticos? \"))\n\t(if (eq ?respuesta TRUE) then (assert(problemas)))\n)\n\n(defrule pide-actividades-trabajo\n\t(declare (salience 30))\n\t(actividad \"trabajo\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad+de+Trabajo)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad haces en el trabajo? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Durante cuanto tiempo? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia Diaria)\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-domesticas\n\t(declare (salience 20))\n\t(actividad \"domesticas\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Tarea+domestica)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(printout t crlf)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad domestica de estas haces? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n(defrule pide-actividades-otras\n\t(actividad \"otras\")\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Estatica)) TRUE))\n\t(bind ?lista_actividades2 (find-all-instances ((?a Desplazamiento)) TRUE))\n\t\n\t(printout t crlf \"0 : Ya esta\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(loop-for-count (?i 1 (length$ ?lista_actividades2)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades2))\n\t\t(printout t (+ ?i (length$ ?lista_actividades)) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t\n\t(bind ?respuesta (pregunta-numerica \"Que actividad de estas haces? \" 0 (+ (length$ ?lista_actividades2)(length$ ?lista_actividades))))\n\t(while (> ?respuesta 0) do \n\t\t(if (<= ?respuesta (length$ ?lista_actividades)) then\n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades)) else\n\t\t\t(bind ?actividad (nth$ (- ?respuesta (length$ ?lista_actividades)) ?lista_actividades2))\n\t\t)\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia lo haces? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\t\n\t\t(bind ?respuesta (pregunta-numerica \"Cual mas? \" 0 (+ (length$ ?lista_actividades)(length$ ?lista_actividades2))))\n\t)\n)\n\t\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 200.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n\t(bind ?pastel (pregunta-numerica \"Cuantas veces a la semana tomas alguna pieza de pasteleria? \" 0.0 200.0))\n (send ?dieta put-pasteleria ?pastel)\n\t\n\t(send ?persona put-dieta ?dieta)\n)\n\n(defrule pide-problema\n\t(problemas)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema mas de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n(deffunction pide-grupo-muscular()\n\t(bind ?lista_musc (find-all-instances ((?p Grupo+muscular)) TRUE))\n\t(bind ?res (create$))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que musculo en concreto? \" 0 (length$ ?lista_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?res (insert$ ?res 1 (nth$ ?respuesta ?lista_musc)))\n\t\t(bind ?respuesta (pregunta-numerica \"Alguno mas? \" 0 (length$ ?lista_musc)))\n\t\t\n\t)\n\t\n\t?res\n)\n\n(defrule pide-objetivo\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_objetivos (find-all-instances ((?o Objetivo)) TRUE))\n\t(printout t \"0 : Deja de anadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_objetivos)) do\n\t\t(bind ?aux (nth$ ?i ?lista_objetivos))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que objetivo tienes? \" 0 (length$ ?lista_objetivos)))\n\t(while (> ?respuesta 0) do\n\t\t(bind ?aux (nth$ ?respuesta ?lista_objetivos))\n\t\t(if (eq ?respuesta 7) then \n\t\t(send ?aux put-grupo_muscular (pide-grupo-muscular))\n\t\t\n\t\telse (slot-insert$ ?persona objetivos 1 ?aux))\n\t\t\n\t\t(bind ?respuesta (pregunta-numerica \"Que objetivo mas tienes? \" 0 (length$ ?lista_objetivos)))\n\t)\n\t\n\t(slot-insert$ ?persona objetivos 1 (find-instance ((?mus Musculacion)) TRUE))\n\t\n\t(bind ?dificultad (ask-question \"Cual es la dificultad deseada del entrenamiento? [Baja|Media|Alta] \" Baja Media Alta))\n\t(assert (dificultad ?dificultad))\n)\n\n(defrule crea-programa\n \n\t=>\n\t(bind ?programa (make-instance programa of Programa))\n\t(bind ?lista_tiempos (create$))\n \n (printout t \"Quantos minutos disponibles tienes al dia?\" crlf)\n\t\n (bind ?respuesta (pregunta-numerica \"Lunes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 1 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Martes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 2 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Miercoles: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 3 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Jueves: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 4 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Viernes: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 5 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Sabado: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 6 ?respuesta))\n (bind ?respuesta (pregunta-numerica \"Domingo: \" 30 1440))\n (bind ?lista_tiempos (insert$ ?lista_tiempos 7 ?respuesta))\n \n (send ?programa put-tiempo+diario+disponible ?lista_tiempos)\n)\n\n\n\n(defrule pasa-a-generar\n\t(declare (salience -10))\n\t=>\n\t(focus generar-solucion)\n)\n\n(defmodule generar-solucion \"Modulo de generacion de solucion\"\n (import MAIN ?ALL)\n (import preguntas-persona ?ALL)\n (export ?ALL))\n\n \n \n(deffunction do-test1(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 150) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 2000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 5000 else 8000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 8000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 8000 else 10000)\n\t\t)\n\t)\n)\n\n(deffunction do-test2(?test ?message ?persona)\n\t(printout t crlf ?message crlf \"Introduce aqui los resultados obtenidos: \" crlf)\n\t(bind ?ppm (pregunta-numerica \"Pulsaciones por minuto \" 50 250))\n\t(send ?test put-ppm ?ppm)\n\t(bind ?cansancio (ask-question \"Cansacio [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-cansancio ?cansancio)\n\t(bind ?tir (ask-question \"Tirantez Muscular [Mucho|Poco|Nada] \" Mucho Poco Nada))\n\t(send ?test put-tirantezMuscular ?tir)\n\t\n\t(slot-insert$ ?persona tests 1 ?test)\n\t(if (> ?ppm 200) then\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 40000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 45000)\n\t\t)\t\t\n\telse\n\t\t(if (eq (str-compare ?cansancio \"Mucho\") 0) then 42000 else\n\t\t\t(if (eq (str-compare ?tir \"Mucho\") 0) then 42000 else 50000)\n\t\t)\n\t)\n)\n\n(defrule calc-fitness\n\t(nombre ?nombre)\n\t?dieta <-(object (is-a Dieta)(nombre \"Much WOW\"))\n\t?test1 <-(object (is-a Test)(nombre \"Subir tramos escalera\"))\n\t?test2 <-(object (is-a Test)(nombre \"Carrera sostenida\"))\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?fitness 0)\n\t(bind ?lista_actividades (send ?persona get-actividades))\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(bind ?sedent (* (send ?aux get-gradoActividad) (send ?aux get-duracion)))\n\t\t(bind ?freq (send ?aux get-frequencia))\n\t\t(if (eq ?freq Diaria) then (bind ?sedent (* ?sedent 30)) else\n\t\t\t(if (eq ?freq Semanal) then (bind ?sedent (* ?sedent 4)) else\n\t\t\t\t(if (eq ?freq Mensual) then (bind ?sedent (* ?sedent 1)))\n\t\t\t)\n\t\t)\n\t\t(bind ?fitness (+ ?fitness ?sedent))\n\t)\n\t\n (bind ?sal (- 5 (send ?dieta get-abuso+de+sal)))\n (bind ?picar (- 5 (send ?dieta get-picar+entre+horas)))\n (bind ?fruta (send ?dieta get-consumo+de+fruta))\n\t(bind ?pastel (- 0 (send ?dieta get-pasteleria)))\n\t\n\t(bind ?fitness (+ (* (+ ?sal ?picar ?fruta ?pastel) 50) ?fitness)) ;(sal+picar)*50+fruta*50+fitness\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t\n\t(if (< ?fitness 10000) then\n\t\t(bind ?message \"Por favor toma el test de subir tramos de escalera (2 minutos)\")\n\t\t(bind ?fitness2 (do-test1 ?test1 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\telse (if (> ?fitness 50000) then \n\t\t(bind ?message \"Por favor toma el test de la carrera sostenida (5 minutos)\")\n\t\t(bind ?fitness2 (do-test2 ?test2 ?message ?persona))\n\t\t(bind ?fitness (\/ (+ ?fitness ?fitness2) 2))\n\t\t)\n\t)\n\t\n\t(printout t \"fitness \" ?fitness crlf)\n\t(assert (fitness ?fitness))\n)\n\n\n(deffunction calcula_puntuacion(?ejercicio ?persona)\n\t(bind ?res 0)\n\t\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(bind ?lista_aliviados (send ?ejercicio get-problemas+aliviados))\n\t(progn$ (?aliviado ?lista_aliviados)\n\t\t(progn$ (?problema ?lista_problemas)\n\t\t\t(if (eq ?aliviado ?problema) then (bind ?res (+ ?res 3)))\n\t\t)\n\t)\n\t\n\t(bind ?lista_objetivos (send ?persona get-objetivos))\n\t(bind ?lista_cumplidos (send ?ejercicio get-objetivos))\n\t(bind ?lista_grupos_cumplidos (send ?ejercicio get-grupos+musculares))\n\t(progn$ (?objetivo ?lista_objetivos)\n\t\t(if (eq (str-compare (class ?objetivo) \"Musculacion\") 0) then \n\t\t\t(bind ?lista_grupos_objetivo (send ?objetivo get-grupo_muscular))\n\t\t\t(progn$ (?grupo_objetivo ?lista_grupos_objetivo)\n\t\t\t\t(progn$ (?grupo_cumplido ?lista_grupos_cumplidos)\n\t\t\t\t\t(if (eq ?grupo_cumplido ?grupo_objetivo) then (bind ?res (+ ?res 1)))\n\t\t\t\t)\n\t\t\t)\n\t\telse \n\t\t\t(progn$ (?cumplido ?lista_cumplidos)\n\t\t\t\t(if (eq ?cumplido ?objetivo) then (bind ?res (+ ?res 3)))\n\t\t\t)\n\t\t)\n\t)\n\t\n\t?res\n)\n\n(deftemplate ejercicio_puntuado (slot ejercicio) (slot puntuacion))\n(deftemplate ejercicio_puntuado2 (slot ejercicio) (slot puntuacion))\n\n(defrule generar-ejercicios\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(do-for-all-instances ((?e Ejercicio)) TRUE \n\t\t(bind ?restricciones (send ?e get-problemas+contraindicados))\n\t\t(bind ?anadir 1)\n\t\t(loop-for-count (?i 1 (length$ ?restricciones)) do\n\t\t\t(bind ?aux (nth$ ?i ?restricciones))\n\t\t\t(if (member ?aux ?lista_problemas) then (bind ?anadir 0))\n\t\t)\n\t\t(if (or (> (send ?persona get-edad) (send ?e get-edad+maxima))(< (send ?persona get-edad) (send ?e get-edad+minima))) then (bind ?anadir 0))\n\t\t(if (eq (str-compare (class ?e) \"Estiramientos\") 0) then (bind ?anadir 0))\n\t\t(if (= ?anadir 1) then \n\t\t\t(assert (ejercicio_puntuado (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t\t(assert (ejercicio_puntuado2 (ejercicio ?e) (puntuacion (calcula_puntuacion ?e ?persona))))\n\t\t)\n\t)\n\t\n\t(assert (lista_ejercicios (create$)))\n)\n\n(defrule listar-ejercicios\n\t?f1 <- (lista_ejercicios $?lista_ejercicios)\n\t?f2 <-(ejercicio_puntuado2 (ejercicio ?e) (puntuacion ?p))\n\t(not (ejercicio_puntuado2 (puntuacion ?p2&:(< ?p2 ?p))))\n\t=>\n\t(bind ?lista_ejercicios (insert$ ?lista_ejercicios 1 ?e))\n\t(retract ?f1)\n\t(retract ?f2)\n\t(assert (lista_ejercicios ?lista_ejercicios))\n)\n\n\n(defrule imprimir-lista-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_problemas (send ?persona get-problemas+fisicos))\n\t(printout t crlf crlf crlf\"Hemos detectado que tienes los siguientes problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_problemas) (printout t (send ?var get-nombre) crlf))\n\t(printout t crlf crlf \"Estos son los ejercicios que podrias hacer teniendo en cuenta tus problemas: \" crlf crlf)\n\t(progn$ (?var ?lista_ejercicios) (printout t (send ?var get-nombre) \" : \" (calcula_puntuacion ?var ?persona) crlf))\n)\n\n(deffunction clamp (?min ?val ?max)\n\t(bind ?res ?val)\n\t(if (< ?val ?min) then (bind ?res ?min))\n\t(if (> ?val ?max) then (bind ?res ?max))\n\t?res\n)\n\n(deftemplate ejercicio_tiempo (slot ejercicio) (slot tiempo) (slot pos))\n\n(defrule calcular-tiempo-ejercicios\n\t(lista_ejercicios $?lista_ejercicios)\n\t(dificultad ?dificultad)\n\t(fitness ?fitness)\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA)(peso ?peso))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?pos 1)\n\t(bind ?fitness 40000)\n\t(bind ?min-fit 10000)\n\t(bind ?max-fit 50000)\n\t(bind ?fitness (clamp ?min-fit ?fitness ?max-fit)) \n\t(bind ?calorias-deseadas (*(\/ (- ?fitness ?min-fit) (- ?max-fit ?min-fit)) 1000)) ;entre 0 y 1000 \n\t(if (eq (str-compare ?dificultad \"Alta\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 2)))\n\t(if (eq (str-compare ?dificultad \"Baja\") 0) then (bind ?calorias-deseadas (* ?calorias-deseadas 0.5)))\n\t(printout t \"Calorias deseadas: \" ?calorias-deseadas crlf)\n\t\n\t(progn$ (?ejercicio ?lista_ejercicios)\n\t\t(bind ?dur-max (send ?ejercicio get-duracion+maxima))\n\t\t(bind ?dur-min (send ?ejercicio get-duracion+minima))\n\t\t(bind ?calorias-minuto (send ?ejercicio get-calorias+quemadas))\n\t\t(bind ?calorias-minuto (* ?calorias-minuto (\/ ?peso 60)))\n\t\t(bind ?tiempo (\/ ?calorias-deseadas ?calorias-minuto))\n\t\t(bind ?tiempo (clamp ?dur-min ?tiempo ?dur-max))\n\t\t(assert (ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo) (pos ?pos)))\n\t\t(bind ?pos (+ ?pos 1))\n\t)\n\t(setgen 1)\n\t(assert (num-program 0))\n)\n\t\n(defrule genera-programa-lunes\n\t?f1<-(num-program ?num)\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 1 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?lunes) ?lunes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq (insert$ ?lunes 1 ?ejercicio) ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (insert$ ?lunes 1 ?ejercicio))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 1 1\n\t\t\t(-(nth$ 1 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n\t\n)\n\n(defrule genera-programa-martes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 2 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?martes) ?martes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq (insert$ ?martes 1 ?ejercicio) ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (insert$ ?martes 1 ?ejercicio))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 2 2\n\t\t\t(-(nth$ 2 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-miercoles\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes&:(not (member ?ejercicio ?martes)))\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 3 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?miercoles) ?miercoles))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq (insert$ ?miercoles 1 ?ejercicio) ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes ?martes)\n\t(send ?new put-miercoles (insert$ ?miercoles 1 ?ejercicio))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 3 3\n\t\t\t(-(nth$ 3 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-jueves\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles&:(not (member ?ejercicio ?miercoles)))\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado)\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 4 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?jueves) ?jueves))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq (insert$ ?jueves 1 ?ejercicio) ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles ?miercoles)\n\t(send ?new put-jueves (insert$ ?jueves 1 ?ejercicio))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (send ?programa get-sabado))\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 4 4\n\t\t\t(-(nth$ 4 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-viernes\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves&:(not (member ?ejercicio ?jueves)))\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 5 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?viernes) ?viernes))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq (insert$ ?viernes 1 ?ejercicio) ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves ?jueves)\n\t(send ?new put-viernes (insert$ ?viernes 1 ?ejercicio))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (send ?programa get-domingo))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 5 5\n\t\t\t(-(nth$ 5 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-sabado\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes&:(not (member ?ejercicio ?viernes)))\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 6 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?sabado) ?sabado))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq (insert$ ?sabado 1 ?ejercicio) ?sabado2))\n\t\t(domingo $?domingo2&:(eq ?domingo ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes (send ?programa get-lunes))\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes ?viernes)\n\t(send ?new put-sabado (insert$ ?sabado 1 ?ejercicio))\n\t(send ?new put-domingo ?domingo)\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 6 6\n\t\t\t(-(nth$ 6 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n(defrule genera-programa-domingo\n\t(ejercicio_tiempo (ejercicio ?ejercicio) (tiempo ?tiempo&:(> ?tiempo 0))(pos ?pos))\n\t?programa<-(object (is-a Programa) \n\t\t(lunes $?lunes&:(not (member ?ejercicio ?lunes))) \n\t\t(martes $?martes)\n\t\t(miercoles $?miercoles)\n\t\t(jueves $?jueves)\n\t\t(viernes $?viernes)\n\t\t(sabado $?sabado&:(not (member ?ejercicio ?sabado)))\n\t\t(domingo $?domingo&:(not (member ?ejercicio ?domingo))) \n\t\t(tiempo+diario+disponible $?tiempos_disponibles&:(> (nth$ 7 ?tiempos_disponibles) ?tiempo))\n\t)\n\t(not (ejercicio_tiempo (ejercicio ?e&:(eq ?e (nth$ (length$ ?domingo) ?domingo))) (pos ?poslast&:(< ?pos ?poslast))))\n\t(not (object (is-a Programa)\n\t\t(lunes $?lunes2&:(eq ?lunes ?lunes2))\n\t\t(martes $?martes2&:(eq ?martes ?martes2))\n\t\t(miercoles $?miercoles2&:(eq ?miercoles ?miercoles2))\n\t\t(jueves $?jueves2&:(eq ?jueves ?jueves2))\n\t\t(viernes $?viernes2&:(eq ?viernes ?viernes2))\n\t\t(sabado $?sabado2&:(eq ?sabado ?sabado2))\n\t\t(domingo $?domingo2&:(eq (insert$ ?domingo 1 ?ejercicio) ?domingo2))\n\t))\n\t=>\n\t(bind ?new (make-instance of Programa))\n\t(send ?new put-lunes ?lunes)\n\t(send ?new put-martes (send ?programa get-martes))\n\t(send ?new put-miercoles (send ?programa get-miercoles))\n\t(send ?new put-jueves (send ?programa get-jueves))\n\t(send ?new put-viernes (send ?programa get-viernes))\n\t(send ?new put-sabado ?sabado)\n\t(send ?new put-domingo (insert$ ?domingo 1 ?ejercicio))\n\t(send ?new put-tiempo+diario+disponible \n\t\t(replace$ ?tiempos_disponibles 7 7\n\t\t\t(-(nth$ 7 ?tiempos_disponibles) ?tiempo)\n\t\t)\n\t)\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"64176817b5cfc90f5e0059791023cffee4aae2af","subject":"Added overloads for load,load*,batch,batch*","message":"Added overloads for load,load*,batch,batch*\n","repos":"DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"lib\/core.clp","new_file":"lib\/core.clp","new_contents":";------------------------------------------------------------------------------\n;electron-platform\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n\n;------------------------------------------------------------------------------\n; message - Useful for passing information between modules and making it \n; possible to have reusable code.\n;------------------------------------------------------------------------------\n(deftemplate message\n \"A standard way to pass information around\"\n (slot interface)\n (slot to)\n (slot from)\n (slot action)\n (multislot contents))\n\n(defgeneric starts-with)\n(defgeneric contains)\n(defgeneric char-at)\n(defgeneric to-lexeme)\n\n(defmethod starts-with\n \"Checks to see if a given lexeme starts with another lexeme\"\n ((?looking-for LEXEME)\n (?in LEXEME))\n (eq 1 (str-index ?looking-for ?in)))\n\n(defmethod starts-with\n (?looking-for ?in)\n (starts-with (to-lexeme ?looking-for)\n (to-lexeme ?in)))\n\n(defmethod contains\n ((?looking-for LEXEME)\n (?in LEXEME))\n (neq (str-index ?looking-for ?in) FALSE))\n\n(defmethod contains\n (?looking-for ?in)\n (contains (to-lexeme ?looking-for)\n (to-lexeme ?in)))\n\n(defmethod char-at \n ((?index INTEGER)\n (?string LEXEME))\n (sub-string ?index ?index ?string))\n\n(defmethod char-at\n ((?index FLOAT)\n (?string LEXEME))\n (char-at (integer ?index) ?string))\n\n(defmethod to-lexeme\n ((?value LEXEME))\n ?value)\n\n(defmethod to-lexeme\n ((?value (not (lexemep ?value))))\n (str-cat ?value))\n\n(defmethod merge\n (($?atoms INTEGER))\n (merge ?atoms))\n\n(defmethod binary-or\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-or ?number ?value)))\n (return ?number))\n\n(defmethod binary-or\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-or ?values))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-or ?a (binary-or ?b ?c)))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-or ?a (binary-or ?b (binary-or ?c ?d))))\n\n(defmethod binary-and\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-and ?number ?value)))\n (return ?number))\n\n(defmethod binary-and\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-and ?values))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-and ?a (binary-and ?b ?c)))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-and ?a (binary-and ?b (binary-and ?c ?d))))\n\n(defmethod binary-xor\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-xor ?number ?value)))\n (return ?number))\n\n(defmethod binary-xor\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-xor ?values))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-xor ?a (binary-xor ?b ?c)))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-xor ?a (binary-xor ?b (binary-xor ?c ?d))))\n\n; some file-system related quick loaders\n(defmethod load* \n ((?paths LEXEME MULTIFIELD))\n (bind ?output TRUE)\n (progn$ (?path ?paths) \n (bind ?output (and ?output (load* ?path))))\n (return ?output))\n\n(defmethod load*\n (($?paths LEXEME))\n (load* ?paths))\n\n(defmethod load\n ((?paths LEXEME MULTIFIELD))\n (bind ?output TRUE)\n (progn$ (?path ?paths) \n (bind ?output (and ?output (load ?path))))\n (return ?output))\n\n(defmethod load\n (($?paths LEXEME))\n (load ?paths))\n\n(defmethod batch\n ((?paths LEXEME MULTIFIELD))\n (bind ?output TRUE)\n (progn$ (?path ?paths) \n (bind ?output (and ?output (batch ?path))))\n (return ?output))\n\n(defmethod batch\n (($?paths LEXEME))\n (batch ?paths))\n\n(defmethod batch*\n ((?paths LEXEME MULTIFIELD))\n (bind ?output TRUE)\n (progn$ (?path ?paths) \n (bind ?output (and ?output (batch* ?path))))\n (return ?output))\n\n(defmethod batch*\n (($?paths LEXEME))\n (batch* ?paths))\n","old_contents":";------------------------------------------------------------------------------\n;electron-platform\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n\n;------------------------------------------------------------------------------\n; message - Useful for passing information between modules and making it \n; possible to have reusable code.\n;------------------------------------------------------------------------------\n(deftemplate message\n \"A standard way to pass information around\"\n (slot interface)\n (slot to)\n (slot from)\n (slot action)\n (multislot contents))\n\n(defgeneric starts-with)\n(defgeneric contains)\n(defgeneric char-at)\n(defgeneric to-lexeme)\n\n(defmethod starts-with\n \"Checks to see if a given lexeme starts with another lexeme\"\n ((?looking-for LEXEME)\n (?in LEXEME))\n (eq 1 (str-index ?looking-for ?in)))\n\n(defmethod starts-with\n (?looking-for ?in)\n (starts-with (to-lexeme ?looking-for)\n (to-lexeme ?in)))\n\n(defmethod contains\n ((?looking-for LEXEME)\n (?in LEXEME))\n (neq (str-index ?looking-for ?in) FALSE))\n\n(defmethod contains\n (?looking-for ?in)\n (contains (to-lexeme ?looking-for)\n (to-lexeme ?in)))\n\n(defmethod char-at \n ((?index INTEGER)\n (?string LEXEME))\n (sub-string ?index ?index ?string))\n\n(defmethod char-at\n ((?index FLOAT)\n (?string LEXEME))\n (char-at (integer ?index) ?string))\n\n(defmethod to-lexeme\n ((?value LEXEME))\n ?value)\n\n(defmethod to-lexeme\n ((?value (not (lexemep ?value))))\n (str-cat ?value))\n\n(defmethod merge\n (($?atoms INTEGER))\n (merge ?atoms))\n\n(defmethod binary-or\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-or ?number ?value)))\n (return ?number))\n\n(defmethod binary-or\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-or ?values))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-or ?a (binary-or ?b ?c)))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-or ?a (binary-or ?b (binary-or ?c ?d))))\n\n(defmethod binary-and\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-and ?number ?value)))\n (return ?number))\n\n(defmethod binary-and\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-and ?values))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-and ?a (binary-and ?b ?c)))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-and ?a (binary-and ?b (binary-and ?c ?d))))\n\n(defmethod binary-xor\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-xor ?number ?value)))\n (return ?number))\n\n(defmethod binary-xor\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-xor ?values))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-xor ?a (binary-xor ?b ?c)))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-xor ?a (binary-xor ?b (binary-xor ?c ?d))))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c5f6049ad4be80cb6db9168a3850151a6d8ca039","subject":"Finished porting wavefront-scheduling-merge-update","message":"Finished porting wavefront-scheduling-merge-update\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveInstructionsFromProducers\n (declare (salience 768))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Remove evidence of ?tInst from instructions ?inst $?insts)\n ?iObj <- (object (is-a Instruction) \n (ID ?inst) \n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (retract ?fct)\n (assert (Remove evidence of ?tInst from instructions $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda))\n (slot-insert$ ?iObj NonLocalDependencies 1 ?tInst))\n;------------------------------------------------------------------------------\n(defrule RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Remove evidence of ? from instructions)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule StartRecomputeBlock\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b)\n ?bb <- (object (is-a BasicBlock) (ID ?b) \n (Contents $?instructions ?last))\n (object (is-a TerminatorInstruction) (ID ?last))\n =>\n (modify-instance ?bb (ReadsFrom) (WritesTo) (HasMemoryBarrier FALSE))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?instructions)))\n;------------------------------------------------------------------------------\n(defrule RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a BasicBlock) (ID ?b))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (ID ?inst) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeLoadInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a LoadInstruction) (ID ?inst) (Parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) (ID ?b))\n =>\n (if (not (member$ ?mt (send ?bb get-ReadsFrom))) then\n (slot-insert$ ?bb ReadsFrom 1 ?mt))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeStoreInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a StoreInstruction) (ID ?inst) (Parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) (ID ?b))\n =>\n (if (not (member$ ?mt (send ?bb get-WritesTo))) then\n (slot-insert$ ?bb WritesTo 1 ?mt))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishRecomputationForBlock\n (declare (salience 98))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions)\n ?bb <- (object (is-a BasicBlock) (ID ?b) (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6f70ca3e50fa6ce6739a7c07d10f44237170922a","subject":"early stage ban variable","message":"early stage ban variable\n","repos":"yzaguirre\/P1IA","old_file":"src\/run.clp","new_file":"src\/run.clp","new_contents":"(deftemplate campeon\n\t(slot nombre (type STRING))\n\t(slot primario (type STRING))\n\t(slot secundario (type STRING))\n\t(slot salud (type INTEGER))\n\t(slot ataque (type INTEGER))\n\t(slot hechizo (type INTEGER))\n\t(slot dificultad (type INTEGER))\n\t(slot fecha (type STRING))\n\t(slot puntosip (type INTEGER))\n\t(slot puntosrp (type INTEGER))\n\t(slot prioridad (type INTEGER))\n\t(multislot ga)\n\t(multislot ba)\n\t(multislot gw)\n\t(slot ban (type INTEGER))\n)\n; Aatrox\n(defglobal ?*op1* = 0)\n(defglobal ?*op2* = 0)\n(defglobal ?*op3* = 0)\n(defglobal ?*ban1* = 0)\n(defglobal ?*ban2* = 0)\n(defglobal ?*ban3* = 0)\n(defglobal ?*ban4* = 0)\n(defglobal ?*ban5* = 0)\n(defglobal ?*ban6* = 0)\n(defrule Ingreso-Informacion-UserPlayer\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(equipo ?equipo)\n\t=>\n\t(printout t \"Ingrese el # de jugador (1 - 6) del equipo \" ?equipo \": \")\n\t(assert (player =(readline)))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-UserTeam\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban6 ?ban6)\n\t?b6 <- (campeon (nombre ?ban6))\n\t=>\n\t(printout t \"Ingrese equipo a pertener, Azul o Morado: \")\n\t(assert (equipo =(readline)))\n\t(modify ?b6 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban6\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban5 ?ban5)\n\t?b5 <- (campeon (nombre ?ban5))\n\t=>\n\t(printout t \"Capitan equipo azul,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 6 a bannear: \")\n\t(assert (ban6 =(readline)))\n\t(modify ?b5 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban5\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban4 ?ban4)\n\t?b4 <- (campeon (nombre ?ban4))\n\t=>\n\t(printout t \"Capitan equipo morado,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 5 a bannear: \")\n\t(assert (ban5 =(readline)))\n\t(modify ?b4 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban4\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban3 ?ban3)\n\t?b3 <- (campeon (nombre ?ban3))\n\t=>\n\t(printout t \"Capitan equipo morado,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 4 a bannear: \")\n\t(assert (ban4 =(readline)))\n\t(modify ?b3 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban3\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban2 ?ban2)\n\t?b2 <- (campeon (nombre ?ban2))\n\t=>\n\t(printout t \"Capitan equipo azul,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 3 a bannear: \")\n\t(assert (ban3 =(readline)))\n\t(modify ?b2 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban2\n\t(declare (salience 201))\n\t;(flag201 ?flag201)\n\t(ban1 ?ban1)\n\t?b1 <- (campeon (nombre ?ban1))\n\t=>\n\t(printout t \"Capitan equipo morado,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 2 a bannear: \")\n\t(assert (ban2 =(readline)))\n\t(modify ?b1 (ban 1))\n\t(printout t crlf)\n)\n(defrule Ingreso-Informacion-Ban1\n(declare (salience 201))\n (initial-fact)\n=>\t\n\t(printout t \"Modo Blind-Pick\" crlf)\n\t(printout t \"Capitan equipo azul,\" crlf)\n\t(printout t \"Ingrese nombre de campeon 1 a bannear: \")\n\t(bind ?*ban1* (readline))\n\t;(assert (flag201 1))\n\t(assert (campeon\n (nombre \"Aatrox\")\n (primario \"Fighter\")\n (secundario \"Tank\")\n (salud 4)\n (ataque 8)\n (hechizo 3)\n (dificultad 6)\n (fecha \"2013-06-13\")\n (puntosip 6300)\n (puntosrp 975)\n (prioridad 100)\n (ga \"Yasuo\" \"Dr. Mundo\" \"Jinx\" \"Darius\" \"Katarina\" \"Nasus\" \"Akali\" \"Kassadin\" \"Zed\" \"Hecarim\")\n (ba \"Jax\" \"LeBlanc\" \"Fiora\" \"Riven\" \"Teemo\" \"Pantheon\" \"Pantheon\" \"Yasuo\" \"Fizz\" \"Renekton\")\n (gw \"Yasuo\" \"Caitlyn\" \"Darius\" \"Jinx\" \"Akali\" \"Teemo\" \"Ezreal\" \"Varus\" \"Thresh\" \"Corki\")\n (ban 0)\n ))\n\t(printout t crlf)\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/run.clp' did not match any file(s) known to git\n","license":"mpl-2.0","lang":"CLIPS"} {"commit":"b0cd018cf8c80e492bd5b05d6258091675a6c71a","subject":"Joan deixa de fer spoilers","message":"Joan deixa de fer spoilers\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (class ?aux) \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(bind ?actividad (nth$ ?respuesta ?lista_actividades))\n\t\t(send ?actividad put-duracion (pregunta-numerica \"Cuanto dura la actividad? (minutos)\" 0 600))\n\t\t(send ?actividad put-frequencia (ask-question \"Con que frequencia? [Diaria|Semanal|Mensual] \" Diaria Semanal Mensual))\n\t\t(slot-insert$ ?persona actividades 1 ?actividad)\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)","old_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer)))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_actividades))\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"90a2deed2099c7781e7a86c584f576b231d36b04","subject":"Fixed the merge method in \/lib\/sys\/core\/extensions.clp","message":"Fixed the merge method in \/lib\/sys\/core\/extensions.clp\n","repos":"DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-filesystem","old_file":"lib\/sys\/core\/extensions.clp","new_file":"lib\/sys\/core\/extensions.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; extensions.clp - extends native functions to make them easier to use\n;\n;------------------------------------------------------------------------------\n(defmethod merge\n (($?atoms INTEGER))\n (merge ?atoms))\n;------------------------------------------------------------------------------\n(defmethod binary-or\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-or ?number ?value)))\n (return ?number))\n\n(defmethod binary-or\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-or ?values))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-or ?a (binary-or ?b ?c)))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-or ?a (binary-or ?b (binary-or ?c ?d))))\n\n;------------------------------------------------------------------------------\n\n(defmethod binary-and\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-and ?number ?value)))\n (return ?number))\n\n(defmethod binary-and\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-and ?values))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-and ?a (binary-and ?b ?c)))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-and ?a (binary-and ?b (binary-and ?c ?d))))\n;------------------------------------------------------------------------------\n\n(defmethod binary-xor\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-xor ?number ?value)))\n (return ?number))\n\n(defmethod binary-xor\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-xor ?values))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-xor ?a (binary-xor ?b ?c)))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-xor ?a (binary-xor ?b (binary-xor ?c ?d))))\n","old_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR \n;ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; extensions.clp - extends native functions to make them easier to use\n;\n;------------------------------------------------------------------------------\n(defmethod merge\n ($?atoms INTEGER)\n (merge ?atoms))\n;------------------------------------------------------------------------------\n(defmethod binary-or\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-or ?number ?value)))\n (return ?number))\n\n(defmethod binary-or\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-or ?values))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-or ?a (binary-or ?b ?c)))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-or ?a (binary-or ?b (binary-or ?c ?d))))\n\n;------------------------------------------------------------------------------\n\n(defmethod binary-and\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-and ?number ?value)))\n (return ?number))\n\n(defmethod binary-and\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-and ?values))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-and ?a (binary-and ?b ?c)))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-and ?a (binary-and ?b (binary-and ?c ?d))))\n;------------------------------------------------------------------------------\n\n(defmethod binary-xor\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-xor ?number ?value)))\n (return ?number))\n\n(defmethod binary-xor\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-xor ?values))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-xor ?a (binary-xor ?b ?c)))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-xor ?a (binary-xor ?b (binary-xor ?c ?d))))\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"70bc32cccaec309cf33d23d68c70a35bd6ffcfec","subject":"Added the default bootstrap.clp in etc\/skel","message":"Added the default bootstrap.clp in etc\/skel\n\nThis file has to be batched and it will bootstrap the system, providing import\nand other things.\n","repos":"DrItanium\/electron-filesystem,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"etc\/skel\/bootstrap.clp","new_file":"etc\/skel\/bootstrap.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; bootstrap.clp - Bootstraps the file system and loads sys.clp. It is up to a\n; shell script to call electron with the customized version of this file.\n;\n; This file has to be batched\n;------------------------------------------------------------------------------\n(defglobal MAIN\n ; Change the value of this global to change the name of the\n ; corresponding shell variable.\n ?*electron-fs-root* = ElectronFSRoot\n ; Use this to make sure that we fail out if we can't bootstrap\n ?*fsys* = (progn (bind ?result (get-shell-variable ?*electron-fs-root*))\n (if (not ?result) then\n (printout t \"ERROR: \" ?*electron-fs-root* \" not defined - Exiting\" crlf)\n (exit)\n else\n ?result)))\n; Can't do loads within defglobal calls because it could cause crashes if\n; we do a defglobal within a defglobal.\n\n; Load the filesystem base points\n(load* (format nil \"%s\/etc\/sys.clp\" ?*fsys*))\n; Load the system base (import commands)\n(load* (format nil \"%s\/import\/import.clp\" ?*lib*))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'etc\/skel\/bootstrap.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"afda2bcf43cc10308c75066636e036abe0d41f00","subject":"fixed a bug where the set of producers was not being added","message":"fixed a bug where the set of producers was not being added\n\nThis occurs during wavefront-scheduling when we are recomputing the\ndependencies for the instructions that have been moved into instructions on the\nwavefront\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (if (not (member$ ?o $?nld)) then\n (modify-instance ?inst (NonLocalDependencies $?nld ?o))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a Object&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (if (not (member$ ?o $?nld)) then\n (modify-instance ?inst (NonLocalDependencies $?nld ?o))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ?tInst => ?inst $?insts))\n ?iObj <- (object (is-a Instruction) \n (id ?inst) \n (NonLocalDependencies $?nld)\n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (modify ?fct (arguments ?tInst => $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda)\n (NonLocalDependencies $?nld ?tInst)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n ?fct <- (message (to wavefront-scheduling)\n (action remove-evidence)\n (arguments ? =>))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::StartRecomputeBlock\n (declare (salience 100))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block)\n (arguments ?b))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents $?instructions ?last))\n (object (is-a TerminatorInstruction) \n (id ?last))\n =>\n (modify-instance ?bb \n (ReadsFrom) \n (WritesTo) \n (HasMemoryBarrier FALSE))\n (modify ?fct \n (action recompute-block-with-instructions)\n (arguments ?b => $?instructions)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (id ?inst) \n (parent ?b))\n =>\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeLoadInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a LoadInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (ReadsFrom $?rf))\n =>\n (if (not (member$ ?mt $?rf)) then\n (modify-instance ?bb (ReadsFrom $?rf ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::RecomputeStoreInstructionForBlock\n (declare (salience 99))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b => ?inst $?rest))\n (object (is-a StoreInstruction) \n (id ?inst) \n (parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) \n (id ?b)\n (WritesTo $?wt))\n =>\n (if (not (member$ ?mt $?wt)) then\n (modify-instance ?bb (WritesTo $?wt ?mt)))\n (modify ?fct (arguments ?b => $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-merge-update::FinishRecomputationForBlock\n (declare (salience 98))\n ?fct <- (message (to wavefront-scheduling)\n (action recompute-block-with-instructions)\n (arguments ?b =>))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d65498b31d47521569d92976f32b39ab4f7b3305","subject":"init\/DeclareLogicFunctions.clp: Fixed bugs in logic-files","message":"init\/DeclareLogicFunctions.clp: Fixed bugs in logic-files\n\nI renamed the ?name variable to ?offset\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"init\/DeclareLogicFunctions.clp","new_file":"init\/DeclareLogicFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLogicFunctions.clp - Defines functions to load code from the\n; logic folder \n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-logic\n \"Loads logic\/\/Entry.clp.\" \n (?folder-name)\n (batch* (format nil \"logic\/%s\/Entry.clp\" ?folder-name)))\n;------------------------------------------------------------------------------\n(deffunction init::logic-files\n \"Loads a series of logic files from the specified path\"\n (?offset $?files)\n (bind ?coreOffset (format nil \"logic\/%s\/%s\" ?offset \"%s\"))\n (progn$ (?a $?files)\n (batch* (format nil ?coreOffset ?a))))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; DeclareLogicFunctions.clp - Defines functions to load code from the\n; logic folder \n; \n; Written by Joshua Scoggins \n; Started on 3\/13\/2013\n;------------------------------------------------------------------------------\n(deffunction init::load-logic\n \"Loads logic\/\/Entry.clp.\" \n (?folder-name)\n (batch* (format nil \"logic\/%s\/Entry.clp\" ?folder-name)))\n;------------------------------------------------------------------------------\n(deffunction init::logic-files\n \"Loads a series of files from the specified path in the logic folder\"\n (?name $?files)\n (bind ?coreOffset (format nil \"logic\/%s\/%s\" ?offset \"%s\"))\n (progn$ (?a $?files)\n (batch* (format nil ?coreOffset ?a))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"7f5ecea2d398d8be8d889fc350bf443464172745","subject":"Modified MemoryBarrierCreation.clp to speed up merger of ReadsFrom and WritesTo","message":"Modified MemoryBarrierCreation.clp to speed up merger of ReadsFrom and WritesTo\n\nI did this by modifying the merger process to only merge with a single\n\"control\" fact that contained all of the merged elements. This merged message\nwas then used solely to great effect in the actual update process.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/MemoryBarrierCreation.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/MemoryBarrierCreation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MemoryBarrierCreation.clp - Contains rules pertaining to the creation of\n; memory barriers to prevent loads and stores from being moved above a specific\n; point within the program during the act of scheduling.\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n; Barriers consist of reads and writes that can't be verified as to their exact\n; source. \n;------------------------------------------------------------------------------\n; TODO: Put in a field for load and store instructions that describes what\n; is being referenced. By default this slot is UNKNOWN.\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::AssertLoadBarrierEvaluation\n\t\t\t\"Creates a fact that tells the system to analyze the given load \n\t\t\tinstruction to see if it is necessary to create a memory barrier for \n\t\t\tthe given instruction\"\n\t\t\t(declare (salience 5))\n\t\t\t(object (is-a LoadInstruction) (id ?t0) (Operands ?target $?))\n\t\t\t=>\n\t\t\t(assert (Analyze ?target for load ?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::AssertStoreBarrierEvaluation\n\t\t\t\"Creates a fact that tells the system to analyze the given store \n\t\t\tinstruction to see if it is necessary to create a memory barrier for \n\t\t\tthe given instruction\"\n\t\t\t(declare (salience 5))\n\t\t\t(object (is-a StoreInstruction) (id ?t0) \n\t\t\t\t\t (DestinationRegisters ?target))\n\t\t\t=>\n\t\t\t(assert (Analyze ?target for store ?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGetElementPointerLoadBarrier\n\t\t\t\"Creates a load memory barrier hint if it turns out that the load \n\t\t\tinstruction refers to a getelementptr instruction but that \n\t\t\tgetelementptr doesn't refer to a alloca instruction or constant.\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a ~AllocaInstruction&~Constant) (id ?a))\n\t\t\t(object (is-a BasicBlock) (id ?p) (parent ?r))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget UNKNOWN))\n\t\t\t(assert (element ?p reads from UNKNOWN)\n\t\t\t\t\t (Element ?p has a MemoryBarrier)\n\t\t\t\t\t (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-Alloca\n\t\t\t\"Does a check to see if the load instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock reads from it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a AllocaInstruction) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p reads from ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-Constant\n\t\t\t\"Does a check to see if the load instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock reads from it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a Constant) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p reads from ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-GetElementPointer-Alloca\n\t\t\t\"Does a check to see if a given LoadInstruction referring to a\n\t\t\tGetElementPointerInstruction refers to an AllocaInstruction or \n\t\t\tConstant. If it does then mark it in the ReadsFrom multifield\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a AllocaInstruction) (id ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?a))\n\t\t\t(assert (element ?p reads from ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-GetElementPointer-Constant\n\t\t\t\"Does a check to see if a given LoadInstruction referring to a\n\t\t\tGetElementPointerInstruction refers to an AllocaInstruction or \n\t\t\tConstant. If it does then mark it in the ReadsFrom multifield\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a Constant) (id ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?a))\n\t\t\t(assert (element ?p reads from ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGeneralLoadBarrier\n\t\t\t\"Creates a load memory barrier hint if it turns out that the load \n\t\t\tinstruction in question refers to a register that isn't an \n\t\t\tAllocaInstruction, GetElementPointerInstruction, or Constant.\"\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (Analyze ?target for load ?t0)\n\t\t\t?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a BasicBlock) (id ?p) (parent ?r))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget UNKNOWN))\n\t\t\t(assert (element ?p reads from UNKNOWN)\n\t\t\t\t\t (Element ?p has a MemoryBarrier)\n\t\t\t\t\t (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGetElementPointerStoreBarrier\n\t\t\t\"Creates a store memory barrier hint if it turns out that the store \n\t\t\tinstruction refers to a getelementptr instruction but that \n\t\t\tgetelementptr doesn't refer to a alloca instruction or constant.\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (parent ?p) (id ?t0))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a ~AllocaInstruction&~Constant) (id ?a))\n\t\t\t(object (is-a BasicBlock) (id ?p) (parent ?r))\n\t\t\t=>\n\t\t\t(modify-instance ?i0 (MemoryTarget UNKNOWN))\n\t\t\t(retract ?fct)\n\t\t\t(assert (element ?p writes to UNKNOWN)\n\t\t\t\t\t (Element ?p has a MemoryBarrier)\n\t\t\t\t\t (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Alloca\n\t\t\t\"Does a check to see if the load instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock writes to it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a AllocaInstruction) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Constant\n\t\t\t\"Does a check to see if the store instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock writes to it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a Constant) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Single-Alloca\n\t\t\t\"Does a check to see if the store instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock writes to it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a AllocaInstruction) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Single-Constant\n\t\t\t\"Does a check to see if the store instruction refers directly to an\n\t\t\tAllocaInstruction or Constant. If it does then mark it as though the \n\t\t\tblock writes to it\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a Constant) (id ?target))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?target))\n\t\t\t(assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-GetElementPointer-Alloca\n\t\t\t\"Does a check to see if a given StoreInstruction referring to a\n\t\t\tGetElementPointerInstruction refers to an AllocaInstruction or \n\t\t\tConstant. If it does then mark it in the WritesTo multifield\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a AllocaInstruction) (id ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?a))\n\t\t\t(assert (element ?p writes to ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-GetElementPointer-Constant\n\t\t\t\"Does a check to see if a given StoreInstruction referring to a\n\t\t\tGetElementPointerInstruction refers to an AllocaInstruction or \n\t\t\tConstant. If it does then mark it in the WritesTo multifield\"\n\t\t\t(declare (salience 4))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a GetElementPointerInstruction) (id ?target) \n\t\t\t\t\t (Operands ?a $?))\n\t\t\t(object (is-a Constant) (id ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget ?a))\n\t\t\t(assert (element ?p writes to ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGeneralStoreBarrier\n\t\t\t\"Creates a store memory barrier hint if it turns out that the load \n\t\t\tinstruction in question refers to a register that isn't an \n\t\t\tAllocaInstruction, GetElementPointerInstruction, or Constant.\"\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (Analyze ?target for store ?t0)\n\t\t\t?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n\t\t\t(object (is-a BasicBlock) (id ?p) (parent ?r))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?i0 (MemoryTarget UNKNOWN))\n\t\t\t(assert (element ?p writes to UNKNOWN)\n\t\t\t\t\t (Element ?p has a MemoryBarrier)\n\t\t\t\t\t (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InitializeReadsFromMerger\n\t\t\t?f0 <- (element ?p reads from $?t0)\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t (action reads-from-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?p => $?))))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action reads-from-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t0))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InitializeWritesToMerger\n\t\t\t?f0 <- (element ?p writes to $?t0)\n\t\t\t(not (exists (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t\t\t (action writes-to-list)\n\t\t\t\t\t\t\t\t\t\t (arguments ?p => $?))))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(assert (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action writes-to-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t0))))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MergeReadsFrom\n\t\t\t?f0 <- (element ?p reads from $?t0)\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action reads-from-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?p => $?t1 $?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MergeWritesTo\n\t\t\t?f0 <- (element ?p writes to $?t0)\n\t\t\t?f1 <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action writes-to-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t1))\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(modify ?f1 (arguments ?p => $?t1 $?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatReadsFrom-ParentDoesntExist\n\t\t\t(declare (salience -9))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action reads-from-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t))\n\t\t\t?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?q))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(slot-insert$ ?bb ReadsFrom 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatReadsFrom-ParentExists\n\t\t\t(declare (salience -9))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action reads-from-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t))\n\t\t\t?bb <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t(id ?p) \n\t\t\t\t\t\t\t\t(parent ?q))\n\t\t\t(exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t (id ?q)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?q => ?t))\n\t\t\t(slot-insert$ ?bb ReadsFrom 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatWritesTo-ParentDoesntExist\n\t\t\t(declare (salience -9))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action writes-to-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t))\n\t\t\t?bb <- (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t(id ?p) \n\t\t\t\t\t\t\t\t(parent ?q))\n\t\t\t(not (exists (object (is-a Diplomat) \n\t\t\t\t\t\t\t\t\t\t(id ?q))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(slot-insert$ ?bb WritesTo 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatWritesTo-ParentExists\n\t\t\t(declare (salience -9))\n\t\t\t?fct <- (message (to dependency-analysis)\n\t\t\t\t\t\t\t\t (action writes-to-list)\n\t\t\t\t\t\t\t\t (arguments ?p => $?t))\n\t\t\t?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n\t\t\t(exists (object (is-a Diplomat) (id ?q)))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?q => $?t))\n\t\t\t(slot-insert$ ?bb WritesTo 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::UpdateDiplomatHasMemoryBarrier\n\t\t\t(declare (salience -10))\n\t\t\t?fct <- (Element ?b has a MemoryBarrier)\n\t\t\t?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier FALSE)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Element ?p has a MemoryBarrier))\n\t\t\t(modify-instance ?obj (HasMemoryBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::RetractDiplomatHasMemoryBarrier\n\t\t\t(declare (salience -10))\n\t\t\t?fct <- (Element ?b has a MemoryBarrier)\n\t\t\t?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier TRUE)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(exists (object (is-a Diplomat) (id ?p)))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Element ?p has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::UpdateDiplomatHasMemoryBarrier-ParentDoesntExist\n\t\t\t(declare (salience -10))\n\t\t\t?fct <- (Element ?b has a MemoryBarrier)\n\t\t\t?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier FALSE)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (HasMemoryBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::RetractDiplomatHasMemoryBarrier-ParentDoesntExist\n\t\t\t(declare (salience -10))\n\t\t\t?fct <- (Element ?b has a MemoryBarrier)\n\t\t\t?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier TRUE)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(not (exists (object (is-a Diplomat) (id ?p))))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; MemoryBarrierCreation.clp - Contains rules pertaining to the creation of\n; memory barriers to prevent loads and stores from being moved above a specific\n; point within the program during the act of scheduling.\n; Written by Joshua Scoggins (7\/1\/2012)\n;------------------------------------------------------------------------------\n; Barriers consist of reads and writes that can't be verified as to their exact\n; source. \n;------------------------------------------------------------------------------\n; TODO: Put in a field for load and store instructions that describes what\n; is being referenced. By default this slot is UNKNOWN.\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::AssertLoadBarrierEvaluation\n \"Creates a fact that tells the system to analyze the given load \n instruction to see if it is necessary to create a memory barrier for \n the given instruction\"\n (declare (salience 5))\n (object (is-a LoadInstruction) (id ?t0) (Operands ?target $?))\n =>\n (assert (Analyze ?target for load ?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::AssertStoreBarrierEvaluation\n \"Creates a fact that tells the system to analyze the given store \n instruction to see if it is necessary to create a memory barrier for \n the given instruction\"\n (declare (salience 5))\n (object (is-a StoreInstruction) (id ?t0) \n (DestinationRegisters ?target))\n =>\n (assert (Analyze ?target for store ?t0)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGetElementPointerLoadBarrier\n \"Creates a load memory barrier hint if it turns out that the load \n instruction refers to a getelementptr instruction but that \n getelementptr doesn't refer to a alloca instruction or constant.\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a ~AllocaInstruction&~Constant) (id ?a))\n (object (is-a BasicBlock) (id ?p) (parent ?r))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget UNKNOWN))\n (assert (element ?p reads from UNKNOWN)\n (Element ?p has a MemoryBarrier)\n (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-Alloca\n \"Does a check to see if the load instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block reads from it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a AllocaInstruction) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p reads from ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-Constant\n \"Does a check to see if the load instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block reads from it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a Constant) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p reads from ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-GetElementPointer-Alloca\n \"Does a check to see if a given LoadInstruction referring to a\n GetElementPointerInstruction refers to an AllocaInstruction or \n Constant. If it does then mark it in the ReadsFrom multifield\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a AllocaInstruction) (id ?a))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?a))\n (assert (element ?p reads from ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithReadFrom-GetElementPointer-Constant\n \"Does a check to see if a given LoadInstruction referring to a\n GetElementPointerInstruction refers to an AllocaInstruction or \n Constant. If it does then mark it in the ReadsFrom multifield\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a Constant) (id ?a))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?a))\n (assert (element ?p reads from ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGeneralLoadBarrier\n \"Creates a load memory barrier hint if it turns out that the load \n instruction in question refers to a register that isn't an \n AllocaInstruction, GetElementPointerInstruction, or Constant.\"\n (declare (salience 3))\n ?fct <- (Analyze ?target for load ?t0)\n ?i0 <- (object (is-a LoadInstruction) (id ?t0) (parent ?p))\n (object (is-a BasicBlock) (id ?p) (parent ?r))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget UNKNOWN))\n (assert (element ?p reads from UNKNOWN)\n (Element ?p has a MemoryBarrier)\n (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGetElementPointerStoreBarrier\n \"Creates a store memory barrier hint if it turns out that the store \n instruction refers to a getelementptr instruction but that \n getelementptr doesn't refer to a alloca instruction or constant.\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (parent ?p) (id ?t0))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a ~AllocaInstruction&~Constant) (id ?a))\n (object (is-a BasicBlock) (id ?p) (parent ?r))\n =>\n (modify-instance ?i0 (MemoryTarget UNKNOWN))\n (retract ?fct)\n (assert (element ?p writes to UNKNOWN)\n (Element ?p has a MemoryBarrier)\n (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Alloca\n \"Does a check to see if the load instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block writes to it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a AllocaInstruction) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Constant\n \"Does a check to see if the store instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block writes to it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a Constant) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Single-Alloca\n \"Does a check to see if the store instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block writes to it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a AllocaInstruction) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-Single-Constant\n \"Does a check to see if the store instruction refers directly to an\n AllocaInstruction or Constant. If it does then mark it as though the \n block writes to it\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a Constant) (id ?target))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?target))\n (assert (element ?p writes to ?target)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-GetElementPointer-Alloca\n \"Does a check to see if a given StoreInstruction referring to a\n GetElementPointerInstruction refers to an AllocaInstruction or \n Constant. If it does then mark it in the WritesTo multifield\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a AllocaInstruction) (id ?a))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?a))\n (assert (element ?p writes to ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::PopulateBasicBlockWithWriteTo-GetElementPointer-Constant\n \"Does a check to see if a given StoreInstruction referring to a\n GetElementPointerInstruction refers to an AllocaInstruction or \n Constant. If it does then mark it in the WritesTo multifield\"\n (declare (salience 4))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a GetElementPointerInstruction) (id ?target) \n (Operands ?a $?))\n (object (is-a Constant) (id ?a))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget ?a))\n (assert (element ?p writes to ?a)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::IdentifyGeneralStoreBarrier\n \"Creates a store memory barrier hint if it turns out that the load \n instruction in question refers to a register that isn't an \n AllocaInstruction, GetElementPointerInstruction, or Constant.\"\n (declare (salience 3))\n ?fct <- (Analyze ?target for store ?t0)\n ?i0 <- (object (is-a StoreInstruction) (id ?t0) (parent ?p))\n (object (is-a BasicBlock) (id ?p) (parent ?r))\n =>\n (retract ?fct)\n (modify-instance ?i0 (MemoryTarget UNKNOWN))\n (assert (element ?p writes to UNKNOWN)\n (Element ?p has a MemoryBarrier)\n (Element ?r has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MergeReadsFrom\n ?f0 <- (element ?p reads from $?t0)\n ?f1 <- (element ?p reads from $?t1)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (element ?p reads from $?t0 $?t1)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::MergeWritesTo\n ?f0 <- (element ?p writes to $?t0)\n ?f1 <- (element ?p writes to $?t1)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (element ?p writes to $?t0 $?t1)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatReadsFrom-ParentDoesntExist\n (declare (salience -9))\n ?fct <- (element ?p reads from $?t)\n ?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n (not (exists (object (is-a Diplomat) (id ?q))))\n =>\n (retract ?fct)\n (slot-insert$ ?bb ReadsFrom 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatReadsFrom-ParentExists\n (declare (salience -9))\n ?fct <- (element ?p reads from $?t)\n ?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n (exists (object (is-a Diplomat) (id ?q)))\n =>\n (retract ?fct)\n (assert (element ?q reads from ?t))\n (slot-insert$ ?bb ReadsFrom 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatWritesTo-ParentDoesntExist\n (declare (salience -9))\n ?fct <- (element ?p writes to $?t)\n ?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n (not (exists (object (is-a Diplomat) (id ?q))))\n =>\n (retract ?fct)\n (slot-insert$ ?bb WritesTo 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::InsertIntoDiplomatWritesTo-ParentExists\n (declare (salience -9))\n ?fct <- (element ?p writes to $?t)\n ?bb <- (object (is-a Diplomat) (id ?p) (parent ?q))\n (exists (object (is-a Diplomat) (id ?q)))\n =>\n (retract ?fct)\n (assert (element ?q writes to ?t))\n (slot-insert$ ?bb WritesTo 1 ?t))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::UpdateDiplomatHasMemoryBarrier\n (declare (salience -10))\n ?fct <- (Element ?b has a MemoryBarrier)\n ?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier FALSE)\n (parent ?p))\n (exists (object (is-a Diplomat) (id ?p)))\n =>\n (retract ?fct)\n (assert (Element ?p has a MemoryBarrier))\n (modify-instance ?obj (HasMemoryBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::RetractDiplomatHasMemoryBarrier\n (declare (salience -10))\n ?fct <- (Element ?b has a MemoryBarrier)\n ?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier TRUE)\n (parent ?p))\n (exists (object (is-a Diplomat) (id ?p)))\n =>\n (retract ?fct)\n (assert (Element ?p has a MemoryBarrier)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::UpdateDiplomatHasMemoryBarrier-ParentDoesntExist\n (declare (salience -10))\n ?fct <- (Element ?b has a MemoryBarrier)\n ?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier FALSE)\n (parent ?p))\n (not (exists (object (is-a Diplomat) (id ?p))))\n =>\n (retract ?fct)\n (modify-instance ?obj (HasMemoryBarrier TRUE)))\n;------------------------------------------------------------------------------\n(defrule dependency-analysis-analysis::RetractDiplomatHasMemoryBarrier-ParentDoesntExist\n (declare (salience -10))\n ?fct <- (Element ?b has a MemoryBarrier)\n ?obj <- (object (is-a Diplomat) (id ?b) (HasMemoryBarrier TRUE)\n (parent ?p))\n (not (exists (object (is-a Diplomat) (id ?p))))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"1d5e9f7ebe8ce7a9d9078ba1e2269d8bb2ee02d3","subject":"Archivo Clips","message":"Archivo Clips\n\nEjemplo b\u00e1sico en Clips.","repos":"cfernandezmanci\/tfi-SistemasExpertos","old_file":"Empresas.clp","new_file":"Empresas.clp","new_contents":"; Datos de Empresas\n\n(deftemplate Empresas\n(field Nombre)\n(field Tipo)\n(field Pais)\n(field Ciudad)\n(field ComercioExterior)\n(field Puntaje)\n)\n\n(deffacts VariasEmpresasHechos\n(Empresas\n\t(Nombre \"Empresa 1\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Buenos Aires\")\n\t(ComercioExterior \"Nada\")\n\t(Puntaje 40))\n(Empresas\n\t(Nombre \"Empresa 2\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Buenos Aires\")\n\t(ComercioExterior \"Importa\")\n\t(Puntaje 60))\n(Empresas\n\t(Nombre \"Empresa 3\")\n\t(Tipo \"MicroPymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Cordoba\")\n\t(ComercioExterior \"Importa-Exporta\")\n\t(Puntaje 74))\n(Empresas\n\t(Nombre \"Empresa 4\")\n\t(Tipo \"Profesional\")\n\t(Pais Argentina)\n\t(Ciudad \"Concordia\")\n\t(ComercioExterior \"Exporta\")\n\t(Puntaje 90))\n(Empresas\n\t(Nombre \"Empresa 5\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Concordia\")\n\t(ComercioExterior \"Exporta\")\n\t(Puntaje 93))\n(Empresas\n\t(Nombre \"Empresa 6\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Concordia\")\n\t(ComercioExterior \"Exporta\")\n\t(Puntaje 60))\n(Empresas\n\t(Nombre \"Empresa 7\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"Buenos Aires\")\n\t(ComercioExterior \"Exporta\")\n\t(Puntaje 80))\t\t\t\n\n(Empresas\n\t(Nombre \"Empresa 8\")\n\t(Tipo \"Pymes\")\n\t(Pais Argentina)\n\t(Ciudad \"La Plata\")\n\t(ComercioExterior \"Exporta\")\n\t(Puntaje 30))\n\n(Empresas\n\t(Nombre \"Empresa 9\")\n\t(Tipo \"Pymes\")\n\t(Pais Mexico)\n\t(Ciudad \"Guadalajara\")\n\t(ComercioExterior \"Importa-Exporta\")\n\t(Puntaje 30))\t\n\n(Empresas\n\t(Nombre \"Empresa 10\")\n\t(Tipo \"MicroPymes\")\n\t(Pais Peru)\n\t(Ciudad \"Lima\")\n\t(ComercioExterior \"Nada\")\n\t(Puntaje 30))\n\n(Empresas\n\t(Nombre \"Empresa 11\")\n\t(Tipo \"Pymes\")\n\t(Pais Peru)\n\t(Ciudad \"Trujillo\")\n\t(ComercioExterior \"Importa-Exporta\")\n\t(Puntaje 30))\t\t\n)\n\n(defrule ImprimeExporta \n\t(Empresas (ComercioExterior ?ComercioExterior & \"Exporta\"|\"Importa-Exporta\") \n\t(Nombre ?Nombre)\t \t\n\t)\n\t=> \n\t(printout \n\tt crlf \"****************************\"\n\tt crlf ?Nombre \" - \" ?ComercioExterior \" sus productos.\"\n\tt crlf \"****************************\")\n)\n\n(defrule ImprimePymes \n\t(Empresas (Tipo ?Tipo & \"Pymes\") \n\t(Nombre ?Nombre)\n\t(ComercioExterior ?ComercioExterior)\t \t\n\t)\n\t=> \n\t(printout \n\tt crlf \"****************************\"\n\tt crlf ?Nombre \" Es una Pyme. \"\n\tt crlf \"Comercio Exterior: \" ?ComercioExterior)\n\tt crlf \"****************************\"\n)\n\n(defrule ImprimeMayorPtos60 \n\t(Empresas \n\t \t(Puntaje ?Puntaje & :(> ?Puntaje 60)) \n\t\t(Nombre ?Nombre)\t \t\n\t)\n\t=> \n\t(printout \n\tt crlf \"****************************\"\n\tt crlf ?Nombre \" ha completado sus datos. \"\n\tt crlf \"Puntaje : \" ?Puntaje)\n\tt crlf \"****************************\"\n)\n\n\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'Empresas.clp' did not match any file(s) known to git\n","license":"unlicense","lang":"CLIPS"} {"commit":"ae2c4d9a215fe63f83815f014a8879a1adeec7f1","subject":"GLAPIConversion.clp: Added a line about fixed size blocks","message":"GLAPIConversion.clp: Added a line about fixed size blocks\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;\n; The functions that take in a fixed size array are easy because I can allocate\n; a static block ahead of time that I can read and write from. \n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n; So, what do we need to do to construct a single function\n; 0) Generate the registration entry for the target builder\n; 1) Generate the function builder (done)\n; 2) Define required arguments \n; 3) Figure out type conversions\n; 4) Define translation code for each argument\n; 5) Generate code to call the target function with the given arguments\n; 6) Assemble the function together\n;------------------------------------------------------------------------------\n; We use EnvDefineFunction in all cases of registration\n;\n; For conversion of pointers, we take in a multifield from clips and convert\n; that to a corresponding pointer. We can also use macros or a function to\n; do the conversion, that would make this whole process a lot easier. \n;\n; While it goes against the standard practices of C, I am going to have this\n; conversion function perform the malloc and return the pointer. It is up to\n; the function that called the conversion function to clean up the pointer once\n; finished.\n;\n; However, continually calling malloc and free is costly. We can allocate a\n; pointer ahead of time and continually resize it as necessary. We could also\n; define a huge block of memory and then slice it accordingly. \n;\n; I know this for certain, this technique will go through many iterations\n; before I arrive at a valid solution (most likely). \n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index)\n\t\t\t\t\t\t\t\t (id ?argID))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (parsing-entries $?pe)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"6e715376e4121180329657ccdd3c6d7ae3e1ce18","subject":"Fixed a bug in pre-init where get-Contents was being called on a wavefront","message":"Fixed a bug in pre-init where get-Contents was being called on a wavefront\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/pre-init\/WavefrontPreInitialization.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/pre-init\/WavefrontPreInitialization.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::generate-wavefront-object\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (not (exists (object (is-a Wavefront) \n (parent ?p))))\n =>\n (retract ?msg)\n (make-instance of Wavefront \n (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::retract-wavefront-creation-action\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (exists (object (is-a Wavefront) \n (parent ?p)))\n =>\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-block-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r))\n =>\n (assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-region-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ~?r))\n (object (is-a Region) \n (parent ?r) \n (Entrances $? ?e $?) \n (id ?q))\n =>\n (assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n ?f1 <- (Add ?v1&~?v0 to wavefront for ?r)\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-multi-multi=>multi\n (declare (salience 1))\n ?f0 <- (In wavefront ?r add $?a)\n ?f1 <- (In wavefront ?r add $?b)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n =>\n (retract ?f0)\n (assert (In wavefront ?r add ?v0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::construct-wavefront-for-region\n (declare (salience -1))\n ?f <- (In wavefront ?r add $?w)\n ?wave <- (object (is-a Wavefront) \n (parent ?r))\n =>\n (retract ?f)\n (modify-instance ?wave (values $?w)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::generate-wavefront-object\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (not (exists (object (is-a Wavefront) \n (parent ?p))))\n =>\n (retract ?msg)\n (make-instance of Wavefront \n (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::retract-wavefront-creation-action\n (declare (salience 3))\n ?msg <- (message (to wavefront-scheduling)\n (action can-wavefront-schedule)\n (arguments ?p))\n (exists (object (is-a Wavefront) \n (parent ?p)))\n =>\n (retract ?msg))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-block-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ?r))\n =>\n (assert (Add ?e to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::assert-add-region-to-wavefront\n (declare (salience 2))\n (object (is-a Wavefront) \n (parent ?r))\n (object (is-a Region) \n (id ?r) \n (Entrances $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e) \n (parent ~?r))\n (object (is-a Region) \n (parent ?r) \n (Entrances $? ?e $?) \n (id ?q))\n =>\n (assert (Add ?q to wavefront for ?r)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n ?f1 <- (Add ?v1&~?v0 to wavefront for ?r)\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add ?v0 ?v1)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-multi-multi=>multi\n (declare (salience 1))\n ?f0 <- (In wavefront ?r add $?a)\n ?f1 <- (In wavefront ?r add $?b)\n (test (neq ?f0 ?f1))\n =>\n (retract ?f0 ?f1)\n (assert (In wavefront ?r add $?a $?b)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::convert-single=>multi\n (declare (salience 1))\n ?f0 <- (Add ?v0 to wavefront for ?r)\n =>\n (retract ?f0)\n (assert (In wavefront ?r add ?v0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-pre-init::construct-wavefront-for-region\n (declare (salience -1))\n ?f <- (In wavefront ?r add $?w)\n ?wave <- (object (is-a Wavefront) \n (parent ?r))\n =>\n (retract ?f)\n (modify-instance ?wave (contents $?w)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"604097ef014d9ebc1e17961ee621d6d90a8d7d16","subject":"Cleaned up logic\/area.clp","message":"Cleaned up logic\/area.clp\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"logic\/area.clp","new_file":"logic\/area.clp","new_contents":"(load* \/lib\/core.clp)\n(load* \/lib\/chicanery.clp)\n(defgeneric setup-background)\n(deftemplate pen-size\n (slot min \n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1))\n (slot max\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 128))\n (slot current\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1)))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (setup-background)))\n\n(definstances elements\n (menu1 of menu \n (menu-entries cut copy paste))\n (menu2 of menu \n (menu-entries eat sleep drink))\n (region0 of rectangle \n (x 0) \n (y 0) \n (bx 64) \n (by 20))\n (point0 of point \n (x 0) \n (y 32))\n (drawing-field of rectangle \n (x 4) \n (y 25) \n (bx 1020) \n (by 1020))\n (drawing-field-border of rectangle \n (x 0) \n (y 21) \n (bx 1024) \n (by 1024))\n (scratch-rect of rectangle \n (x 0) \n (y 0) \n (bx 0) \n (by 0))\n (text of image \n (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color black)))\n (inset-rect0 of image \n (rectangle [drawing-field-border])\n (replicate TRUE)\n (color (get-standard-color black)))\n (field0 of image \n (rectangle [drawing-field])\n (replicate TRUE)\n (color (get-standard-color white)))\n (button-background of image \n (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color paleyellow)))\n (pixel-image of image \n (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input)\n (pen-size (min 1)\n (max 128)\n (current 1)))\n(defmethod setup-background\n ()\n (screen\/draw [drawing-field-border] [inset-rect0] [ZP])\n (screen\/draw [drawing-field] [field0] [ZP])\n (screen\/draw [region0] [button-background] [ZP])\n (screen\/draw-text [ZP] [text] [ZP] \"File\")\n (screen\/flush 1))\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n (test (intersects ?x ?y [drawing-field]))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n (pen-size (current ?factor))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?factor)) \n (by (+ ?y ?factor)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3)\n (position ?x ?y))\n (test (intersects ?x ?y [region0]))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?pen <- (pen-size \n (current ?factor)\n (max ?max))\n =>\n (if (< ?factor ?max) then\n (modify ?pen (current (+ ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?pen <- (pen-size (min ?min)\n (current ?factor))\n =>\n (if (> ?factor ?min) then\n (modify ?pen (current (- ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n(batch* \/lib\/reset-run-exit.clp)\n","old_contents":"(load* \/lib\/core.clp)\n(load* \/lib\/chicanery.clp)\n\n(deftemplate pen-size\n (slot min \n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1))\n (slot max\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 128))\n (slot current\n (type INTEGER)\n (range 1 ?VARIABLE)\n (default 1)))\n\n(defmethod on-resized\n \"method to handle resizing of the window\"\n ((?value SYMBOL (not (neq ?value FALSE TRUE))))\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (assert (setup background))))\n\n(definstances elements\n (menu1 of menu (menu-entries cut copy paste))\n (menu2 of menu (menu-entries eat sleep drink))\n (region0 of rectangle (x 0) (y 0) (bx 128) (by 32))\n (point0 of point (x 0) (y 32))\n (drawing-field of rectangle (x 4) (y 37) (bx 1020) (by 1020))\n (drawing-field-border of rectangle (x 0) (y 33) (bx 1024) (by 1024))\n (scratch-rect of rectangle (x 0) (y 0) (bx 0) (by 0))\n (text of image (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color black)))\n (inset-rect0 of image (rectangle [drawing-field-border])\n (replicate TRUE)\n (color (get-standard-color black)))\n (field0 of image (rectangle [drawing-field])\n (replicate TRUE)\n (color (get-standard-color white)))\n (button-background of image (rectangle [region0])\n (replicate TRUE)\n (color (get-standard-color paleyellow)))\n (pixel-image of image (rectangle [pixel])\n (replicate TRUE)\n (color (get-standard-color black))))\n\n(deffacts query-operation\n (query input)\n (pen-size (min 1)\n (max 128)\n (current 1)))\n\n(defrule setup-background \n (declare (salience 10000))\n ?f <- (setup background)\n =>\n (retract ?f)\n (screen\/draw [drawing-field-border] [inset-rect0] [ZP])\n (screen\/draw [drawing-field] [field0] [ZP])\n (screen\/draw [region0] [button-background] [ZP])\n (screen\/draw-text [ZP] [text] [ZP] \"File\")\n (screen\/flush 1))\n\n(defrule query-input\n ?f <- (query input)\n =>\n (retract ?f)\n (send [mouse] query)\n (send [keyboard] query)\n (assert (check mouse)\n (check keyboard)))\n\n(defrule process-mouse-inputs\n (declare (salience -1))\n ?f <- (check mouse)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:button1\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button1)\n (position ?x ?y))\n (test (intersects ?x ?y [drawing-field]))\n ?rect <- (object (is-a rectangle)\n (name [scratch-rect]))\n (pen-size (current ?factor))\n =>\n (retract ?f)\n (modify-instance ?rect (x ?x) (y ?y)\n (bx (+ ?x ?factor)) \n (by (+ ?y ?factor)))\n ;rebuild the native memory since we've made\n ; changes to the fields\n (send ?rect build-pointer)\n (screen\/draw ?rect [pixel-image] [ZP])\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:menu1\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button3)\n (position ?x ?y))\n (test (intersects ?x ?y [region0]))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu1] show-menu 3) crlf)\n (assert (query mouse)))\n\n(defrule process-mouse-inputs:menu2\n (declare (salience 1))\n ?f <- (check mouse)\n (object (is-a mouse)\n (name [mouse])\n (buttons button2)\n (timestamp ?ts))\n =>\n (retract ?f)\n ; Display a menu\n (printout t (send [menu2] show-menu 2) crlf)\n (assert (query mouse)))\n\n\n(defrule process-keyboard-inputs:quit\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ESC))\n =>\n (retract ?f)\n (exit))\n\n(defrule process-keyboard-inputs:nil\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys NIL))\n =>\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:up\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys UP))\n ?pen <- (pen-size \n (current ?factor)\n (max ?max))\n =>\n (if (< ?factor ?max) then\n (modify ?pen (current (+ ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n\n(defrule process-keyboard-inputs:down\n (declare (salience 1))\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys DOWN))\n ?pen <- (pen-size (min ?min)\n (current ?factor))\n =>\n (if (> ?factor ?min) then\n (modify ?pen (current (- ?factor 1))))\n (retract ?f)\n (assert (query keyboard)))\n(defrule process-keyboard-inputs\n ?f <- (check keyboard)\n (object (is-a keyboard)\n (name [keyboard])\n (keys ?b&~NIL))\n =>\n (retract ?f)\n (printout t \"Pressed \" ?b crlf)\n (assert (query keyboard)))\n\n(defrule ready-to-query-input-again \n ?f <- (query keyboard)\n ?f2 <- (query mouse)\n =>\n (retract ?f ?f2)\n (send [mouse] clear)\n (send [keyboard] clear)\n (assert (query input)))\n\n(batch* \/lib\/reset-run-exit.clp)\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"5775e884ff549bcbe0cff83d242cd4942d6cbeb1","subject":"Rewrote the PassRegistry to use the new pass layout","message":"Rewrote the PassRegistry to use the new pass layout\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/PassRegistry.clp","new_file":"lib\/durandal\/passes\/PassRegistry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; NOTE: If you want to define your own place to load passes from then remember\n; that it is up to you to load it initially.\n;------------------------------------------------------------------------------\n\n;This is part of the MAIN module\n(definstances PersistentPassRegistry\n ([paths] of Pass\n (entry-point \"passes\/path\/PassHeader.clp\")\n (pass-name paths)\n (pass-description \"Generate the set of paths through a given function\") \n (pass-type Function)\n (need-loops TRUE)\n (need-regions TRUE)\n (passes paths)\n (required loops regions))\n \n \n ;([pass-valid-paths] of Pass\n ; (entry \"passes\/path\/valid-only\/PassHeader.clp\")\n ; (pass-name \"valid-paths\")\n ; (pass-description \"Generate the set of paths through user-defined valid regions in a function\")\n ; (target Function))\n ;([pass-paths] of Pass\n ; (entry \"passes\/path\/all-paths\/PassHeader.clp\")\n ; (pass-name \"paths\")\n ; (pass-description \"Generate the set of all paths through all regions in a function\")\n ; (target Function))\n\n)\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PassRegistry.clp - Contains the listing of the standard set of passes. \n;------------------------------------------------------------------------------\n; NOTE: If you want to define your own place to load passes from then remember\n; that it is up to you to load it initially.\n;------------------------------------------------------------------------------\n\n;This is part of the MAIN module\n(definstance PersistentPassRegistry\n ([pass-valid-paths] of Pass\n (entry \"passes\/path\/valid-only\/PassHeader.clp\")\n (pass-name \"valid-paths\")\n (pass-description \"Generate the set of paths through user-defined valid regions in a function\")\n (target Function))\n ([pass-paths] of Pass\n (entry \"passes\/path\/all-paths\/PassHeader.clp\")\n (pass-name \"paths\")\n (pass-description \"Generate the set of all paths through all regions in a function\")\n (target Function))\n\n)\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"9ee3af2937d033fe502a0d03a15bb6d850d10923","subject":"Added extensions.clp.","message":"Added extensions.clp.\n\nThis contains methods that extend off of the native methods provided by\nthe electron runtime\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-filesystem,DrItanium\/electron-platform","old_file":"sys\/core\/extensions.clp","new_file":"sys\/core\/extensions.clp","new_contents":";------------------------------------------------------------------------------\n;electron-filesystem\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of electron-filesystem nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; extensions.clp - extends native functions to make them easier to use\n;\n;------------------------------------------------------------------------------\n(defmethod merge\n ($?atoms INTEGER)\n (merge ?atoms))\n;------------------------------------------------------------------------------\n(defmethod binary-or\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-or ?number ?value)))\n (return ?number))\n\n(defmethod binary-or\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-or ?values))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-or ?a (binary-or ?b ?c)))\n\n(defmethod binary-or\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-or ?a (binary-or ?b (binary-or ?c ?d))))\n\n;------------------------------------------------------------------------------\n\n(defmethod binary-and\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-and ?number ?value)))\n (return ?number))\n\n(defmethod binary-and\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-and ?values))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-and ?a (binary-and ?b ?c)))\n\n(defmethod binary-and\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-and ?a (binary-and ?b (binary-and ?c ?d))))\n;------------------------------------------------------------------------------\n\n(defmethod binary-xor\n ((?values MULTIFIELD INTEGER (> (length$ ?values) 4)))\n (bind ?number (nth$ 1 (first$ ?values)))\n (progn$ (?value (rest$ ?values))\n (bind ?number (binary-xor ?number ?value)))\n (return ?number))\n\n(defmethod binary-xor\n (($?values INTEGER (> (length$ ?values) 4)))\n (binary-xor ?values))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER))\n (binary-xor ?a (binary-xor ?b ?c)))\n\n(defmethod binary-xor\n ((?a INTEGER)\n (?b INTEGER)\n (?c INTEGER)\n (?d INTEGER))\n (binary-xor ?a (binary-xor ?b (binary-xor ?c ?d))))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'sys\/core\/extensions.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"34148678a599f1418a2036253123ed4f2d5d8ac6","subject":"Finished porting wavefront-scheduling-dependency-analysis","message":"Finished porting wavefront-scheduling-dependency-analysis\n\nI have not optimized the rules in this module as heavily as I've done in others\ndue to the fact that I need to make sure that the code works first before\nmaking changes.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontDependencyUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::CreateDependencyAnalysisTargets\n (declare (salience 10))\n (object (is-a Wavefront) \n (parent ?r) \n (contents $? ?e $?))\n (object (is-a BasicBlock) \n (id ?e))\n (object (is-a PathAggregate) \n (parent ?e) \n (OriginalStopIndex ?si))\n =>\n ;only look at instructions starting at the original stop index. This\n ;prevents unncessary recomputation\n (assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAR\n \"Identifies a WAR dependency between two instructions. It will not \n match if it turns out the values are constant integers or constant \n floating point values\"\n (Evaluate ?p for dependencies starting at ?si)\n ;TODO: Rewrite this to be more efficient\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (Operands $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyRAW\n \"Identifies a RAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n (object (is-a Instruction) \n (parent ?p) \n (id ?t1)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (Operands $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::IdentifyWAW\n \"Identifies a WAW dependency between two instructions in the same \n block. It will not match if it turns out that the values are constant \n integers or constant floating point values.\"\n (Evaluate ?p for dependencies starting at ?si)\n ?i0 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0)\n (DestinationRegisters $? ?c $?))\n (object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n (id ?c))\n ?i1 <- (object (is-a Instruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n (DestinationRegisters $? ?c $?))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-ModifiesMemory\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call could modify memory.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n (MayWriteToMemory TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-InlineAsm\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (IsInlineAsm TRUE)\n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (id ?following)\n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkCallInstructionDependency-SideEffects\n \"Creates a series of dependencies for all instructions following a \n call instruction if it turns out that the call is inline asm.\"\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a CallInstruction) \n (id ?name) \n (parent ?p) \n (MayHaveSideEffects TRUE) \n (MayWriteToMemory TRUE) \n (TimeIndex ?t0))\n (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n (HasCallDependency FALSE) \n (id ?following))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?following => ?name))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?name => ?following))\n (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?following))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::MarkNonLocalDependencies\n (Evaluate ?p for dependencies starting at ?si)\n ?inst <- (object (is-a Instruction) \n (parent ?p) \n (TimeIndex ?t&:(>= ?t ?si))\n (NonLocalDependencies $?nld)\n (Operands $? ?o $?))\n (object (is-a Instruction) \n (id ?o) \n (parent ~?p))\n =>\n (modify-instance ?inst (NonLocalDependencies $?nld ?o)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::Wavefront-MarkHasCallDependency\n (declare (salience -2))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-has-a-call-dependency)\n (arguments ?f))\n\n ?obj <- (object (is-a Instruction) \n (id ?f))\n =>\n (modify-instance ?obj (HasCallDependency TRUE))\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectConsumers\n \"Adds a given consumer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (Consumers $?consumers))\n =>\n (retract ?fct)\n (if (not (member$ ?target $?consumers)) then\n (modify-instance ?inst (Consumers $?consumers ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::InjectProducers\n \"Adds a given producer to the target instruction\"\n (declare (salience -5))\n ?fct <- (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?target => ?id))\n ?inst <- (object (is-a Instruction) \n (id ?id)\n (LocalDependencies $?ld)\n (Producers $?prod))\n =>\n (retract ?fct)\n (modify-instance ?inst \n (LocalDependencies $?ld \n (if (not (member$ ?target $?ld)) \n then ?target))\n (Producers $?prod \n (if (not (member$ ?target $?prod)) \n then ?target))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToLoadDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::StoreToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0))\n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::LoadToStoreDependency\n (Evaluate ?p for dependencies starting at ?si)\n (object (is-a LoadInstruction) \n (parent ?p) \n (id ?t0)\n (TimeIndex ?ti0) \n (MemoryTarget ?sym0)) \n (object (is-a StoreInstruction) \n (parent ?p) \n (id ?t1) \n (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n (MemoryTarget ?sym1))\n (test (or (eq ?sym0 ?sym1) \n (eq ?sym0 UNKNOWN)))\n =>\n (assert (message (to wavefront-scheduling)\n (action instruction-consumes)\n (arguments ?t1 => ?t0))\n (message (to wavefront-scheduling)\n (action instruction-produces)\n (arguments ?t0 => ?t1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-dependency-analysis::FinishedDependencyAnalysis \n (declare (salience -800))\n ?fct <- (Evaluate ?p for dependencies starting at ?v)\n (object (is-a BasicBlock) \n (id ?p) \n (parent ?r))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveInstructionsFromProducers\n (declare (salience 768))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Remove evidence of ?tInst from instructions ?inst $?insts)\n ?iObj <- (object (is-a Instruction) \n (ID ?inst) \n (Producers $?pb ?tInst $?pa)\n (LocalDependencies $?ldb ?tInst $?lda))\n =>\n (retract ?fct)\n (assert (Remove evidence of ?tInst from instructions $?insts))\n (modify-instance ?iObj (Producers $?pb $?pa)\n (LocalDependencies $?ldb $?lda))\n (slot-insert$ ?iObj NonLocalDependencies 1 ?tInst))\n;------------------------------------------------------------------------------\n(defrule RetractRemoveInstructionsFromProducers\n (declare (salience 768))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Remove evidence of ? from instructions)\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule StartRecomputeBlock\n (declare (salience 100))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b)\n ?bb <- (object (is-a BasicBlock) (ID ?b) \n (Contents $?instructions ?last))\n (object (is-a TerminatorInstruction) (ID ?last))\n =>\n (modify-instance ?bb (ReadsFrom) (WritesTo) (HasMemoryBarrier FALSE))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?instructions)))\n;------------------------------------------------------------------------------\n(defrule RecomputeNonMemoryInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a BasicBlock) (ID ?b))\n (object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n (ID ?inst) (Parent ?b))\n =>\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeLoadInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a LoadInstruction) (ID ?inst) (Parent ?b) \n (MemoryTarget ?mt)) \n ?bb <- (object (is-a BasicBlock) (ID ?b))\n =>\n (if (not (member$ ?mt (send ?bb get-ReadsFrom))) then\n (slot-insert$ ?bb ReadsFrom 1 ?mt))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeStoreInstructionForBlock\n (declare (salience 99))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions ?inst $?rest)\n (object (is-a StoreInstruction) (ID ?inst) (Parent ?b) \n (MemoryTarget ?mt))\n ?bb <- (object (is-a BasicBlock) (ID ?b))\n =>\n (if (not (member$ ?mt (send ?bb get-WritesTo))) then\n (slot-insert$ ?bb WritesTo 1 ?mt))\n (retract ?fct)\n (assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishRecomputationForBlock\n (declare (salience 98))\n (Stage WavefrontSchedule $?)\n (Substage MergeUpdate $?)\n ?fct <- (Recompute block ?b with instructions)\n ?bb <- (object (is-a BasicBlock) (ID ?b) (ReadsFrom $?rf)\n (WritesTo $?wt))\n =>\n (retract ?fct)\n (if (or (member$ UNKNOWN ?rf)\n (member$ UNKNOWN ?wt)) then\n (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; This stage is the actual act of scheduling the blocks on the wavefront. \n; The first step is to reacquire all dependencies of the given blocks by\n; running the same rules as before. The only difference is that we have to do\n; it specially for the blocks on the wavefront. \n; \n; I'm thinking of just copying the rules from the analysis pass to here. It\n; would be a duplication but I frankly don't care anymore. \n;------------------------------------------------------------------------------\n(defrule CreateDependencyAnalysisTargets\n\t\t\t(declare (salience 10))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(object (is-a Wavefront) (Parent ?r) (Contents $? ?e $?))\n\t\t\t(object (is-a BasicBlock) (ID ?e))\n\t\t\t(object (is-a PathAggregate) (Parent ?e) (OriginalStopIndex ?si))\n\t\t\t=>\n\t\t\t;only look at instructions starting at the original stop index. This\n\t\t\t;prevents unncessary recomputation\n\t\t\t(assert (Evaluate ?e for dependencies starting at ?si)))\n;------------------------------------------------------------------------------\n(defrule IdentifyWAR-Wavefront\n\t\t\t\"Identifies a WAR dependency between two instructions. It will not \n\t\t\tmatch if it turns out the values are constant integers or constant \n\t\t\tfloating point values\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t?i0 <- (object (is-a Instruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t\t\t\t(Operands $? ?c $?) (TimeIndex ?ti0))\n\t\t\t(object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n\t\t\t\t\t (ID ?c))\n\t\t\t?i1 <- (object (is-a Instruction) (Parent ?p) (ID ?t1)\n\t\t\t\t\t\t\t\t(TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n\t\t\t\t\t\t\t\t(DestinationRegisters $? ?c $?))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n(defrule IdentifyRAW-Wavefront\n\t\t\t\"Identifies a RAW dependency between two instructions in the same \n\t\t\tblock. It will not match if it turns out that the values are constant \n\t\t\tintegers or constant floating point values.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a Instruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t (DestinationRegisters $? ?c $?) (TimeIndex ?ti0))\n\t\t\t(object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n\t\t\t\t\t (ID ?c))\n\t\t\t(object (is-a Instruction) (Parent ?p) (ID ?t1)\n\t\t\t\t\t (Operands $? ?c $?) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n(defrule IdentifyWAW-Wavefront\n\t\t\t\"Identifies a WAW dependency between two instructions in the same \n\t\t\tblock. It will not match if it turns out that the values are constant \n\t\t\tintegers or constant floating point values.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t?i0 <- (object (is-a Instruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t\t\t\t(DestinationRegisters $? ?c $?) (TimeIndex ?ti0))\n\t\t\t(object (is-a TaggedObject&~ConstantInteger&~ConstantFloatingPoint) \n\t\t\t\t\t (ID ?c))\n\t\t\t?i1 <- (object (is-a Instruction) (Parent ?p) (ID ?t1) \n\t\t\t\t\t\t\t\t(TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1))) \n\t\t\t\t\t\t\t\t(DestinationRegisters $? ?c $?))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n;these call instruction checks only work for new instructions or those that\n; dont have a call dependency. As that was the only way they got into the \n; block in the first place\n;------------------------------------------------------------------------------\n(defrule MarkCallInstructionDependency-ModifiesMemory-Wavefront\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call could modify memory.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a CallInstruction) (ID ?name) (Parent ?p) \n\t\t\t\t\t (DoesNotAccessMemory FALSE) (OnlyReadsMemory FALSE) \n\t\t\t\t\t (MayWriteToMemory TRUE)\n\t\t\t\t\t (TimeIndex ?t0))\n\t\t\t(object (is-a Instruction) (Parent ?p) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n\t\t\t\t\t (HasCallDependency FALSE) (ID ?following))\n\t\t\t=>\n\t\t\t(assert (Instruction ?following has a CallDependency)\n\t\t\t\t\t (Instruction ?following consumes ?name)\n\t\t\t\t\t (Instruction ?name produces ?following)))\n;------------------------------------------------------------------------------\n(defrule MarkCallInstructionDependency-InlineAsm-Wavefront\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a CallInstruction) (ID ?name) (Parent ?p) \n\t\t\t\t\t (IsInlineAsm TRUE)\n\t\t\t\t\t (TimeIndex ?t0))\n\t\t\t(object (is-a Instruction) (Parent ?p) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n\t\t\t\t\t (HasCallDependency FALSE) (ID ?following))\n\t\t\t=>\n\t\t\t(assert (Instruction ?following has a CallDependency)\n\t\t\t\t\t (Instruction ?following consumes ?name)\n\t\t\t\t\t (Instruction ?name produces ?following)))\n;------------------------------------------------------------------------------\n(defrule MarkCallInstructionDependency-SideEffects-Wavefront\n\t\t\t\"Creates a series of dependencies for all instructions following a \n\t\t\tcall instruction if it turns out that the call is inline asm.\"\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a CallInstruction) (ID ?name) (Parent ?p) \n\t\t\t\t\t (MayHaveSideEffects TRUE) (MayWriteToMemory TRUE) \n\t\t\t\t\t (TimeIndex ?t0))\n\t\t\t(object (is-a Instruction) (Parent ?p) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?t0 ?ti1)))\n\t\t\t\t\t (HasCallDependency FALSE) (ID ?following))\n\t\t\t=>\n\t\t\t(assert (Instruction ?following has a CallDependency)\n\t\t\t\t\t (Instruction ?following consumes ?name)\n\t\t\t\t\t (Instruction ?name produces ?following)))\n;------------------------------------------------------------------------------\n(defrule MarkNonLocalDependencies-Wavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t?inst <- (object (is-a Instruction) (Parent ?p) \n\t\t\t\t\t\t\t\t (TimeIndex ?t&:(>= ?t ?si))\n\t\t\t\t\t\t\t\t (Operands $? ?o $?))\n\t\t\t(object (is-a Instruction) (ID ?o) (Parent ~?p))\n\t\t\t=>\n\t\t\t(slot-insert$ ?inst NonLocalDependencies 1 ?o))\n;------------------------------------------------------------------------------\n(defrule Wavefront-MarkHasCallDependency\n\t\t\t(declare (salience -2))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t?fct <- (Instruction ?f has a CallDependency)\n\t\t\t?obj <- (object (is-a Instruction) (ID ?f))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (HasCallDependency TRUE))\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule InjectConsumers-Wavefront\n\t\t\t\"Adds a given consumer to the target instruction\"\n\t\t\t(declare (salience -5))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t?fct <- (Instruction ?target consumes ?id)\n\t\t\t?inst <- (object (is-a Instruction) (ID ?id))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(if (not (member$ ?target (send ?inst get-Consumers))) then\n\t\t\t (slot-insert$ ?inst Consumers 1 ?target)))\n;------------------------------------------------------------------------------\n(defrule InjectProducers-Wavefront\n\t\t\t\"Adds a given producer to the target instruction\"\n\t\t\t(declare (salience -5))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t?fct <- (Instruction ?target produces ?id)\n\t\t\t?inst <- (object (is-a Instruction) (ID ?id))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(if (not (member$ ?target (send ?inst get-LocalDependencies))) then\n\t\t\t (slot-insert$ ?inst LocalDependencies 1 ?target))\n\t\t\t(if (not (member$ ?target (send ?inst get-Producers))) then \n\t\t\t (slot-insert$ ?inst Producers 1 ?target)))\n;------------------------------------------------------------------------------\n(defrule StoreToLoadDependency-Wavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a StoreInstruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0))\n\t\t\t(object (is-a LoadInstruction) (Parent ?p) (ID ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n\t\t\t\t\t (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n(defrule StoreToStoreDependency-Wavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a StoreInstruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0))\n\t\t\t(object (is-a StoreInstruction) (Parent ?p) (ID ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n\t\t\t\t\t (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n(defrule LoadToStoreDependency-Wavefront\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t(Evaluate ?p for dependencies starting at ?si)\n\t\t\t(object (is-a LoadInstruction) (Parent ?p) (ID ?t0)\n\t\t\t\t\t (TimeIndex ?ti0) (MemoryTarget ?sym0)) \n\t\t\t(object (is-a StoreInstruction) (Parent ?p) (ID ?t1) \n\t\t\t\t\t (TimeIndex ?ti1&:(and (>= ?ti1 ?si) (< ?ti0 ?ti1)))\n\t\t\t\t\t (MemoryTarget ?sym1))\n\t\t\t(test (or (eq ?sym0 ?sym1) (eq ?sym0 UNKNOWN)))\n\t\t\t=>\n\t\t\t(assert (Instruction ?t1 consumes ?t0)\n\t\t\t\t\t (Instruction ?t0 produces ?t1)))\n;------------------------------------------------------------------------------\n(defrule FinishedDependencyAnalysis \n\t\t\t(declare (salience -800))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage DependencyAnalysis $?)\n\t\t\t?fct <- (Evaluate ?p for dependencies starting at ?v)\n\t\t\t(object (is-a BasicBlock) (ID ?p) (Parent ?r))\n\t\t\t=>\n\t\t\t(assert (Schedule ?p for ?r))\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule RemoveInstructionsFromProducers\n\t\t\t(declare (salience 768))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Remove evidence of ?tInst from instructions ?inst $?insts)\n\t\t\t?iObj <- (object (is-a Instruction) \n\t\t\t\t\t\t\t\t (ID ?inst) \n\t\t\t\t\t\t\t\t (Producers $?pb ?tInst $?pa)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ldb ?tInst $?lda))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Remove evidence of ?tInst from instructions $?insts))\n\t\t\t(modify-instance ?iObj (Producers $?pb $?pa)\n\t\t\t\t\t\t\t\t (LocalDependencies $?ldb $?lda))\n\t\t\t(slot-insert$ ?iObj NonLocalDependencies 1 ?tInst))\n;------------------------------------------------------------------------------\n(defrule RetractRemoveInstructionsFromProducers\n\t\t\t(declare (salience 768))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Remove evidence of ? from instructions)\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule StartRecomputeBlock\n\t\t\t(declare (salience 100))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Recompute block ?b)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?b) \n\t\t\t\t\t\t\t\t(Contents $?instructions ?last))\n\t\t\t(object (is-a TerminatorInstruction) (ID ?last))\n\t\t\t=>\n\t\t\t(modify-instance ?bb (ReadsFrom) (WritesTo) (HasMemoryBarrier FALSE))\n\t\t\t(retract ?fct)\n\t\t\t(assert (Recompute block ?b with instructions $?instructions)))\n;------------------------------------------------------------------------------\n(defrule RecomputeNonMemoryInstructionForBlock\n\t\t\t(declare (salience 99))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Recompute block ?b with instructions ?inst $?rest)\n\t\t\t(object (is-a BasicBlock) (ID ?b))\n\t\t\t(object (is-a Instruction&~LoadInstruction&~StoreInstruction) \n\t\t\t\t\t (ID ?inst) (Parent ?b))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeLoadInstructionForBlock\n\t\t\t(declare (salience 99))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Recompute block ?b with instructions ?inst $?rest)\n\t\t\t(object (is-a LoadInstruction) (ID ?inst) (Parent ?b) \n\t\t\t\t\t (MemoryTarget ?mt)) \n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?b))\n\t\t\t=>\n\t\t\t(if (not (member$ ?mt (send ?bb get-ReadsFrom))) then\n\t\t\t (slot-insert$ ?bb ReadsFrom 1 ?mt))\n\t\t\t(retract ?fct)\n\t\t\t(assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule RecomputeStoreInstructionForBlock\n\t\t\t(declare (salience 99))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Recompute block ?b with instructions ?inst $?rest)\n\t\t\t(object (is-a StoreInstruction) (ID ?inst) (Parent ?b) \n\t\t\t\t\t (MemoryTarget ?mt))\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?b))\n\t\t\t=>\n\t\t\t(if (not (member$ ?mt (send ?bb get-WritesTo))) then\n\t\t\t (slot-insert$ ?bb WritesTo 1 ?mt))\n\t\t\t(retract ?fct)\n\t\t\t(assert (Recompute block ?b with instructions $?rest)))\n;------------------------------------------------------------------------------\n(defrule FinishRecomputationForBlock\n\t\t\t(declare (salience 98))\n\t\t\t(Stage WavefrontSchedule $?)\n\t\t\t(Substage MergeUpdate $?)\n\t\t\t?fct <- (Recompute block ?b with instructions)\n\t\t\t?bb <- (object (is-a BasicBlock) (ID ?b) (ReadsFrom $?rf)\n\t\t\t\t\t\t\t\t(WritesTo $?wt))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(if (or (member$ UNKNOWN ?rf)\n\t\t\t\t\t (member$ UNKNOWN ?wt)) then\n\t\t\t (modify-instance ?bb (HasMemoryBarrier TRUE))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"f0addf2677b38649aec78bc6ea07893a20ece596","subject":"A minor change.","message":"A minor change.\n\n","repos":"ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror,ekiwi\/jade-mirror","old_file":"src\/examples\/jess\/JadeAgent.clp","new_file":"src\/examples\/jess\/JadeAgent.clp","new_contents":"; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n (send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n; (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","old_contents":"; Remind that the ACLMessage has been defined with the following template:\n; (deftemplate ACLMessage \n; (slot communicative-act) (slot sender) (multislot receiver) \n; (slot reply-with) (slot in-reply-to) (slot envelope) \n; (slot conversation-id) (slot protocol) \n; (slot language) (slot ontology) (slot content) )\n; refer to Fipa97 Part 2 (www.cselt.it\/fipa) for the description of the \n; ACLMessage parameters.\n;\n; Remind that Jade has also asserted for you the fact \n; (MyAgent (name \n;(send (assert (ACLMessage (communicative-act propose) (receiver ?s) (content ?c))))\n (assert (ACLMessage (communicative-act propose) (sender ?r) (receiver ?s) (content ?c)))\n (retract ?m)\n)\n\n(defrule send-a-message\n \"When a message is asserted whose sender is this agent, the message is\n sent and then retracted from the knowledge base.\"\n (MyAgent (name ?n))\n ?m <- (ACLMessage (sender ?n))\n =>\n (send ?m)\n (retract ?m)\n)\n\n(watch facts)\n(reset) \n\n(run) \n; if you put run here, Jess is run before waiting for a message arrival,\n; if you do not put (run here, the agent waits before for the arrival of the \n; first message and then runs Jess.\n\n\n\n\n\n\n\n\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"a7ef4db19107cb68ce09926e6b843aed254124e4","subject":"Modified instance-address in ReindexBasicBlock to search all modules","message":"Modified instance-address in ReindexBasicBlock to search all modules\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/WavefrontPropagation.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (slot-insert$ ?pa InstructionPropagation 1 ?targ ?alias ?z !))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n ?count\n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address * (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::PropagateAggregateInformation\n \"Pulls instruction propagation information from all elements on paths \n that immediately precede this element on the wavefront and merges it \n into the path aggregate itself\"\n (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?e))\n ;if this element is on the wavefront then we can be certain that all \n ;of it's predecessors are above it. That is the definition of being on\n ;the wavefront\n ?pa <- (object (is-a PathAggregate) \n (parent ?e))\n (object (is-a Diplomat) \n (id ?e) \n (PreviousPathElements $? ?z $?))\n (object (is-a PathAggregate) \n (parent ?z) \n (InstructionPropagation $? ?targ ?alias ? ! $?))\n =>\n ;replace parent blocks of previous path elements with the name of the\n ;element this was acquired from\n ;(printout t \"Put (\" ?targ \" \" ?alias \" \" ?z \"! ) into \" ?pp crlf)\n (slot-insert$ ?pa InstructionPropagation 1 ?targ ?alias ?z !))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-identify::RetractAggregationInformation\n (declare (salience -50))\n ?fct <- (message (to wavefront-scheduling)\n (action propagate-aggregates)\n (arguments ?))\n =>\n (retract ?fct))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-identify::AssertPhiNodePropagationPredicateIsBlock\n (declare (salience 1))\n (object (is-a Wavefront) \n (parent ?r) \n (values $? ?e $?))\n ?pa <- (object (is-a PathAggregate) \n (parent ?e) \n (InstructionPropagation ?targ ?alias ?pred ! $?rest))\n =>\n (modify-instance ?pa (InstructionPropagation $?rest))\n (assert (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?targ \n alias ?alias \n from ?pred \n for ?e))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::RemoveDuplicateElements \n \"Removes propagation targets that represent the same value but come from\n different previous blocks\/regions. When this is seen it's not necessary to\n create a phi node. This is evident because the aliases are the same across\n multiple paths of execution.\"\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p0 \n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a \n from ?p1&~?p0 \n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b) \n (InstructionPropagation $?ip))\n =>\n (retract ?f0 ?f1)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithOtherPropagation\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a1&~?a0\n from ?p1&~?p0 \n for ?b))\n =>\n (retract ?f0 ?f1)\n (assert (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t\n block ?b => ?a0 ?p0 ?a1 ?p1))))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::MergePhiNodePropagationWithCreateStatement\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?f1 <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?targets))\n =>\n (retract ?f0)\n (modify ?f1 (arguments target-instruction ?t\n block ?b => $?targets ?a0 ?p0)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::PutUnfulfilledItemsBackIntoPropagationList\n (declare (salience -10))\n ?f0 <- (message (to wavefront-scheduling)\n (action propagation-target)\n (arguments target ?t \n alias ?a0\n from ?p0\n for ?b))\n ?pa <- (object (is-a PathAggregate) \n (parent ?b)\n (InstructionPropagation $?ip))\n =>\n (retract ?f0)\n (modify-instance ?pa (InstructionPropagation $?ip ?t ?a0 ?b !)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-NotOriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si)\n (InstructionPropagation $?ip)\n (ReplacementActions $?ra))\n\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest)\n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n (object (is-a Instruction) \n (id ?t) \n (Type ?ty))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?typePtr))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n ;make the phinode in LLVM and get it's address back\n (bind ?phiPtr \n (llvm-make-phi-node ?name\n ?typePtr \n ?count\n ?bPtr \n (symbol-to-pointer-list $?elements)))\n ;build a CLIPS representation of it\n (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPtr)\n (IncomingValueCount ?count)\n (Operands $?elements))\n ;we've scheduled the given original instruction into this block\n ; although it's just a ruse\n (modify-instance ?agObj (ScheduledInstructions $?si ?t)\n (InstructionPropagation $?ip ?t ?name ?b !)\n (ReplacementActions $?ra ?t ?name !))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node::NamePhiNodeFromCreateStatement-OriginalBlock\n (declare (salience -12))\n ?fct <- (message (to wavefront-scheduling)\n (action create-phi-node)\n (arguments target-instruction ?t \n block ?b => $?elements))\n ?agObj <- (object (is-a PathAggregate) \n (parent ?b)\n (ScheduledInstructions $?si))\n ?bb <- (object (is-a BasicBlock) \n (id ?b) \n (contents ?first $?rest) \n (UnlinkedInstructions \n $?ui&:(not (member$ ?t $?ui))))\n (object (is-a Instruction) \n (id ?first) \n (pointer ?bPtr))\n ?tObj <- (object (is-a Instruction) \n (id ?t) \n (Type ?ty) \n (pointer ?tPtr))\n (object (is-a LLVMType) \n (id ?ty) \n (pointer ?dataType))\n =>\n (modify ?fct (action update-block-duration)\n (arguments ?b))\n (bind ?name (sym-cat phi. (gensym*) . ?t))\n (bind ?count (\/ (length$ $?elements) 2))\n (bind ?pointers (symbol-to-pointer-list ?elements))\n (bind ?phiPointer \n (llvm-make-phi-node ?name ?dataType ?count ?bPtr ?pointers))\n (bind ?phiObj (make-instance ?name of PhiNode \n (parent ?b)\n (TimeIndex 0)\n (pointer ?phiPointer)\n (IncomingValueCount ?count)\n (Operands $?elements)))\n (llvm-replace-all-uses ?tPtr ?phiPointer)\n (llvm-unlink-and-delete-instruction ?tPtr)\n (unmake-instance ?tObj)\n (modify-instance ?agObj (ScheduledInstructions $?si ?t))\n (modify-instance ?bb (contents ?name ?first $?rest)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-phi-node-update::ReindexBasicBlock \n ?fct <- (message (to wavefront-scheduling)\n (action update-block-duration)\n (arguments ?b))\n (object (is-a BasicBlock) \n (id ?b) \n (contents $?c))\n =>\n ;this is very much procedural but I frankly don't care\n ;anymore. \n (progn$ (?t ?c)\n (bind ?obj (instance-address (symbol-to-instance-name ?t)))\n (modify-instance ?obj (TimeIndex (- ?t-index 1))))\n (retract ?fct))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"deb81279e3a57eced6c6845325a9440a2226feeb","subject":"Create task6.clp","message":"Create task6.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task6.clp","new_file":"ssu-ai-level-2\/chapter5\/task6.clp","new_contents":"(defrule node\n =>\n (printout t \"n1=\")\n (bind ?n1 (read))\n (printout t \"n2=\")\n (bind ?n2 (read))\n (while TRUE do\n (if (= ?n1 ?n2) then\n (printout t \"nod is: \" ?n1)\n (return)\n )\n\n (if (> ?n1 ?n2) then\n (bind ?n1 (- ?n1 ?n2))\n else\n (bind ?n2 (- ?n2 ?n1))\n )\n )\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task6.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"5107f01c80562ae8d0f7c401451e9e14446e363c","subject":"Reactivated unknown file retraction","message":"Reactivated unknown file retraction\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"29c5ac4878c8de95b3df09b4946e639f77dc92e9","subject":"Added CS B.S. degree requirements rule.","message":"Added CS B.S. degree requirements rule.\n","repos":"jtan189\/CompSci-Degree-Expert-System,jtan189\/CompSci-Degree-Expert-System","old_file":"DegreeAdvisor\/src\/advisor.clp","new_file":"DegreeAdvisor\/src\/advisor.clp","new_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n(defglobal ?*lab-seq-credits* = 8)\n\n;; GEN ED REQUIREMENTS\n\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {courseId == \"UNIV 189\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n (not (exists (Course {courseId == \"COMM 110\"})))\n (not (exists (Course {courseId == \"ENGL 110\"})))\n (not (exists (Course {courseId == \"ENGL 120\"})))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {courseId == \"MATH 165\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; Humanities & Fine Arts (A) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-a\n \"Advise student if Gen Ed Humanities & Fine Arts requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"A\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Humanities & Fine Arts requirements not satisfied\" \"At least 6 credits in the General Education Humanities & Fine Arts area are required.\" \"ISSUE\")))\n\n;; Social & Behavioral Sciences (B) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-b\n \"Advise student if Gen Ed Social & Behavioral Sciences requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"B\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Social & Behavioral Sciences requirements not satisfied\" \"At least 6 credits in the General Education Social & Behavioral Sciences area are required.\" \"ISSUE\")))\n\n;; Wellness (W) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-w\n \"Advise student if Gen Ed Wellness requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"W\")))) ;; CE\n (test (< ?totalCredits 2))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Wellness requirements not satisfied\" \"At least 6 credits in the General Education Wellness area are required.\" \"ISSUE\")))\n\n;; Cultural Diversity (D) Requirements\n(defrule gen-ed-d\n \"Advise student if Gen Ed Cultural Diversity requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"D\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Cultural Diversity requirements not satisfied\" \"At least 1 course in the General Education Cultural Diversity area is required.\" \"ISSUE\")))\n\n;; Global Perspectives (G) Requirements\n(defrule gen-ed-g\n \"Advise student if Gen Ed Global Perspectives requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"G\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Global Perspectives requirements not satisfied\" \"At least 1 course in the General Education Global Perspectives area is required.\" \"ISSUE\")))\n\n;; Gen Ed Lower Division Requirements\n(defrule gen-ed-ld\n \"Adivce student if Gen Ed lower division requirements are not satisfied.\"\n (exists (gen-ed-ld-not-satisfied))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed lower division requirements not satisfied\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; Gen Ed Upper Division Requirements\n(defrule gen-ed-ud\n \"Advise student if Gen Ed upper division requirements not satisfied.\"\n (not (exists (Course {courseId == \"ENGL 321\" || courseId == \"ENGL 324\"})))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed upper division requirements not satisfied\" \"Either Writing in the Technical Professions (ENGL 321) or Writing in the Sciences (ENGL 324) is required, but neither is listed among courses.\" \"ISSUE\")))\n\n;; Gen Ed Requirements\n(defrule gen-ed\n \"Advise student if Gen Ed requirements not satisfied.\"\n (or (exists (gen-ed-ld-not-satisfied)) (exists (gen-ed-ud-not-satisfied)))\n =>\n (assert (deg-req-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed requirements not satisfied\" \"See curriculm guide for details.\" \"ISSUE\")))\n\n\n\n;; One Year Lab Science Sequence Requirement\n(defrule lab-sci-biol-126\n (not (exists (Course {courseId == \"BIOL 126\"})))\n (not (exists (Course {courseId == \"BIOL 126L\"})))\n (not (exists (Course {courseId == \"BIOL 220\"})))\n (not (exists (Course {courseId == \"BIOL 220L\"})))\n =>\n (assert (no-biol-126-seq)))\n\n(defrule lab-sci-chem-121\n (not (exists (Course {courseId == \"CHEM 121\"})))\n (not (exists (Course {courseId == \"CHEM 121L\"})))\n (not (exists (Course {courseId == \"CHEM 122\"})))\n (not (exists (Course {courseId == \"CHEM 122L\"})))\n =>\n (assert (no-chem-121-seq)))\n\n(defrule lab-sci-chem-150\n (not (exists (Course {courseId == \"CHEM 150\"})))\n (not (exists (Course {courseId == \"CHEM 160\"})))\n (not (exists (Course {courseId == \"CHEM 151\"})))\n (not (exists (Course {courseId == \"CHEM 161\"})))\n =>\n (assert (no-chem-150-seq)))\n\n(defrule lab-sci-geol-105\n (not (exists (Course {courseId == \"GEOL 105\"})))\n (not (exists (Course {courseId == \"GEOL 105L\"})))\n (not (exists (Course {courseId == \"GEOL 106\"})))\n (not (exists (Course {courseId == \"GEOL 106L\"})))\n =>\n (assert (no-geol-105-seq)))\n\n(defrule lab-sci-phys-211\n (not (exists (Course {courseId == \"PHYS 211\"})))\n (not (exists (Course {courseId == \"PHYS 211L\"})))\n (not (exists (Course {courseId == \"PHYS 212\"})))\n (not (exists (Course {courseId == \"PHYS 212L\"})))\n =>\n (assert (no-phys-211-seq)))\n\n(defrule lab-sci-phys-251\n (not (exists (Course {courseId == \"PHYS 251\"})))\n (not (exists (Course {courseId == \"PHYS 251L\"})))\n (not (exists (Course {courseId == \"PHYS 252\"})))\n (not (exists (Course {courseId == \"PHYS 252L\"})))\n =>\n (bind ?*lab-seq-credits* 10)\n (assert (no-phys-251-seq)))\n\n(defrule lab-sci-seq-req\n (no-biol-126-seq)\n (no-chem-121-seq)\n (no-chem-150-seq)\n (no-geol-105-seq)\n (no-phys-211-seq)\n (no-phys-251-seq)\n =>\n (add (new Advice \"LabScienceRequirement\" \"Lab Science Sequence requirements not satisfied\" \"A one year sequence of lab science courses (with corresponding labs) is required.\" \"ISSUE\")))\n\n;; B.S. COMPUTER SCIENCE REQUIREMENTS\n\n;; \"C\" or better required for all CSCI courses\n(defrule c-in-cs-course\n \"Advise that will have to retake a CS course if it's a degree requirement and a D or worse received.\"\n (exists (Course (courseId ?cId&:(is-core ?cId))\n \t\t (grade \"D\"|\"F\")))\n =>\n (assert (bs-cs-degree-req-not-met))\n (add (new Advice \"MajorRequirement\" \"Computer Science Major requirements not satisfied\" \"A grade of 'C' or better is required for all CSCI courses.\" \"ISSUE\")))\n\n;; all core CSCI courses taken\n(defrule core-courses-taken\n \"Advise student if all core CSCI courses have not been taken.\"\n (not (exists (Record (studentId ?s&:(core-courses-satisfied ?s)))))\n =>\n (assert (bs-cs-degree-req-not-met))\n (add (new Advice \"MajorRequirement\" \"Major requirements not satisfied\" \"All core CSCI courses have not been taken.\" \"ISSUE\")))\n\n;; Computer Science Electives\n(defrule cs-elective-req\n \"Computer Science Elective requirements\"\n (exists (elective-req-not-met))\n =>\n (assert (bs-cs-degree-req-not-met))\n (add (new Advice \"ElectiveRequirement\" \"Computer Science Elective requirements not satisfied\" \"3 CS electives are required from at least 2 categories.\" \"ISSUE\")))\n\n(defrule cs-elective-req-credits\n \"Credit subrequirement for Computer Science Elective requirements\"\n ?totalCourses <- (accumulate (bind ?count 0)\n\t\t\t (bind ?count (+ ?count 1))\n\t\t\t ?count\n\t\t\t (Course (courseId ?cId&:(is-elective ?cId))))\n (test (< ?totalCourses 3))\n =>\n (assert (elective-req-not-met)))\n\n(defrule cs-elective-req-cat\n \"Category subrequirement for Computer Science Elective requirements\"\n (not (exists (Record (studentId ?sId&:(at-least-2-elect-cat ?sId)))))\n =>\n (assert (elective-req-not-met)))\n\n(defrule bs-cs-degree-req\n \"Requirements for a B.S. in CS\"\n (exists (bs-cs-degree-req-not-met))\n =>\n (add (new Advice \"MajorRequirement\" \"Computer Science B.S. degree requirements not satisfied\" \"Must take all required core courses and at least 3 computer science electives.\" \"ISSUE\")))\n\n;; RELATED REQUIRED COURSES\n(defrule related-course-req\n (exists (related-course-req-not-sat))\n =>\n (add (new Advice \"RelatedRequirement\" \"Related course requirements not satisfied.\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; Related required courses (MATH and STATS)\n(defrule related-course-req-math-stats\n (not (exists (Course {courseId == \"MATH 166\"})))\n (not (exists (Course {courseId == \"STAT 367\"})))\n (not (exists (Course {courseId == \"STAT 368\"})))\n =>\n (assert (related-course-req-not-sat))\n (add (new Advice \"RelatedRequirement\" \"Related course requirements for mathemtatics and statistics not satisfied.\" \"Calculus II (MATH 166), Probability (STATS 367), and Statistics (STATS 368) are required.\" \"ISSUE\")))\n\n;; Additional Science course\n(defrule related-course-req-science\n \"Advise student if additional science course requiremnet not fulfilled.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< (- ?totalCredits ?*lab-seq-credits*) 3))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (related-course-req-not-sat))\n (add (new Advice \"RelatedRequirement\" \"Related course requirements for additianl science course not satisfied.\" \"One additional science course that satisifies general education is required.\" \"ISSUE\")))\n\n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n (not (exists (Course {grade == \"NA\"})))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","old_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n\n;; GEN ED REQUIREMENTS\n\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {courseId == \"UNIV 189\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n (not (exists (Course {courseId == \"COMM 110\"})))\n (not (exists (Course {courseId == \"ENGL 110\"})))\n (not (exists (Course {courseId == \"ENGL 120\"})))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {courseId == \"MATH 165\"}))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; Humanities & Fine Arts (A) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-a\n \"Advise student if Gen Ed Humanities & Fine Arts requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"A\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Humanities & Fine Arts requirements not satisfied\" \"At least 6 credits in the General Education Humanities & Fine Arts area are required.\" \"ISSUE\")))\n\n;; Social & Behavioral Sciences (B) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-b\n \"Advise student if Gen Ed Social & Behavioral Sciences requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"B\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Social & Behavioral Sciences requirements not satisfied\" \"At least 6 credits in the General Education Social & Behavioral Sciences area are required.\" \"ISSUE\")))\n\n;; Wellness (W) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-w\n \"Advise student if Gen Ed Wellness requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"W\")))) ;; CE\n (test (< ?totalCredits 2))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Wellness requirements not satisfied\" \"At least 6 credits in the General Education Wellness area are required.\" \"ISSUE\")))\n\n;; Cultural Diversity (D) Requirements\n(defrule gen-ed-d\n \"Advise student if Gen Ed Cultural Diversity requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"D\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Cultural Diversity requirements not satisfied\" \"At least 1 course in the General Education Cultural Diversity area is required.\" \"ISSUE\")))\n\n;; Global Perspectives (G) Requirements\n(defrule gen-ed-g\n \"Advise student if Gen Ed Global Perspectives requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"G\")))))\n =>\n (assert (gen-ed-ld-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Global Perspectives requirements not satisfied\" \"At least 1 course in the General Education Global Perspectives area is required.\" \"ISSUE\")))\n\n;; Gen Ed Lower Division Requirements\n(defrule gen-ed-ld\n \"Adivce student if Gen Ed lower division requirements are not satisfied.\"\n (exists (gen-ed-ld-not-satisfied))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed lower division requirements not satisfied\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; Gen Ed Upper Division Requirements\n(defrule gen-ed-ud\n \"Advise student if Gen Ed upper division requirements not satisfied.\"\n (not (exists (Course {courseId == \"ENGL 321\" || courseId == \"ENGL 324\"})))\n =>\n (assert (gen-ed-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed upper division requirements not satisfied\" \"Either Writing in the Technical Professions (ENGL 321) or Writing in the Sciences (ENGL 324) is required, but neither is listed among courses.\" \"ISSUE\")))\n\n;; Gen Ed Requirements\n(defrule gen-ed\n \"Advise student if Gen Ed requirements not satisfied.\"\n (or (exists (gen-ed-ld-not-satisfied)) (exists (gen-ed-ud-not-satisfied)))\n =>\n (assert (deg-req-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed requirements not satisfied\" \"See curriculm guide for details.\" \"ISSUE\")))\n\n\n\n;; One Year Lab Science Sequence Requirement\n(defrule lab-sci-biol-126\n (not (exists (Course {courseId == \"BIOL 126\"})))\n (not (exists (Course {courseId == \"BIOL 126L\"})))\n (not (exists (Course {courseId == \"BIOL 220\"})))\n (not (exists (Course {courseId == \"BIOL 220L\"})))\n =>\n (assert (no-biol-126-seq)))\n\n(defrule lab-sci-chem-121\n (not (exists (Course {courseId == \"CHEM 121\"})))\n (not (exists (Course {courseId == \"CHEM 121L\"})))\n (not (exists (Course {courseId == \"CHEM 122\"})))\n (not (exists (Course {courseId == \"CHEM 122L\"})))\n =>\n (assert (no-chem-121-seq)))\n\n(defrule lab-sci-chem-150\n (not (exists (Course {courseId == \"CHEM 150\"})))\n (not (exists (Course {courseId == \"CHEM 160\"})))\n (not (exists (Course {courseId == \"CHEM 151\"})))\n (not (exists (Course {courseId == \"CHEM 161\"})))\n =>\n (assert (no-chem-150-seq)))\n\n(defrule lab-sci-geol-105\n (not (exists (Course {courseId == \"GEOL 105\"})))\n (not (exists (Course {courseId == \"GEOL 105L\"})))\n (not (exists (Course {courseId == \"GEOL 106\"})))\n (not (exists (Course {courseId == \"GEOL 106L\"})))\n =>\n (assert (no-geol-105-seq)))\n\n(defrule lab-sci-phys-211\n (not (exists (Course {courseId == \"PHYS 211\"})))\n (not (exists (Course {courseId == \"PHYS 211L\"})))\n (not (exists (Course {courseId == \"PHYS 212\"})))\n (not (exists (Course {courseId == \"PHYS 212L\"})))\n =>\n (assert (no-phys-211-seq)))\n\n(defrule lab-sci-phys-251\n (not (exists (Course {courseId == \"PHYS 251\"})))\n (not (exists (Course {courseId == \"PHYS 251L\"})))\n (not (exists (Course {courseId == \"PHYS 252\"})))\n (not (exists (Course {courseId == \"PHYS 252L\"})))\n =>\n (assert (no-phys-251-seq)))\n\n(defrule lab-sci-seq-req\n (no-biol-126-seq)\n (no-chem-121-seq)\n (no-chem-150-seq)\n (no-geol-105-seq)\n (no-phys-211-seq)\n (no-phys-251-seq)\n =>\n (add (new Advice \"LabScienceRequirement\" \"Lab Science Sequence requirements not satisfied\" \"A one year sequence of lab science courses (with corresponding labs) is required.\" \"ISSUE\")))\n\n;; B.S. COMPUTER SCIENCE REQUIREMENTS\n\n;; \"C\" or better required for all CSCI courses\n(defrule c-in-cs-course\n \"Advise that will have to retake a CS course if it's a degree requirement and a D or worse received.\"\n (exists (Course (courseId ?cId&:(is-core ?cId))\n \t\t (grade \"D\"|\"F\")))\n =>\n (add (new Advice \"MajorRequirement\" \"Computer Science Major requirements not satisfied\" \"A grade of 'C' or better is required for all CSCI courses.\" \"ISSUE\")))\n\n;; all core CSCI courses taken\n(defrule core-courses-taken\n \"Advise student if all core CSCI courses have not been taken.\"\n (not (exists (Record (studentId ?s&:(core-courses-satisfied ?s)))))\n =>\n (add (new Advice \"MajorRequirement\" \"Major requirements not satisfied\" \"All core CSCI courses have not been taken.\" \"ISSUE\")))\n\n;; Computer Science Electives\n(defrule cs-elective-req\n \"Computer Science Elective requirements\"\n (exists (elective-req-not-met))\n =>\n (add (new Advice \"ElectiveRequirement\" \"Computer Science Elective requirements not satisfied\" \"3 CS electives are required from at least 2 categories.\" \"ISSUE\")))\n\n(defrule cs-elective-req-credits\n \"Credit subrequirement for Computer Science Elective requirements\"\n ?totalCourses <- (accumulate (bind ?count 0)\n\t\t\t (bind ?count (+ ?count 1))\n\t\t\t ?count\n\t\t\t (Course (courseId ?cId&:(is-elective ?cId))))\n (test (< ?totalCourses 3))\n =>\n (assert (elective-req-not-met)))\n\n(defrule cs-elective-req-cat\n \"Category subrequirement for Computer Science Elective requirements\"\n (not (exists (Record (studentId ?sId&:(at-least-2-elect-cat ?sId)))))\n =>\n (assert (elective-req-not-met)))\n\n;; Related required courses (MATH and STATS)\n(defrule related-course-req\n (not (exists (Course {courseId == \"MATH 166\"})))\n (not (exists (Course {courseId == \"STAT 367\"})))\n (not (exists (Course {courseId == \"STAT 368\"})))\n =>\n (add (new Advice \"RelatedRequirement\" \"Related course requirements for mathemtatics and statistics not satisfied.\" \"Calculus II (MATH 166), Probability (STATS 367), and Statistics (STATS 368) are required.\" \"ISSUE\")))\n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n (not (exists (Course {grade == \"NA\"})))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"0cba60932b8db1f1e85f413dfaacf337cc7a58df","subject":"GLAPIArgumentConversion.clp: Added message handlers for code generation","message":"GLAPIArgumentConversion.clp: Added message handlers for code generation\n","repos":"DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/tools\/conv\/gl\/GLAPIArgumentConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIArgumentConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIArgumentConversion.clp\n; \n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot clips-type (type SYMBOL))\n (slot gl-type (type SYMBOL))\n (slot clips-function-name (type SYMBOL))\n (slot index (type INTEGER) (range 1 ?VARIABLE))\n (slot argument-name-base (type SYMBOL STRING))\n (slot data-object-argument-name (type SYMBOL STRING))\n (slot variable-argument-name (type SYMBOL STRING))\n (slot variable-declaration (type STRING))\n (slot data-object-declaration (type STRING))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-type-check-code ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,%s,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-type\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(deffunction get-conversion-function (?symbol)\n\t\t\t\t (bind ?fn-float \"DOToFloat\")\n\t\t\t\t (bind ?fn-double \"DOToDouble\")\n\t\t\t\t (bind ?fn-int \"DOToInteger\")\n\t\t\t\t (bind ?fn-long \"DOToLong\")\n\t\t\t\t (bind ?fn-string \"DOToString\")\n\t\t\t\t (switch ?symbol\n\t\t\t\t\t\t\t(case float then ?fn-float)\n\t\t\t\t\t\t\t(case FLOAT then ?fn-float)\n\t\t\t\t\t\t\t(case Float then ?fn-float)\n\t\t\t\t\t\t\t(case double then ?fn-double)\n\t\t\t\t\t\t\t(case DOUBLE then ?fn-double)\n\t\t\t\t\t\t\t(case Double then ?fn-double)\n\t\t\t\t\t\t\t(case integer then ?fn-int)\n\t\t\t\t\t\t\t(case INTEGER then ?fn-int)\n\t\t\t\t\t\t\t(case Integer then ?fn-int)\n\t\t\t\t\t\t\t(case long then ?fn-long)\n\t\t\t\t\t\t\t(case LONG then ?fn-long)\n\t\t\t\t\t\t\t(case Long then ?fn-long)\n\t\t\t\t\t\t\t(case symbol then ?fn-string)\n\t\t\t\t\t\t\t(case Symbol then ?fn-string)\n\t\t\t\t\t\t\t(case SYMBOL then ?fn-string)\n\t\t\t\t\t\t\t(case string then ?fn-string)\n\t\t\t\t\t\t\t(case String then ?fn-string)\n\t\t\t\t\t\t\t(case STRING then ?fn-string)\n\t\t\t\t\t\t\t(default \"ERROR_NO_CONVERSION_FOUND\")))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-conversion-code ()\n (return (format nil \"%s = %s(%s);\"\n\t\t\t\t\t\t\t\t\t ?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t (get-conversion-function ?self:clips-type)\n\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-length-variable-declaration)\n (slot multifield-length-variable-name)\n (slot multifield-pointer-argument-name)\n (slot multifield-pointer-declaration)\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n get-type-check-code primary ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,MULTIFIELD,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n (\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n get-conversion-code ()\n (return (format nil \"%s%n%s%n%s%n%s%n\"\n\t\t\t ;GetLength\n\t\t\t (format nil \"%s = GetDOLength(%s);\"\n\t\t\t \t\t\t\t?self:multifield-length-variable-name\n\t\t\t\t\t\t\t?self:data-object-argument-name)\n\t\t\t ;GetValue\n\t\t\t (format nil \"%s = GetValue(%s);\"\n\t\t\t ?self:multifield-pointer-argument-name\n\t\t\t ?self:data-object-argument-name)\n\t\t\t ;Conversion\n\t\t\t ;(format nil \"%\n\t\t\t ;get the multifield pointer out\n\t\t\t)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIArgumentBuilder\n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer TRUE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield-fixed\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIFixedArrayArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (size ?size))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIFixedMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(multifield-size ?size)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-multifield-conversion-code\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-multifield-conversion-code)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?o <- (object (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name)\n\t\t\t\t\t\t\t (argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-make-multifield-conversion-code))\n\t\t\t(bind ?baseName (sym-cat (format nil \"%s_MF\" ?anb)))\n\t\t\t(modify-instance ?o \n\t\t\t\t\t\t\t\t (multifield-pointer-argument-name ?baseName)\n\t\t\t\t\t\t\t\t (multifield-pointer-declaration (format nil \"void* %s;\" ?baseName))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-data-object-declaration\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-data-object-declaration)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?ab <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t\t(id ?name)\n\t\t\t\t\t\t\t\t(argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-data-object-declaration))\n\t\t\t(bind ?doArg (sym-cat (format nil \"%s_DO\" ?anb)))\n\t\t\t(modify-instance ?ab \n\t\t\t\t\t\t\t\t (data-object-argument-name ?doArg)\n\t\t\t\t\t\t\t\t (data-object-declaration \n\t\t\t\t\t\t\t\t\t (format nil \"DATA_OBJECT %s;\" ?doArg))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-type-check-contents\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-type-check-code)\n\t\t\t\t\t\t\t\t (arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (parent ?p)\n\t\t\t\t\t (argument-type ?arg-type)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t(object (is-a GLAPIFunction)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (function-name ?fname))\n\t\t\t?b <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t)\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIArgumentConversion.clp\n; \n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot index (type INTEGER) (range 1 ?VARIABLE))\n (slot argument-name-base (type SYMBOL STRING))\n (slot data-object-argument-name (type SYMBOL STRING))\n (slot variable-argument-name (type SYMBOL STRING))\n (slot variable-declaration (type STRING))\n (slot data-object-declaration (type STRING))\n (slot type-check-code (type STRING))\n (slot conversion-code (type STRING)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-pointer-argument-name)\n (slot multifield-pointer-declaration))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIArgumentBuilder\n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (is-pointer TRUE))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-function-argument-builder-multifield-fixed\n\t\t\t(declare (salience 1))\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action construct-entry)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIFixedArrayArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (index ?index)\n\t\t\t\t\t (size ?size))\n\t\t\t=>\n\t\t\t(make-instance ?name of CLIPSGLAPIFixedMultifieldArgumentBuilder \n\t\t\t\t\t\t\t\t(index (+ 1 ?index))\n\t\t\t\t\t\t\t\t(parent ?arg)\n\t\t\t\t\t\t\t\t(multifield-size ?size)\n\t\t\t\t\t\t\t\t(argument-name-base (sym-cat (format nil \"arg%d\" ?index))))\n\t\t\t(modify ?f (action make-variable-declaration))\n\t\t\t(duplicate ?f (action make-type-check-code))\n\t\t\t(duplicate ?f (action make-data-object-declaration))\n\t\t\t(duplicate ?f (action make-multifield-conversion-code))\n\t\t\t(duplicate ?f (action make-conversion-code)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-multifield-conversion-code\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-multifield-conversion-code)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?o <- (object (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name)\n\t\t\t\t\t\t\t (argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-make-multifield-conversion-code))\n\t\t\t(bind ?baseName (sym-cat (format nil \"%s_MF\" ?anb)))\n\t\t\t(modify-instance ?o \n\t\t\t\t\t\t\t\t (multifield-pointer-argument-name ?baseName)\n\t\t\t\t\t\t\t\t (multifield-pointer-declaration (format nil \"void* %s;\" ?baseName))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-data-object-declaration\n\t\t\t?f <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t(action make-data-object-declaration)\n\t\t\t\t\t\t\t\t(arguments ?arg => ?name))\n\t\t\t?ab <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t\t(id ?name)\n\t\t\t\t\t\t\t\t(argument-name-base ?anb))\n\t\t\t=>\n\t\t\t(modify ?f (action completed-data-object-declaration))\n\t\t\t(bind ?doArg (sym-cat (format nil \"%s_DO\" ?anb)))\n\t\t\t(modify-instance ?ab \n\t\t\t\t\t\t\t\t (data-object-argument-name ?doArg)\n\t\t\t\t\t\t\t\t (data-object-declaration \n\t\t\t\t\t\t\t\t\t (format nil \"DATA_OBJECT %s;\" ?doArg))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::construct-type-check-code\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-type-check-code)\n\t\t\t\t\t\t\t\t (arguments ?arg => ?name))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?arg)\n\t\t\t\t\t (parent ?p)\n\t\t\t\t\t (argument-type ?arg-type)\n\t\t\t\t\t (is-pointer FALSE))\n\t\t\t(object (is-a GLAPIFunction)\n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (function-name ?fname))\n\t\t\t?b <- (object (is-a CLIPSGLAPIArgumentBuilder)\n\t\t\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t)\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"646953db3ec4bb554bbb463e5a0a8aace08d762c","subject":"Added rules to look for GLAPI calls","message":"Added rules to look for GLAPI calls\n","repos":"DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defclass opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate file-line \n (slot index)\n (slot parent)\n (slot type)\n (multifield contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n;(defrule retract-unknowns \n; (declare (salience -10))\n; ?f <- (file-line (type UNKNOWN))\n; =>\n; (retract ?f))\n;------------------------------------------------------------------------------\n(defrule mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"aa8f14bc7a7d57ae805ff71d055506a96829f1e2","subject":"Gen Ed lower division requirements rule implemented.","message":"Gen Ed lower division requirements rule implemented.\n","repos":"jtan189\/CompSci-Degree-Expert-System,jtan189\/CompSci-Degree-Expert-System","old_file":"DegreeAdvisor\/src\/advisor.clp","new_file":"DegreeAdvisor\/src\/advisor.clp","new_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n\n;; GEN ED REQUIREMENTS\n\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {title == \"UNIV 189\"}))\n =>\n (assert (gen-ed-f-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n (not (exists (Course {title == \"COMM 110\"})))\n (not (exists (Course {title == \"ENGL 110\"})))\n (not (exists (Course {title == \"ENGL 120\"})))\n =>\n (assert (gen-ed-c-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {title == \"MATH 165\"}))\n =>\n (assert (gen-ed-r-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (assert (gen-ed-s-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; Humanities & Fine Arts (A) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-a\n \"Advise student if Gen Ed Humanities & Fine Arts requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"A\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-a-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Humanities & Fine Arts requirements not satisfied\" \"At least 6 credits in the General Education Humanities & Fine Arts area are required.\" \"ISSUE\")))\n\n;; Social & Behavioral Sciences (B) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-b\n \"Advise student if Gen Ed Social & Behavioral Sciences requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"B\")))) ;; CE\n (test (< ?totalCredits 6))\n =>\n (assert (gen-ed-b-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Social & Behavioral Sciences requirements not satisfied\" \"At least 6 credits in the General Education Social & Behavioral Sciences area are required.\" \"ISSUE\")))\n\n;; Wellness (W) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-w\n \"Advise student if Gen Ed Wellness requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"W\")))) ;; CE\n (test (< ?totalCredits 2))\n =>\n (assert (gen-ed-w-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Wellness requirements not satisfied\" \"At least 6 credits in the General Education Wellness area are required.\" \"ISSUE\")))\n\n;; Cultural Diversity (D) Requirements\n(defrule gen-ed-d\n \"Advise student if Gen Ed Cultural Diversity requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"D\")))))\n =>\n (assert (gen-ed-w-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Cultural Diversity requirements not satisfied\" \"At least 1 course in the General Education Cultural Diversity area is required.\" \"ISSUE\")))\n\n;; Global Perspectives (G) Requirements\n(defrule gen-ed-g\n \"Advise student if Gen Ed Global Perspectives requirements not satisfied.\"\n (not (exists (Course (courseId ?t&:(is-gen-ed ?t \"G\")))))\n =>\n (assert (gen-ed-g-not-satisfied))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Global Perspectives requirements not satisfied\" \"At least 1 course in the General Education Global Perspectives area is required.\" \"ISSUE\")))\n\n;; Gen Ed Lower Division Requirements\n(defrule gen-ed-ld\n \"Adivce student if Gen Ed lower division requirements are not satisfied.\"\n (or (gen-ed-f-not-satisfied)\n (gen-ed-c-not-satisfied)\n (gen-ed-r-not-satisfied)\n (gen-ed-s-not-satisfied)\n (gen-ed-a-not-satisfied)\n (gen-ed-b-not-satisfied)\n (gen-ed-w-not-satisfied)\n (gen-ed-d-not-satisfied)\n (gen-ed-g-not-satisfied))\n =>\n (add (new Advice \"GenEdRequirement\" \"Gen Ed lower division requirements not satisfied\" \"See curriculum guide for details.\" \"ISSUE\")))\n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n (not (exists (Course {grade == \"NA\"})))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","old_contents":";; Define templates for model classes\n(import com.joshktan.advisor.model.*)\n(deftemplate Course\n (declare (from-class Course)))\n(deftemplate Record\n (declare (from-class Record)))\n(deftemplate Advice\n (declare (from-class Advice)))\n\n;; GLOBAL VARIABLES\n(defglobal ?*total-credit-req* = (get-member com.joshktan.advisor.req.TotalCreditsRequirement TOTAL_CREDITS_REQUIRED))\n\n;; GEN ED REQUIREMENTS\n;; First Year Experience (F) Requirements\n(defrule gen-ed-f\n \"Advise student if Gen Ed First Year Experience requirements not satisfied.\"\n (not (Course {title == \"UNIV 189\"}))\n =>\n (add (new Advice \"GenEdRequirement\" \"Gen Ed First Year Experience requirements not satisfied\" \"Skills for Academic Success (UNIV 189) is required, but is not listed among courses.\" \"ISSUE\")))\n;; Communication (C) Requirements\n(defrule gen-ed-c\n \"Advise student if Gen Ed Communication requirements not satisfied.\"\n ;; (and (not (exists (Course {title == \"COMM 110\"}))) (not (exists (GradedCourse {title == \"COMM 110\"}))))\n ;; (and (not (exists (Course {title == \"ENGL 110\"}))) (not (exists (GradedCourse {title == \"ENGL 110\"}))))\n ;; (and (not (exists (Course {title == \"ENGL 120\"}))) (not (exists (GradedCourse {title == \"ENGL 120\"}))))\n (not (exists (Course {title == \"COMM 110\"})))\n (not (exists (Course {title == \"ENGL 110\"})))\n (not (exists (Course {title == \"ENGL 120\"})))\n =>\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Communication requirements not satisfied\" \"College Composition I (ENGL 110), College Composition II (ENGL 120), and Fundamentals of Public Speaking (COMM 110) are required.\" \"ISSUE\")))\n;; Quantitative Reasoning (R) Requirements\n(defrule gen-ed-r\n \"Advise student if Gen Ed Quantitative Reasoning requirements not satisfied.\"\n (not (Course {title == \"MATH 165\"}))\n =>\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Quantitative Reasoning requirements not satisfied\" \"Calculus I (MATH 165) is required, but is not listed among courses.\" \"ISSUE\")))\n;; Science & Technology (S) Requirements\n;; TODO - make sure all different\n(defrule gen-ed-s\n \"Advise student if Gen Ed Science & Technology requirements not satisfied.\"\n ?totalCredits <- (accumulate (bind ?count 0) ;; initializer\n\t\t\t (bind ?count (+ ?count ?credits)) ;; action\n\t\t\t ?count ;; result\n\t\t\t (Course (credits ?credits) (courseId ?t&:(is-gen-ed ?t \"S\")))) ;; CE\n (test (< ?totalCredits 10))\n =>\n;; ((System.out) println (?totalCredits toString))\n (add (new Advice \"GenEdRequirement\" \"Gen Ed Science & Technology requirements not satisfied\" \"At least 10 credits in the General Education Science and Technology area are required.\" \"ISSUE\")))\n\n;; UNIVERSITY GRADUATION REQUIREMENTS\n;; Total Degree Credits Requirement\n(defrule total-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n ?r <- (Record)\n =>\n (if (< ?r.totalCredits ?*total-credit-req*) then\n (assert (not-enough-credits))\n else\n (assert (enough-credits))))\n(defrule not-enough-credits\n \"Advise to take more credits if total credit amount is less than the required amount.\"\n (not-enough-credits)\n ?r <- (Record)\n =>\n (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n\n;; CRITERA FOR GRADUATING WITH HONOR\n(defrule graduate-with-honors\n ?record <- (Record {gpa >= 3.5})\n;; (not (exists ((Course {grade != \"NA\"}))))\n (not (exists (Course {grade == \"NA\"})))\n;;\t ( ?course \"GradedCourse\"))\n ;; TODO add other requirements here\n =>\n (assert (honors))\n (if (>= ?record.gpa 3.90) then\n (add (new Congrats \"You will graduate summa cum laude.\"))\n elif (>= ?record.gpa 3.70) then\n (add (new Congrats \"You will graduate magna cum laude.\"))\n else\n (add (new Congrats \"You will graduate cum laude.\"))))\n\n;; ---------------------------------------------------------------------- ;;\n\n;; Just so you know how to do it\n;; (defrule enough-credits-and-honors\n;; \"enough credits and honors also\"\n;; (and (honors) (enough-credits))\n;; =>\n;; ((System.out) println \"Both enough credits and also honorable!\"))\n\n;; (# semesters left * 20 ) < (needed - already have) => advise warning: fill out form thing for +20 credits \/ semester (or summer school or postpone grad)\n\n;; Graduating Honors (figure out how to chain rules: (if all courses have grades) && (all requirements fulfilled) => (add congrats)\n\n;; COULD BE USEFUL:\n;; The not CE can be used in arbitrary combination with the and and or CEs. You can define complex logical structures this way. For example, suppose you want a rule to fire once if for every fact (a ?x), there is a fact (b ?x). You could express that as\n;; Jess> (defrule forall-example\n;; (not (and (a ?x) (not (b ?x))))\n;; =>)\n;; i.e., \"It is not true that for some ?x, there is an (a ?x) and no (b ?x)\". This is actually how the the forall CE is implemented.\n\n;; note: (instanceof )\n\n;; COULD ALSO BE USEFUL\n;; The logical conditional element lets you specify logical dependencies among facts. All the facts asserted on the RHS of a rule become dependent on the matches to the logical patterns on that rule's LHS. If any of the matches later become invalid, the dependent facts are retracted automatically.\n;; (defrule rule-1\n;; (logical (faucet-open))\n;; =>\n;; (assert (water-flowing)))\n;; =>\n;; (assert (all-cour)))\n\n;; Graduation with honor eligibility is determined in two steps:\n;; Step One: Earn a minimum NDSU (institutional) GPA of 3.50\n;; NDSU GPA's below 3.50 are not considered (and step two is not necessary)\n;; Step Two: Earn an overall (cumulative) GPA of 3.50 or greater, which includes:\n;; all credits and grades earned at NDSU\n;; the inclusion of all transfer work and all attempts of repeated coursework\n;;\n;; Candidates who achieve an overall GPA of 3.50 or higher according to the criteria listed above will graduate: \n;; Cum Laude \u2014 greater than or equal to 3.50 and less than 3.70 \n;; Magna Cum Laude \u2014 greater than or equal to 3.70 and less than 3.90 \n;; Summa Cum Laude \u2014 greater than or equal to 3.90 and up to 4.00 \n;; The complete Graduation with Honor policy may be reviewed in the online Undergraduate Bulletin\n;; PLEASE BE AWARE grade-point averages are NOT rounded (for example, a GPA of 3.497 is not rounded to 3.5) \n;; PLEASE BE AWARE graduation with honor levels are subject to change once final grades are determined and posted to the official academic record\n\n;; ;; matches any\n;; (defrule any\n;; (Record (studentId ?sId))\n;; =>\n;; ((System.out) println \"Testing 1,2,3\" ))\n\n;; Old rule - University Graduation Requirements\n;; (defrule total-credit-req\n;; \"Advise to take more credits if total credit amount is less than the required amount.\"\n;; ?r <- (Record {totalCredits < ?*total-credit-req*})\n;; =>\n;; (assert (enough-credits))\n;; (add (new Advice \"TotalCreditsRequirement\" \"Too little credits\" (str-cat \"Have \" ?r.totalCredits \" credits, but need \" ?*total-credit-req* \".\") \"ISSUE\")))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"74b4ea48b6617227a22ed0a3dd6279d081d5301c","subject":"update knowledge","message":"update knowledge\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beer-questions.clp","new_file":"clips\/beer-questions.clp","new_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n \"Classic topping pizzas pair well with crisp and clean beers.\"\n \"Meat topping pizzas pair well with hoppy and bitter beers.\"\n \"Vegetables.\"\n \"Cheese topping pizzas pair well with fruity and spicy beers.\"))\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entree-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Fish_ pair well with the bitterness of the \"\n \"English-Style Bitter and the sweetness of the \"\n \"English-Style Pale Ale.\")\n (str-cat \" _Meat_ pairs well with Scottish-Style Ales.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" With _fats_ strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entree-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entree-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and\n \"have a very creamy taste and soft texture.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \")\n (why (str-cat \" Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \")\n (why (str-cat \" Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm-hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \")\n (why (str-cat \" Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \")\n (why (str-cat \" Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \")\n (why \" Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \"))\n (why (str-cat \" Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \")\n (why (str-cat \" Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","old_contents":"\n;;***********************\n;;* BEER QUESTION RULES *\n;;***********************\n\n; random questions for user type and scenario recognition\n\n(defrule determine-which-sex\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you male or female?\")\n (relation-asserted which-sex)\n (valid-answers male female))))\n\n(defrule determine-which-age\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"How old are you?\")\n (relation-asserted which-age)\n (valid-answers 18-22 22-25 25-30 30-40 >=40))))\n\n(defrule determine-which-season\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"It is autumn, spring, summer or winter?\")\n (relation-asserted which-season)\n (valid-answers autumn spring summer winter))))\n\n(defrule determine-preferred-carbonation\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally prefer to drink low, medium or high carbonated drinks? \")\n (relation-asserted preferred-carbonation)\n (valid-answers low medium high))))\n\n(defrule determine-whether-he-is-a-regular-beer-drinker\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Are you a regular beer drinker? \")\n (relation-asserted regular-beer-drinker)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-eats-fermented-foods\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you generally eat fermented foods (probiotic yogurt, kefir, kombucha, etc.)? \")\n (relation-asserted fermented-foods-eater)\n (valid-answers yes no))))\n\n(defrule determine-whether-he-should-drive\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"Do you have to drive? \")\n (relation-asserted driver)\n (valid-answers yes no))))\n\n(defrule determine-preferred-flavor\n (declare (salience ?*very-high-priority*))\n (start)\n =>\n (assert (UI-state (display \"What kind of flavor do you generally prefer?\")\n (relation-asserted preferred-flavor)\n (valid-answers clean sweet bitter roasty fruity spicy sour \"don't know\"))))\n\n; depth questions for meal type recognition\n\n(defrule determine-food-style\n (start)\n =>\n (assert (UI-state (display \"Are you vegetarian, vegan or omnivorous?\")\n (relation-asserted food-style)\n (valid-answers vegetarian vegan omnivorous))))\n\n(defrule determine-main-meal-for-omnivorous-or-vegetarian\n (or (food-style omnivorous)\n (food-style vegetarian))\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e, cheese or dessert? \")\n (relation-asserted main-meal-for-omnivorous-or-vegetarian)\n (valid-answers pizza entr\u00e9e cheese dessert other))))\n\n(defrule determine-main-meal-for-vegan\n (food-style vegan)\n =>\n (assert (UI-state (display \"Is the main meal pizza, entr\u00e9e or dessert?\")\n (relation-asserted main-meal-for-vegan)\n (valid-answers pizza entr\u00e9e dessert other))))\n\n ; ... if main meal is pizza\n\n(defrule determine-pizza-for-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, meat, vegetables, cheese or other?\")\n (why (format nil \"%s %n%s %n%s %n%s\"\n \"Classic topping pizzas pair well with crisp and clean beers.\"\n \"Meat topping pizzas pair well with hoppy and bitter beers.\"\n \"Vegetables.\"\n \"Cheese topping pizzas pair well with fruity and spicy beers.\"))\n (relation-asserted pizza-topping-for-omnivorous)\n (valid-answers classic meat vegetables cheese other))))\n\n(defrule determine-if-meat-topping-is-spicy\n (pizza-topping-for-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat spicy?\")\n (relation-asserted meat-topping-is-spicy)\n (valid-answers yes no))))\n\n(defrule determine-pizza-for-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables, cheese or other?\")\n (relation-asserted pizza-topping-for-vegetarian)\n (valid-answers classic vegetables cheese other))))\n\n(defrule determine-pizza-for-vegan\n (main-meal-for-vegan pizza)\n =>\n (assert (UI-state (display \"Is the pizza topping classic, vegetables or other?\")\n (relation-asserted pizza-topping-for-vegan)\n (valid-answers classic vegetables other))))\n\n(defrule determine-if-vegetables-topping-are-roasted\n (or (pizza-topping-for-omnivorous vegetables)\n (pizza-topping-for-vegetarian vegetables)\n (pizza-topping-for-vegan vegetables))\n =>\n (assert (UI-state (display \"Are the vegetables roasted?\")\n (relation-asserted vegetables-topping-are-roasted)\n (valid-answers yes no))))\n\n ; ... if main meal is cheese\n\n(defrule determine-which-cheese-style\n (main-meal-for-omnivorous-or-vegetarian cheese)\n =>\n (assert (UI-state (display (str-cat \"Is the cheese style fresh (Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese, \"\n \"Quark, Cottage, etc.), semi-soft (Mozzarella, Colby, Fontina, Havarti, Monterey \"\n \"Jack, etc.), firm\/hard (Gouda, Cheddar, Swiss, Parmesan), blue (Roquefort, \"\n \"Gorgonzola, Danish, etc.), natural rind (Brie, Camembert, Triple Cr\u00e8me, \"\n \"Mimolette, Stilton, Lancashire, Tomme de Savoie, etc.) or washed rind (Epoisses, \"\n \"Livarot, Taleggio, etc.)? \"))\n (help (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" _Fresh_ cheeses have not been aged, or are very slightly cured. \"\n \"These cheeses have a high moisture content and are usually mild and\n \"have a very creamy taste and soft texture.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses have a smooth, generally, \"\n \"creamy interior with little or no rind. These cheeses are generally \"\n \"high in moisture content and range from very mild in flavor to very \"\n \"pungent.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses have a taste profiles range \"\n \"from very mild to sharp and pungent. They generally have a texture \"\n \"profile that ranges from elastic, at room temperature, to the hard \"\n \"cheeses that can be grated.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses have a distinctive blue\/green \"\n \"veining, created when the penicillium roqueforti mold, added during the \"\n \"make process, is exposed to air. This mold provides a distinct flavor \"\n \"to the cheese, which ranges from fairly mild to assertive and pungent.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses have rinds that are \"\n \"self-formed during the aging process. Generally, no molds or microflora \"\n \"are added, nor is washing used to create the exterior rinds, and those \"\n \"that do exhibit molds and microflora in their rinds get them naturally \"\n \"from the environment.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses are surface-ripened by \"\n \"washing the cheese throughout the ripening\/aging process with brine, \"\n \"beer, wine, brandy, or a mixture of ingredients, which encourages the \"\n \"growth of bacteria. The exterior rind of washed rind cheeses may vary \"\n \"from bright orange to brown, with flavor and aroma profiles that are \"\n \"quite pungent, yet the interior of these cheeses is most often \"\n \"semi-soft and, sometimes, very creamy.\")))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Fresh cheeses are light cheeses which pair excellently with the \"\n \"softer flavors of Wheat and Lambic beers.\")\n (str-cat \" [Semi-soft](www.goo.gl\/izu1Bw) cheeses can be paired with many \"\n \"different craft beers, such as German K\u00f6lsch or Bock and Pale Ale beers.\")\n (str-cat \" [Firm\/hard](www.goo.gl\/yrfoJK) cheeses are easily paried with an \"\n \"equally broad range of craft beer styles, such as Pilsner, Bock, Brown \"\n \"Ale and Imperial Stout.\")\n (str-cat \" [Blue](www.goo.gl\/9KkNww) cheeses are stronger-flavored cheeses which \"\n \"are most successfully balanced with stonger-flavored bolder beers like \"\n \"IPAs or Imperial IPAs.\")\n (str-cat \" [Natural rind](www.goo.gl\/ys8pkz) cheeses pair well with Golden, \"\n \"Blonde and traditional British-style ales.\")\n (str-cat \" [Washed rind](www.goo.gl\/Kh3BwD) cheeses, while potentially pungent, \"\n \"are often creamy and can be paired with Belgian-styles ales, like \"\n \"Triples and Golden Strong ales with these varieties.\")))\n (relation-asserted which-cheese-style)\n (valid-answers fresh semi-soft firm\/hard blue \"natural rind\" \"washed rind\" \"don't know\"))))\n\n(defrule determine-which-fresh-cheese\n (which-cheese-style fresh)\n =>\n (assert (UI-state (display \"Is the fresh cheese Mascarpone, Ricotta, Ch\u00e8vre, Feta, Cream Cheese or other? \")\n (why (str-cat \" Italian-Style Mascarpone, Ricotta and soft Ch\u00e8vre will match the delicate notes \"\n \"of the beer and neither will overwhelm the palate in the beginning of a meal.\"))\n (relation-asserted which-fresh-cheese)\n (valid-answers Mascarpone Ricotta Ch\u00e8vre Feta \"Cream Cheese\" other))))\n\n(defrule determine-which-semi-soft-cheese\n (which-cheese-style semi-soft)\n =>\n (assert (UI-state (display \"Is the semi-soft cheese Mozzarella, Colby, Havarti, Monterey Jack or other? \")\n (why (str-cat \" Fontina, Havarti and milder blue cheeses can be enhanced by the carbonation of \"\n \"K\u00f6lsch style ales. The gentle notes of grass in the cheese can be brought out by \"\n \"using the malt of a Bock or the hops of a Pale Ale.\"))\n (relation-asserted which-semi-soft-cheese)\n (valid-answers Mozzarella Colby Havarti \"Monterey Jack\" other))))\n\n(defrule determine-which-firm-hard-cheese\n (which-cheese-style firm\/hard)\n =>\n (assert (UI-state (display \"Is the firm\/hard cheese Gouda, Cheddar, Swiss, Parmesan or other? \")\n (why (str-cat \" Cheddar and Swiss cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale. Roasty stouts can add a creaminess to the firm and hard \"\n \"cheeses on the palate.\"))\n (relation-asserted which-firm\/hard-cheese)\n (valid-answers Gouda Cheddar Swiss Parmesan other))))\n\n(defrule determine-which-type-of-Gouda\n (which-firm\/hard-cheese Gouda)\n =>\n (assert (UI-state (display \"Is the Gouda cheese aged, smoked or other? \")\n (relation-asserted which-type-of-Gouda)\n (valid-answers aged smoked other))))\n\n(defrule determine-which-color-of-Cheddar\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese white or yellow? \")\n (relation-asserted which-color-of-Cheddar)\n (valid-answers white yellow))))\n\n(defrule determine-which-Cheddar-seasoning\n (which-firm\/hard-cheese Cheddar)\n =>\n (assert (UI-state (display \"Is the Cheddar cheese seasoning mild, medium, aged or other? \")\n (relation-asserted which-Cheddar-seasoning)\n (valid-answers mild medium aged other))))\n\n(defrule determine-if-Cheddar-is-sharp\n (or (which-Cheddar-seasoning medium)\n (which-Cheddar-seasoning aged))\n =>\n (assert (UI-state (display \"Is the Cheddar cheese sharp? \")\n (relation-asserted Cheddar-is-sharp)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-type-of-Swiss\n (which-firm\/hard-cheese Swiss)\n =>\n (assert (UI-state (display \"Is the Swiss cheese Emmental, Gruy\u00e8re or other? \")\n (why (str-cat \" Emmentaler-style cheeses can mimic the Maillard reaction when paired with a beer \"\n \"style, such as a Brown Ale.\"))\n (relation-asserted which-type-of-Swiss)\n (valid-answers Emmental Gruy\u00e8re other))))\n\n(defrule determine-if-Swiss-is-aged\n (which-type-of-Swiss other)\n =>\n (assert (UI-state (display \"Is the Swiss aged? \")\n (relation-asserted Swiss-is-aged)\n (valid-answers yes no \"don't know\"))))\n\n(defrule determine-which-blue-cheese\n (which-cheese-style blue)\n =>\n (assert (UI-state (display \"Is the blue cheese Stilton or other? \")\n (why \" Stilton cheese can be intensified the sweetness on the palate with a Barley Wine.\")\n (relation-asserted which-blue-cheese)\n (valid-answers Stilton other))))\n\n(defrule determine-which-natural-rind-cheese\n (which-cheese-style \"natural rind\")\n =>\n (assert (UI-state (display (str-cat \"Is the natural rind cheese Brie, Camembert, Triple Cr\u00e8me, Mimolette, Stilton, \"\n \"or other? \"))\n (why (str-cat \" Lancashire, Stilton, Brie and Camembert all share a rich creamy base that can be \"\n \"refreshed with a Golden, Blond or Pale Ale or intensified the sweetness on the \"\n \"palate with a Barley Wine.\"))\n (relation-asserted which-natural-rind-cheese)\n (valid-answers Brie Camembert \"Triple Cr\u00e8me\" Mimolette Stilton other))))\n\n(defrule determine-which-washed-rind-cheese\n (which-cheese-style \"washed rind\")\n =>\n (assert (UI-state (display \"Is the washed rind cheese Taleggio or other? \")\n (why (str-cat \" Classic Belgian yeast flavors spur a tighter carbonation as well as bring out \"\n \"delicate sweet notes that can cut through the funk of a washed rind cheeses.\"))\n (relation-asserted which-washed-rind-cheese)\n (valid-answers Taleggio other))))\n\n ; ... if main meal is entr\u00e9e\n\n(defrule determine-which-entree-omnivorous\n (food-style omnivorous)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), fish, meat, \"\n \"vegetables, fats or other?\"))\n (why (format nil \"%s %n%s %n%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Fish_ pair well with the bitterness of the \"\n \"English-Style Bitter and the sweetness of the \"\n \"English-Style Pale Ale.\")\n (str-cat \" _Meat_ pairs well with Scottish-Style Ales.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" With _fats_ strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-omnivorous)\n (valid-answers grain legumes fish meat vegetables fats other))))\n\n(defrule determine-which-entree-vegetarian\n (food-style vegetarian)\n (main-meal-for-omnivorous-or-vegetarian entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.) or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegetarian)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-entree-vegan\n (main-meal-for-vegan entr\u00e9e)\n =>\n (assert (UI-state (display (str-cat \"Is the main component of the entr\u00e9e grain (farro, arborio, wild rice, polenta, \"\n \"etc.), legumes (lentils, fava, chickpea, green beans, etc.), vegetables, \"\n \"vegetables fats (avocados, olive oil, peanut butter, nuts and seeds, etc.), or \"\n \"other?\"))\n (why (format nil \"%s %n%s %n%s %n%s\"\n (str-cat \" Complementary _grain_ flavors balance hops while \"\n \"remaining light on the palate.\")\n (str-cat \" _Legumes_ add richness to the beer while balancing \"\n \"salt and acidity.\")\n (str-cat \" _Vegetables_ pair well with clean Dark Lagers and \"\n \"American Brown Ale.\")\n (str-cat \" _Vegetables fats_ pair well with high carbonated \"\n \"beers. With fats strong flavors, beer balances and \"\n \"allows for a complex finish.\")))\n (relation-asserted which-entr\u00e9e-vegan)\n (valid-answers grain legumes vegetables \"vegetables fats\" other))))\n\n(defrule determine-which-grain\n (or (which-entr\u00e9e-omnivorous grain)\n (which-entr\u00e9e-vegetarian grain)\n (which-entr\u00e9e-vegan grain))\n =>\n (assert (UI-state (display \"Are the grain chips, spaghetti, bruschetta, grits or other?\")\n (relation-asserted which-grain)\n (valid-answers chips spaghetti bruschetta grits other))))\n\n(defrule determine-which-fish-cooking-method\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display \"Is the fish cooking method grilled or other?\")\n (relation-asserted fish-cooking-method)\n (valid-answers grilled other))))\n\n(defrule determine-which-fish\n (which-entr\u00e9e-omnivorous fish)\n =>\n (assert (UI-state (display (str-cat \"Is the fish shellfish (clams, scallops, lobster, crab, etc.), bluefish (salmon, \"\n \"trout, tuna, etc.) or other? \"))\n (relation-asserted which-fish)\n (valid-answers shellfish bluefish other))))\n\n(defrule determine-if-shellfish-is-mild\n (which-fish shellfish)\n =>\n (assert (UI-state (display \"Is the shellfish mild (squid, cuttlefish, octopus)? \")\n (relation-asserted shellfish-is-mild)\n (valid-answers yes no))))\n\n(defrule determine-which-shellfish\n (shellfish-is-mild no)\n =>\n (assert (UI-state (display \"Are the fish shellfish shrimps, mussels, oysters or other? \")\n (relation-asserted which-shellfish)\n (valid-answers shrimps mussels oysters other))))\n\n(defrule determine-which-bluefish\n (which-fish bluefish)\n =>\n (assert (UI-state (display \"Is the bluefish salmon or other?\")\n (relation-asserted which-bluefish)\n (valid-answers salmon other))))\n\n(defrule determine-which-meat-cooking-method\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat cooking method barbecue, braised, grilled, roasted or other?\")\n (relation-asserted meat-cooking-method)\n (valid-answers barbecue braised grilled roasted other))))\n\n(defrule determine-which-meat\n (which-entr\u00e9e-omnivorous meat)\n =>\n (assert (UI-state (display \"Is the meat rich (beef, lamb, pork, etc.), poultry, game, steak or other?\")\n (relation-asserted which-meat)\n (valid-answers rich poultry game steak other))))\n\n(defrule determine-which-rich\n (which-meat rich)\n =>\n (assert (UI-state (display \"Is the rich meat beef, lamb, pork or other?\")\n (relation-asserted which-rich)\n (valid-answers beef lamb pork other))))\n\n(defrule determine-which-beef\n (which-rich beef)\n =>\n (assert (UI-state (display \"Is the beef bresaola or other?\")\n (relation-asserted which-beef)\n (valid-answers bresaola other))))\n\n(defrule determine-which-pork\n (which-rich pork)\n =>\n (assert (UI-state (display \"Is the pork loin, tenderloin, prosciutto, speck, mortadella, sausage or other?\")\n (relation-asserted which-pork)\n (valid-answers loin tenderloin prosciutto speck mortadella sausage other))))\n\n(defrule determine-which-sausage\n (which-pork sausage)\n =>\n (assert (UI-state (display \"Is the sausage capocollo, soppressata, salame piccante or other?\")\n (relation-asserted which-sausage)\n (valid-answers capocollo soppressata \"salame piccante\" other))))\n\n(defrule determine-which-poultry\n (which-meat poultry)\n =>\n (assert (UI-state (display \"Is the poultry chicken or turkey?\")\n (relation-asserted which-poultry)\n (valid-answers chicken turkey))))\n\n(defrule determine-which-game\n (which-meat game)\n =>\n (assert (UI-state (display \"Is the game wild or birds (duck, quail, quinoa, etc.)?\")\n (relation-asserted which-game)\n (valid-answers wild birds))))\n\n(defrule determine-which-game-birds\n (which-game birds)\n =>\n (assert (UI-state (display \"Is the game birds duck or other?\")\n (relation-asserted which-game-birds)\n (valid-answers duck other))))\n\n(defrule determine-which-vegetables-cooking-method\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables cooking method grilled, roasted or other?\")\n (relation-asserted vegetables-cooking-method)\n (valid-answers grilled roasted other))))\n\n(defrule determine-which-vegetables\n (or (which-entr\u00e9e-omnivorous vegetables)\n (which-entr\u00e9e-vegetarian vegetables)\n (which-entr\u00e9e-vegan vegetables))\n =>\n (assert (UI-state (display \"Is the vegetables root (parsnips, carrots, etc.), salad or other?\")\n (relation-asserted which-vegetables)\n (valid-answers root salad other))))\n\n(defrule determine-which-other-vegetables\n (which-vegetables other)\n =>\n (assert (UI-state (display \"Are the vegetables mushrooms or other?\")\n (relation-asserted which-other-vegetables)\n (valid-answers mushrooms other))))\n\n(defrule determine-which-fats\n (which-entr\u00e9e-omnivorous fats)\n =>\n (assert (UI-state (display (str-cat \"Is the fats vegetable (avocados, olive oil, peanut butter, nuts and seeds, etc.) \"\n \"or animal (duck\/pork fat, dairy, etc.)?\"))\n (why \"Carbonation is an effective tool to cleanse vegetable fats.\")\n (relation-asserted which-fats)\n (valid-answers vegetable animal other))))\n\n ; ... if main meal is dessert\n\n(defrule determine-which-dessert\n (or (which-entr\u00e9e-omnivorous dessert)\n (which-entr\u00e9e-vegetarian dessert))\n =>\n (assert (UI-state (display (str-cat \"Is the dessert creamy (cheesecake, ice cream, creme br\u00fbl\u00e9e, mousse cake), \"\n \"chocolate or other? \"))\n (relation-asserted which-dessert)\n (valid-answers creamy chocolate other))))\n\n(defrule determine-which-chocolate\n (which-dessert chocolate)\n =>\n (assert (UI-state (display (str-cat \"Is the chocolate white, milk (35% cacao ca.), semisweet (55% cacao ca.), \"\n \"bittersweet (70% cacao ca.) or unsweetened\/bitter (100% cacao)? \"))\n (relation-asserted which-chocolate)\n (valid-answers white milk semisweet bittersweet unsweetened\/bitter \"don't know\"))))\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"8ac1b7a60a987d0b36c26323cb1885d975efb9b0","subject":"Update task1.clp","message":"Update task1.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter7\/task1.clp","new_file":"ssu-ai-level-2\/chapter7\/task1.clp","new_contents":";Get string, first symbol and second symbol.\n;Replace all entityes of first symbol with second.\n(defrule replace\n =>\n (bind ?str (readline))\n (bind ?a (readline))\n (bind ?b (readline))\n (bind ?n (str-length ?str))\n (bind ?res \"\")\n (loop-for-count (?i 1 ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n (bind ?d (str-compare ?c1 ?a))\n\n (if (= ?d 0) then\n (bind ?res (str-cat ?res ?b)))\n\n (if (<> ?d 0) then\n (bind ?res (str-cat ?res ?c1))))\n\n (printout t \"result=\" ?res crlf) \n )\n","old_contents":"(defrule replace\n =>\n (bind ?str (readline))\n (bind ?a (readline))\n (bind ?b (readline))\n (bind ?n (str-length ?str))\n (bind ?k 0)\n (loop-for-count (?i 1 ?n) do\n (bind ?c1 (sub-string ?i ?i ?str))\n (bind ?d (str-compare ?c1 ?a))\n\n (if (= ?d 0) then\n (printout t \"k=\" ?k crlf))))\n","returncode":0,"stderr":"","license":"apache-2.0","lang":"CLIPS"} {"commit":"5ed7b35bf46783a1766f6f4b93f6ca228a841e6f","subject":"Wrote rules to split commas and parens away from corresponding symbols","message":"Wrote rules to split commas and parens away from corresponding symbols\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule retract-invalid-elements\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input modify-input \n identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result)))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"7570fc6ae19e004fd0dc22d125ac7f071157122f","subject":"Added a rule to delete ungrouped objects","message":"Added a rule to delete ungrouped objects\n","repos":"DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/AdventureEngine,DrItanium\/electron-platform","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule retract-invalid-elements\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input \n modify-input \n identify-lines \n convert-templates \n build-groups\n retract-invalid-elements)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n(defrule retract-invalid-elements::delete-still-existing-elements\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n ?obj <- (object (is-a file-line)\n (id ?id))\n =>\n (send ?obj print)\n (unmake-instance ?obj)\n (retract ?msg))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule retract-invalid-elements\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(defclass types::file-line\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::file-line init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::grouping\n (is-a USER)\n (slot group-name)\n (slot parent)\n (slot from (type INTEGER) (range 0 ?VARIABLE))\n (slot to (type INTEGER) (range 0 ?VARIABLE))\n (multislot contents))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus read-input modify-input \n identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule read-input::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (if (neq ?result \"\") then\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-commas\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \",\"))\n (str-index \",\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \",\" ?str))\n (bind ?p0 (sub-string 1 (- ?ind 1) ?str))\n (bind ?p1 (sub-string (+ ?ind 1) (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 , ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-open-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \"(\"))\n (str-index \"(\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \"(\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \"(\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule modify-input::identify-symbols-with-close-parens\n ?fct <- (object (is-a file-line)\n (contents $?before ?symbol&~\")\" $?after))\n (test (and (neq 0 (str-compare (str-cat ?symbol) \")\"))\n (str-index \")\" (str-cat ?symbol))))\n =>\n (bind ?str (if (stringp ?symbol) then ?symbol else (str-cat ?symbol)))\n (bind ?ind (str-index \")\" ?str))\n (bind ?p0 (sub-string 1 ?ind ?str))\n (bind ?p1 (sub-string ?ind (str-length ?str) ?str))\n (modify-instance ?fct (contents $?before ?p0 \")\" ?p1 $?after)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify-instance ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (object (is-a file-line)\n (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (object (is-a file-line)\n (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (unmake-instance ?f)\n (modify-instance ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (object (is-a file-line)\n (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) \n (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule convert-templates::assert-build-groups\n ?f <- (object (is-a file-line) \n (type ~UNKNOWN) \n (id ?id))\n =>\n (assert (message (to build-groups)\n (action add-to-span)\n (arguments ?id))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a file-line) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"8538d9f0f41ef1325c190230971980b2bb9b97b6","subject":"first throw","message":"first throw\n","repos":"tortinator\/asprilo","old_file":"xapf\/goal-ms.clp","new_file":"xapf\/goal-ms.clp","new_contents":"% NON-ANONYMOUS MAPF \n\ngoal(N,T) :- robot(N), shelf(N), position(shelf(N),(X,Y),0), &sum { positionX(robot(N),T) } = X, &sum { positionY(robot(N),T) } = Y.\n\n% :- goal(N,T-1), move(N,_,T).\n \n:- robot(N), shelf(N), not goal(N,horizon).\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'xapf\/goal-ms.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"1e3d30fa393612e8d1733de2f6200fabdba374e3","subject":"Added CommonConversionEntry.clp","message":"Added CommonConversionEntry.clp\n\nThis file contains the common definitions that different expert systems will\nuse for conversion of this type\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/CommonConversionEntry.clp","new_file":"src\/tools\/conv\/gl\/CommonConversionEntry.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; CommonConversionEntry.clp - Entry point into the generic backend for the\n; conversion expert systems\n; Written by Joshua Scoggins\n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule read-input \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule modify-input\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule grouping-update\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(batch* \"Types\/Loader.clp\")\n(batch* GLCommonConversionRules.clp)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/tools\/conv\/gl\/CommonConversionEntry.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"4645c08027ff62cbea2e9caec73b59769d3d21e1","subject":"Marked the slots in PassBase as being accessible by child classes.","message":"Marked the slots in PassBase as being accessible by child classes.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING))\n (slot pass-description (type STRING)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"dfeb1470cd8b04292cda9e740c2e0ab54c800c68","subject":"test manners","message":"test manners\n\ngit-svn-id: 9643e93313b82f5e4da82d8413267a0daa4b5472@1495 2cd91b7d-3b21-0410-a5f4-f42db4f24360\n","repos":"RWTH-i5-IDSG\/jamocha,RWTH-i5-IDSG\/jamocha","old_file":"benchmark\/manners\/mymanners.clp","new_file":"benchmark\/manners\/mymanners.clp","new_contents":";;; The Manners Benchmark implemented using CLIPS\n;;; The original source for the OPS5 benchmark suite is available\n;;; at http:\/\/www.cs.utexas.edu\/ftp\/pub\/ops5-benchmark-suite\/\n\n;;; Changes made for the CLIPS version\n;;;\n;;; Reformatted code\n;;; Changed the logical name to which the program output\n;;; is sent to a global variable so that the program\n;;; output can be easily enabled\/disabled.\n\n;;; ##########\n;;; Defglobals\n;;; ##########\n\n(bind ?*output* t) ; Disabled = nil Enabled = t\n\n;;; ############\n;;; Deftemplates\n;;; ############\n\n(deftemplate guest \n (slot name)\n (slot sex)\n (slot hobby))\n \n(deftemplate last_seat \n (slot seat))\n \n(deftemplate seating \n (slot seat1)\n (slot seat2)\n (slot name1) \n (slot name2)\n (slot id)\n (slot pid)\n (slot path_done))\n \n(deftemplate context\n (slot state))\n\n(deftemplate path \n (slot id)\n (slot name)\n (slot seat))\n \n(deftemplate chosen \n (slot id)\n (slot name)\n (slot hobby))\n \n(deftemplate count \n (slot c))\n\n;;; ########\n;;; Defrules\n;;; ########\n\n;;; *****************\n;;; assign_first_seat\n;;; *****************\n\n(defrule assign_first_seat\n ?f1 <- (context (state start))\n (guest (name ?n))\n ?f3 <- (count (c ?c))\n =>\n (assert (seating (seat1 1) (name1 ?n) (name2 ?n) (seat2 1) (id ?c) (pid 0) (path_done yes)))\n (assert (path (id ?c) (name ?n) (seat 1)))\n (modify ?f3 (c (+ ?c 1)))\n (printout ?*output* \"first seat 1 \" ?n \" \" ?n \" 1 \" ?c \" 0 1\" crlf)\n (modify ?f1 (state assign_seats)))\n\n;;; ************\n;;; find_seating\n;;; ************\n\n(defrule find_seating\n ?f1 <- (context (state assign_seats))\n (seating (seat1 ?seat1) (seat2 ?seat2) (name2 ?n2) (id ?id) (pid ?pid) (path_done yes))\n (guest (name ?n2) (sex ?s1) (hobby ?h1))\n (guest (name ?g2) (sex ~?s1) (hobby ?h1))\n ?f5 <- (count (c ?c))\n (not (path (id ?id) (name ?g2)))\n (not (chosen (id ?id) (name ?g2) (hobby ?h1)))\n =>\n (assert (seating (seat1 ?seat2) (name1 ?n2) (name2 ?g2) (seat2 (+ ?seat2 1)) (id ?c) (pid ?id) (path_done no)))\n (assert (path (id ?c) (name ?g2) (seat (+ ?seat2 1))))\n (assert (chosen (id ?id) (name ?g2) (hobby ?h1)))\n (modify ?f5 (c (+ ?c 1)))\n (printout ?*output* \"seat1: \" ?seat2 \" seat2: \" (+ ?seat2 1) \" Name1: \" ?n2 \" Name2: \" ?g2 crlf)\n (modify ?f1 (state make_path)))\n\n;;; *********\n;;; make_path\n;;; *********\n\n(defrule make_path\n (context (state make_path))\n (seating (id ?id) (pid ?pid) (path_done no))\n (path (id ?pid) (name ?n1) (seat ?s))\n (not (path (id ?id) (name ?n1)))\n =>\n (assert (path (id ?id) (name ?n1) (seat ?s))))\n\n;;; *********\n;;; path_done\n;;; *********\n\n(defrule path_done\n ?f1 <- (context (state make_path))\n ?f2 <- (seating (path_done no))\n =>\n (modify ?f2 (path_done yes))\n (modify ?f1 (state check_done)))\n\n;;; ***********\n;;; are_we_done\n;;; ***********\n\n(defrule are_we_done\n ?f1 <- (context (state check_done))\n (last_seat (seat ?l_seat))\n (seating (seat2 ?l_seat))\n =>\n (printout ?*output* crlf \"Yes, we are done!!\" crlf)\n (modify ?f1 (state print_results)))\n\n;;; ********\n;;; continue\n;;; ********\n\n(defrule continue\n ?f1 <- (context (state check_done))\n =>\n (modify ?f1 (state assign_seats))\n)\n\n;;; *************\n;;; print_results\n;;; *************\n\n(defrule print_results\n (context (state print_results))\n (seating (id ?id) (seat2 ?s2))\n (last_seat (seat ?s2))\n ?f4 <- (path (id ?id) (name ?n) (seat ?s))\n =>\n (retract ?f4)\n (printout ?*output* \"Seat: \" ?s \" Name: \" ?n crlf))\n\n;;; ********\n;;; all_done\n;;; ********\n\n(defrule all_done\n (context (state print_results))\n =>\n(printout t \"ALL DONE\")\n)\n\n \n \n \n \n \n \n \n(assert \n(guest (name n1) (sex m) (hobby h3))\n(guest (name n1) (sex m) (hobby h2))\n\n(guest (name n1) (sex m) (hobby h4))\n(guest (name n1) (sex m) (hobby h5))\n(guest (name n1) (sex m) (hobby h6))\n\n(guest (name n2) (sex m) (hobby h2))\n(guest (name n2) (sex m) (hobby h3))\n\n\n;(guest (name n3) (sex m) (hobby h1))\n;(guest (name n3) (sex m) (hobby h2))\n;(guest (name n3) (sex m) (hobby h3))\n\n(guest (name n4) (sex f) (hobby h3))\n(guest (name n4) (sex f) (hobby h2))\n\n(guest (name n4) (sex f) (hobby h5))\n(guest (name n4) (sex f) (hobby h6))\n\n(guest (name n5) (sex f) (hobby h1))\n(guest (name n5) (sex f) (hobby h2))\n(guest (name n5) (sex f) (hobby h3))\n\n;(guest (name n6) (sex f) (hobby h3))\n;(guest (name n6) (sex f) (hobby h1))\n;(guest (name n6) (sex f) (hobby h2))\n\n;(guest (name n7) (sex f) (hobby h3))\n;(guest (name n7) (sex f) (hobby h2))\n\n;(guest (name n8) (sex m) (hobby h3))\n;(guest (name n8) (sex m) (hobby h1))\n\n(last_seat (seat 4))\n(count (c 1))\n(context (state start)))\n ","old_contents":"","returncode":1,"stderr":"error: pathspec 'benchmark\/manners\/mymanners.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"be04da68eba1e49fb36ca6d12b5d7140992c9566","subject":"GLAPIConversion.clp: Added a new function builder type for CLIPS functions","message":"GLAPIConversion.clp: Added a new function builder type for CLIPS functions\n\nThis class takes in the different components of a target function so that it\ncan be built in a single run.\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n\t\t\t(modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of CLIPSFunctionBuilder \n\t\t\t\t\t\t\t\t(parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a CLIPSFunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a CLIPSFunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")\n\t\t\t\t\t\t\t\t (count ?index)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n; build-groups module\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg \n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(retract ?msg)\n\t\t\t(make-instance of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(deffunction build-groups::count-commas\n\t\t\t\t \"Iterates through a multifield and counts the number of commas\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?count 0)\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t(if (or (eq ?e \",\")\n\t\t\t\t\t\t\t\t\t (eq ?e ,)) then\n\t\t\t\t\t\t\t (bind ?count (+ 1 ?count))))\n\t\t\t\t (return ?count))\n;------------------------------------------------------------------------------\n(defrule build-groups::concatentate-length\n\t\t\t\"Adds a range to the target argument set\"\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action diverge-arguments)\n\t\t\t\t\t (arguments ?o 0 (count-commas $?contents) =>\n\t\t\t\t\t\t\t\t\t $?contents)))\n;------------------------------------------------------------------------------\n(defrule build-groups::diverge-arguments\n\t\t\t\"Splits the set of arguments into two separate facts\"\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?start ?finish => $?a \",\" $?b))\n\t\t\t(test (neq ?start ?finish))\n\t\t\t=>\n\t\t\t(bind ?cca (count-commas $?a))\n\t\t\t(bind ?starta ?start)\n\t\t\t(bind ?enda (+ ?starta ?cca))\n\t\t\t;from start to end\n\t\t\t(bind ?startb (+ 1 ?enda))\n\t\t\t;we use finish since it's the upper bound on this argument set\n\t\t\t(bind ?endb ?finish)\n (modify ?fct (arguments ?o ?starta ?enda => $?a))\n\t\t\t(duplicate ?fct (arguments ?o ?startb ?endb => $?b)))\n;------------------------------------------------------------------------------\n(defrule build-groups::generate-build-argument-statement\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action diverge-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o ?pos ?pos => $?conditions))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-argument)\n\t\t\t\t\t (arguments ?o ?pos => $?conditions)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-fixed-array\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?field \"[\" ?size \"]\"))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?field))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(array-size ?size)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n(defrule build-groups::argument-is-generic\n\t\t\t?fct <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action build-argument)\n\t\t\t\t\t\t\t\t (arguments ?o ?ind => $?input))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (to grouping-update)\n\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?input))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index ?ind)))\n;------------------------------------------------------------------------------\n; grouping-update module\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o =>))\n\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o =>))\n\t\t\t(object (is-a GLAPIArgument)\n\t\t\t\t\t (id ?o)\n\t\t\t\t\t (parent ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action make-function-builder)\n\t\t\t\t\t (arguments ?p)))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defrule grouping-update::make-function-builder\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action make-function-builder)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t=>\n\t\t\t(modify ?fct (action build-function)\n\t\t\t\t\t (arguments ?p -1))\n\t\t\t(make-instance of FunctionBuilder (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-header\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p -1))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p))\n\t\t\t(object (is-a GLAPIFunction) \n\t\t\t\t\t (id ?p)\n\t\t\t\t\t (return-type ?ret)\n\t\t\t\t\t (clips-function-name ?cfn))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p 0))\n\t\t\t(modify-instance ?obj (contents \n\t\t\t\t\t\t\t\t\t\t\t(format nil \"extern %s %s(void* theEnv) {\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t ?ret ?cfn))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::build-function-add-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t?arg <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (index ?index))\n\t\t\t?obj <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?p (+ ?index 1)))\n\t\t\t(modify-instance ?obj \n\t\t\t\t\t\t\t\t (contents $?contents \n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"\/\/code to handle %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (send ?arg reconstitute)))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::close-function\n\t\t\t(declare (salience -1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action build-function)\n\t\t\t\t\t\t\t\t (arguments ?p ?index))\n\t\t\t(not (exists (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t\t\t(index ?index))))\n\t\t\t?f <- (object (is-a FunctionBuilder) \n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?contents))\n\t\t\t=>\n\t\t\t(modify ?fct (action print-function)\n\t\t\t\t\t (arguments ?p))\n\t\t\t(modify-instance ?f (contents $?contents \"}\")))\n;------------------------------------------------------------------------------\n(defrule grouping-update::print-built-function\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action print-function)\n\t\t\t\t\t\t\t\t (arguments ?p))\n\t\t\t?f <- (object (is-a FunctionBuilder)\n\t\t\t\t\t\t\t (parent ?p)\n\t\t\t\t\t\t\t (contents $?c))\n\t\t\t=>\n\t\t\t(progn$ (?line ?c)\n\t\t\t\t\t (printout t ?line crlf))\n\t\t\t(printout t crlf crlf)\n\t\t\t(retract ?fct)\n\t\t\t(unmake-instance ?f))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ebb9c8aa0ae67f8e6500bc8062ce9f31fb554955","subject":"Added the pass header for the dependency-analysis pass","message":"Added the pass header for the dependency-analysis pass\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/dependency-analysis\/PassHeader.clp","new_file":"lib\/durandal\/passes\/dependency-analysis\/PassHeader.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule dependency-analysis\n (import core ?ALL)\n (import llvm ?ALL)\n (import indirect ?ALL)\n (import pipeline ?ALL)\n (import rampancy ?ALL)\n (import types ?ALL)\n (import MAIN ?ALL))\n\n(load* \"passes\/dependency-analysis\/Init.clp\")\n(load* \"passes\/dependency-analysis\/ProducersPropagation.clp\")\n(load* \"passes\/dependency-analysis\/BlockDependencyCreation.clp\")\n(load* \"passes\/dependency-analysis\/MemoryBarrierCreation.clp\")\n(load* \"passes\/dependency-analysis\/MergeRules.clp\")\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/passes\/dependency-analysis\/PassHeader.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0c325f77b9d26d81eea7e2ec375431fa908e02be","subject":"Create task2.clp","message":"Create task2.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter5\/task2.clp","new_file":"ssu-ai-level-2\/chapter5\/task2.clp","new_contents":"(defrule spisok-sotr\n =>\n (printout t \"Input the count of employees\")\n (bind ?n (read))\n (loop-for-count (?i 1 ?n) do\n (printout t \"Input the last name:\")\n (bind ?lastName (read))\n (printout t \"Input the doljnost:\")\n (bind ?doljn (read))\n (assert (sotr ?lastName ?doljn))\n )\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter5\/task2.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"557182f604be770d6ebdabe362200545a7e09a44","subject":"Added an initial graphics example","message":"Added an initial graphics example\n\nIt will exit on right clicking\n","repos":"DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/neutron","old_file":"logic\/graphics\/test.clp","new_file":"logic\/graphics\/test.clp","new_contents":"(defglobal MAIN\n ?*system-initialized* = FALSE)\n(deffacts query-operation\n (query mouse))\n(defmethod bool ((?number INTEGER)) (if (= ?number 0) then FALSE else TRUE))\n(defmethod translate\/mouse\/buttons\n ()\n ; Mouse combinations\n ; m.buttons & 1 => left-click\n ; m.buttons & 2 => middle-click \n ; m.buttons & 3 => left + middle\n ; m.buttons & 4 => right-click \n ; m.buttons & 5 => left + right\n ; m.buttons & 6 => middle + right \n ; m.buttons & 7 => left + middle + right\n (bind ?z (mouse\/buttons))\n (return (create$ \n (if (bool (binary-and ?z 1)) then button1 else (create$))\n (if (bool (binary-and ?z 2)) then button2 else (create$))\n (if (bool (binary-and ?z 4)) then button3 else (create$)))))\n\n(defrule initialize \n (declare (salience 10000))\n (initial-fact)\n =>\n (if (not ?*system-initialized*) then\n (initdraw)\n (mouse\/init)\n (eresized 0)\n (bind ?*system-initialized* TRUE)))\n\n(defrule on-resized\n ?f <- (event resized new ?value)\n =>\n (if (and ?value (< (getwindow) 0)) then\n (printout werror \"ERROR: couldn't reattach to window\" crlf)\n (exit)\n else\n (retract ?f)))\n(defrule query-mouse\n ?f <- (query mouse)\n =>\n (retract ?f)\n (mouse\/query)\n (assert (mouse input buttons: (translate\/mouse\/buttons) \n position: (mouse\/position)\n time-stamp: (mouse\/timestamp))))\n\n\n(defrule process-mouse-inputs\n ?f <- (mouse input\n buttons: $?z&:(not (member$ button3 ?z))\n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (assert (query mouse)))\n\n\n(defrule process-mouse-inputs:exit\n ?f <- (mouse input \n buttons: $? button3 $? \n position: ? ?\n time-stamp: ?)\n =>\n (retract ?f)\n (exit))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'logic\/graphics\/test.clp' did not match any file(s) known to git\n","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"d8eac2695e0d87c623eb9fbd6646c6aede2d0658","subject":"Fixed issues in Environment.clp","message":"Fixed issues in Environment.clp\n\n1) I replaced EXTERNAL_ADDRESS with EXTERNAL-ADDRESS because the latter is the\nproper symbol\n2) Replaced dynamic-default with default-dynamic because the latter is the\ncorrect command\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/core\/Environment.clp","new_file":"lib\/durandal\/modules\/core\/Environment.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL-ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (default-dynamic 0)))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Environment.clp - A wrapper over a CLIPS environment\n;------------------------------------------------------------------------------\n(defclass core::Environment \n \"A wrapper over a clips environment\"\n (is-a Object InteropObject)\n (slot pointer (type INTEGER EXTERNAL_ADDRESS) (source composite) (access initialize-only)\n (range 0 0) (dynamic-default 0))\n\n(defmessage-handler core::Environment init around ()\n (call-next-handler)\n (if (eq ?self:pointer 0) then\n (bind ?self:pointer (env-create))))\n\n(defmessage-handler core::Environment destroy primary ()\n (if (not (is-executing-environment ?self:pointer)) then\n (env-destroy ?self:pointer)\n (return (delete-instance))\n else\n (printout \n werror\n \"ERROR: attempted to destroy the executing environment.\"\n crlf)\n (return FALSE)))\n\n(defmessage-handler core::Environment is-executing-environment primary () \n (return (is-executing-environment ?self:pointer)))\n\n(defmessage-handler core::Environment run ($?count)\n (bind ?size (length$ $?count))\n (if (= 0 ?size) then \n (if (is-executing-environment ?self:pointer) then\n (run)\n else\n (env-run ?self:pointer))\n else\n (bind ?num (nth$ 1 ?count))\n (if (and (> ?num 0) (integerp ?num)) then\n (if (is-executing-environment ?self:pointer) then\n (run ?num)\n else\n (env-run ?self:pointer ?num))\n else\n (printout werror \"ERROR: invalid count provided.\" crlf))))\n\n(defmessage-handler core::Environment eval (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (eval ?string)\n else\n (env-eval ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment build (?string)\n (if (stringp ?string) then\n (if (is-executing-environment ?self:pointer) then\n (build ?string)\n else\n (env-build ?self:pointer ?string))\n else\n (printout werror \"ERROR: string expected\" crlf)))\n\n(defmessage-handler core::Environment facts ()\n (if (is-executing-environment ?self:pointer) then\n (facts)\n else\n (env-facts ?self:pointer)))\n(defmessage-handler core::Environment instances () \n (if (is-executing-environment ?self:pointer) then\n (instances)\n else\n (env-instances ?self:pointer)))\n\n(defmessage-handler core::Environment rules ()\n (if (is-executing-environment ?self:pointer) then\n (rules)\n else\n (env-rules ?self:pointer)))\n\n(defmessage-handler core::Environment assert ($?elements)\n (bind ?length (length$ ?elements))\n (if (= 0 ?length) then\n (printout werror \"ERROR: No arguments provided\" crlf)\n else\n (env-assert-string ?self:pointer \n\t\t\t\t\t\t\t (implode$ $?elements))))\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"f1c45bf02847d1af94a53f0584f56b3d5e968a58","subject":"problem?","message":"problem?\n","repos":"jmigual\/IA2016,jmigual\/IA2016","old_file":"Coneixement\/CouchPotato.clp","new_file":"Coneixement\/CouchPotato.clp","new_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer)))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_actividades))\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n)\n\n(defrule pide-problemas\n\t(nombre ?nombre)\n (test (any-instancep ((?dieta Dieta)) TRUE))\n\t=>\n\t(printout t \"Problemas musculo-esqueleticos: \" crlf crlf)\n\t(bind ?lista_problemas_musc (find-all-instances ((?p Problema+musculo-esqueletico)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_problemas_musc)) do\n\t\t(bind ?aux (nth$ ?i ?lista_problemas_musc))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_problemas_musc))\n\t\t(bind ?respuesta (pregunta-numerica \"Que problema de estos tienes? \" 0 (length$ ?lista_problemas_musc)))\n\t)\n)\n\n","old_contents":"; Thu May 05 11:59:51 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n\n(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS \"Fake class to save top-level slot information\"\n\t(is-a USER)\n\t(role abstract)\n\t(single-slot grado\n;+\t\t(comment \"1 - 2\")\n\t\t(type INTEGER)\n\t\t(range 1 2)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(multislot problemas\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(cardinality 1 ?VARIABLE)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tipo\n\t\t(type INTEGER)\n\t\t(range 1 4)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot value\n;+\t\t(type ANY)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot imc\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot actividades\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Actividad)\n\t\t(create-accessor read-write))\n\t(single-slot altura\n\t\t(type FLOAT)\n\t\t(default 1.7)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot peso\n\t\t(type FLOAT)\n\t\t(default 75.0)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(multislot tests\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Test)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n\t\t(default \"Paco\")\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad\n\t\t(type INTEGER)\n\t\t(default 25)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot pMax\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+fisicos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot pMin\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot dieta\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Dieta)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Test\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot ppm\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot cansancio\n\t\t(type SYMBOL)\n\t\t(allowed-values Mucho Poco Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot tirantezMuscular\n\t\t(type SYMBOL)\n\t\t(allowed-values Poco Mucho Nada)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n\t\t(default 0)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot frequencia\n\t\t(type SYMBOL)\n\t\t(allowed-values Diaria Semanal Mensual None)\n\t\t(default None)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Actividad+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Actividad+fuera+de+Trabajo\n\t(is-a Actividad)\n\t(role concrete))\n\n(defclass Estatica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Tarea+domestica\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Desplazamiento\n\t(is-a Actividad+fuera+de+Trabajo)\n\t(role concrete))\n\n(defclass Salud\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Dieta\n\t(is-a Salud)\n\t(role concrete)\n\t(single-slot picar+entre+horas\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot consumo+de+fruta\n;+\t\t(comment \"Piezas a la semana\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot abuso+de+sal\n;+\t\t(comment \"de 0 (nada) a 10 (mucho)\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Problema\n\t(is-a Salud)\n\t(role concrete))\n\n(defclass Problema+musculo-esqueletico\n\t(is-a Problema)\n\t(role concrete)\n\t(multislot zona\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write)))\n\n(defclass Otros+problemas\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Problema+IMC\n\t(is-a Problema)\n\t(role concrete))\n\n(defclass Objetivo\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Musculacion\n\t(is-a Objetivo)\n\t(role concrete)\n\t(single-slot grupo_muscular\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Programa\n\t(is-a USER)\n\t(role concrete)\n\t(multislot jueves\n;+\t\t(comment \"ejercicios jueves\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot tiempo+diario+disponible\n;+\t\t(comment \"tiempo diario en minutos\")\n\t\t(type INTEGER)\n\t\t(range 30 1440)\n\t\t(cardinality 7 7)\n\t\t(create-accessor read-write))\n\t(multislot lunes\n;+\t\t(comment \"ejercicios lunes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot martes\n;+\t\t(comment \"ejercicios martes\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot sabado\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot viernes\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot miercoles\n;+\t\t(comment \"ejercicios miercoles\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(multislot domingo\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot duracion+maxima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot duracion+minima\n;+\t\t(comment \"en minutos\")\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+minimas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot grupos+musculares\n;+\t\t(comment \"grupos musculares ejercitados\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Grupo+muscular)\n\t\t(create-accessor read-write))\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot edad+maxima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot ejercicios+combinan\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n\t\t(create-accessor read-write))\n\t(single-slot edad+minima\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot objetivos\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Objetivo)\n\t\t(create-accessor read-write))\n\t(multislot problemas+contraindicados\n;+\t\t(comment \"problemas del usuario contraindicados para este ejercicio\")\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot repeticiones+maximas\n\t\t(type INTEGER)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write))\n\t(multislot problemas+aliviados\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Problema)\n\t\t(create-accessor read-write))\n\t(single-slot calorias+quemadas\n;+\t\t(comment \"calorias quemadas por minuto\")\n\t\t(type FLOAT)\n;+\t\t(cardinality 0 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio+con+aparatos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+de+suelo\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Ejercicio+con+pesas\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Estiramientos\n\t(is-a Ejercicio)\n\t(role concrete))\n\n(defclass Grupo+muscular\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot nombre\n\t\t(type STRING)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n\n(defclass Ejercicio-Persona\n\t(is-a USER)\n\t(role concrete)\n\t(single-slot repeticiones\n\t\t(type INTEGER)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot salud\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Salud)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot ejercicio\n\t\t(type INSTANCE)\n;+\t\t(allowed-classes Ejercicio)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write))\n\t(single-slot dificultad\n\t\t(type SYMBOL)\n\t\t(allowed-values moderada normal dificil)\n;+\t\t(cardinality 1 1)\n\t\t(create-accessor read-write)))\n \n(definstances instances\n; Thu May 05 11:59:52 CEST 2016\n; \n;+ (version \"3.5\")\n;+ (build \"Build 663\")\n\n([Articular] of Problema+musculo-esqueletico\n\n\t(nombre \"Articular\"))\n\n([Barrer] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Barrer\"))\n\n([Bicicleta+estatica] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.4)\n\t(duracion+maxima 90)\n\t(duracion+minima 20)\n\t(edad+maxima 60)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Bicicleta estatica\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Brazos] of Problema+musculo-esqueletico\n\n\t(nombre \"Brazos\")\n\t(zona\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Dorsal]\n\t\t[Tr%C3%ADceps]))\n\n([B%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Biceps\"))\n\n([Carrera+sostenida] of Test\n\n\t(nombre \"Carrera sostenida\"))\n\n([Cinta+de+correr] of Ejercicio+con+aparatos\n\n\t(duracion+minima 20)\n\t(edad+minima 12)\n\t(ejercicios+combinan\n\t\t[Bicicleta+estatica]\n\t\t[Stepper])\n\t(grupos+musculares\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Cinta de correr\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas]))\n\n([Colada] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Colada\"))\n\n([Compra] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Compra\"))\n\n([CouchPotato_Class0] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 4.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [Pesos])\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Trapecio]\n\t\t[Tr%C3%ADceps])\n\t(nombre \"Pesos brazos\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular])\n\t(repeticiones+minimas 10))\n\n([CouchPotato_Class2] of Problema+IMC\n\n\t(nombre \"Peso insuficiente\"))\n\n([CouchPotato_Class3] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 1\"))\n\n([CouchPotato_Class4] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 2\"))\n\n([CouchPotato_Class5] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 3\"))\n\n([CouchPotato_Class6] of Problema+IMC\n\n\t(nombre \"Obesidad tipo 4\"))\n\n([CouchPotato_Class7] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 1\"))\n\n([CouchPotato_Class8] of Problema+IMC\n\n\t(nombre \"Sobrepeso grado 2\"))\n\n([CouchPotato_Class9] of Ejercicio+de+suelo\n)\n\n([Cuadriceps] of Grupo+muscular\n\n\t(nombre \"Cuadriceps\"))\n\n([Cuello] of Problema+musculo-esqueletico\n\n\t(nombre \"Cuello\")\n\t(zona [Trapecio]))\n\n([Cuidar+del+jard%C3%ADn] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Cuidar del jardin\"))\n\n([De+pie] of Actividad+de+Trabajo\n\n\t(nombre \"De pie\"))\n\n([Deltoides] of Grupo+muscular\n\n\t(nombre \"Deltoides\"))\n\n([Desplazamiento+a+pie] of Actividad+de+Trabajo\n\n\t(nombre \"Desplazamientos a pie\"))\n\n([Dorsal] of Grupo+muscular\n\n\t(nombre \"Dorsal\"))\n\n([Equilibrio] of Objetivo\n\n\t(nombre \"Equilibrio\"))\n\n([Esfuerzos+musculares] of Actividad+de+Trabajo\n\n\t(nombre \"Esfuerzos musculares\"))\n\n([Espalda] of Problema+musculo-esqueletico\n\n\t(nombre \"Espalda\")\n\t(zona\n\t\t[Dorsal]\n\t\t[Trapecio]))\n\n([Flexibilidad] of Objetivo\n\n\t(nombre \"Flexibilidad\"))\n\n([Fregar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Fregar\"))\n\n([Gemelos] of Grupo+muscular\n\n\t(nombre \"Gemelos\"))\n\n([Gluteos] of Grupo+muscular\n\n\t(nombre \"Gluteos\"))\n\n([Lectura] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Lectura\"))\n\n([Levantamiento+de+peso] of Actividad+de+Trabajo\n\n\t(nombre \"Levantamiento de peso\"))\n\n([Mantenimiento] of Objetivo\n\n\t(nombre \"Mantenimiento\"))\n\n([Movimientos+Repetitivos] of Actividad+de+Trabajo\n\n\t(nombre \"Movimientos repetitivos\"))\n\n([Paseo] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo\"))\n\n([Paseo+mascota] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Paseo mascota\"))\n\n([Pesos] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 5.0)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+minima 12)\n\t(ejercicios+combinan [CouchPotato_Class0])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Pesos piernas\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Presion+alta]\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 10))\n\n([Planchar] of Tarea+domestica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Planchar\"))\n\n([Ponerse+en+forma] of Objetivo\n\n\t(nombre \"Ponerse en forma\"))\n\n([Presion+alta] of Otros+problemas\n\n\t(nombre \"Presion alta\"))\n\n([Rebajar+Peso] of Objetivo\n\n\t(nombre \"Rebajar peso\"))\n\n([Remo] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 10.0)\n\t(grupos+musculares\n\t\t[B%C3%ADceps]\n\t\t[Cuadriceps]\n\t\t[Dorsal]\n\t\t[Gemelos]\n\t\t[Tr%C3%ADceps]\n\t\t[Deltoides]\n\t\t[Gluteos])\n\t(nombre \"Remo\")\n\t(problemas+aliviados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+minimas 20))\n\n([Rodillas] of Problema+musculo-esqueletico\n\n\t(nombre \"Rodillas\")\n\t(zona [Gemelos]))\n\n([Salir+a+correr] of Desplazamiento\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Salir a correr\"))\n\n([Sentado] of Actividad+de+Trabajo\n\n\t(nombre \"Sentado\"))\n\n([Sistema+Card%C3%ADaco] of Objetivo\n\n\t(nombre \"Sistema cardiaco\"))\n\n([Stepper] of Ejercicio+con+aparatos\n\n\t(calorias+quemadas 6.1)\n\t(duracion+maxima 30)\n\t(duracion+minima 10)\n\t(edad+maxima 55)\n\t(ejercicios+combinan\n\t\t[Cinta+de+correr]\n\t\t[Bicicleta+estatica])\n\t(grupos+musculares\n\t\t[Cuadriceps]\n\t\t[Gemelos]\n\t\t[Gluteos])\n\t(nombre \"Stepper\")\n\t(problemas+aliviados\n\t\t[CouchPotato_Class3]\n\t\t[CouchPotato_Class4]\n\t\t[CouchPotato_Class5]\n\t\t[CouchPotato_Class6]\n\t\t[CouchPotato_Class7]\n\t\t[CouchPotato_Class8])\n\t(problemas+contraindicados\n\t\t[Articular]\n\t\t[Rodillas])\n\t(repeticiones+maximas 200)\n\t(repeticiones+minimas 10))\n\n([Subir+tramos+de+escalera] of Test\n\n\t(nombre \"Subir tramos escalera\"))\n\n([Television] of Estatica\n\n\t(duracion 0)\n\t(frequencia None)\n\t(nombre \"Television\"))\n\n([Trapecio] of Grupo+muscular\n\n\t(nombre \"Trapecio\"))\n\n([Tr%C3%ADceps] of Grupo+muscular\n\n\t(nombre \"Triceps\"))\n\n)\n\n([Troll] of Persona\n\t(nombre \"Inigo\")\n\t(altura 1.9)\n\t(peso 75)\n\t(imc 20))\n\n\n\n)\n;;****************\n;;* DEFFUNCTIONS *\n;;****************\n\n(deffunction ask-question (?question $?allowed-values)\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer)))\n (while (not (member ?answer ?allowed-values)) do\n (printout t ?question)\n (bind ?answer (read))\n (if (lexemep ?answer) \n then (bind ?answer (lowcase ?answer))))\n ?answer)\n\n(deffunction si-o-no-p (?question)\n (bind ?response (ask-question ?question si no s n))\n (if (or (eq ?response si) (eq ?response s))\n then TRUE \n else FALSE))\n \n(deffunction pregunta-general (?pregunta) \n\t(format t \"%s\" ?pregunta) \n\t(bind ?respuesta (read)) \n\t?respuesta\n)\n\n(deffunction pregunta-numerica (?pregunta ?rangini ?rangfi) \n\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t(bind ?respuesta (read)) \n\t(while (not(and(>= ?respuesta ?rangini)(<= ?respuesta ?rangfi))) do \n\t\t(format t \"%s [%d,%d] \" ?pregunta ?rangini ?rangfi) \n\t\t(bind ?respuesta (read)) \n\t) \n\t?respuesta\n)\n\n;;****************\n;;* REGLAS *\n;;**************** \n\n(defmodule MAIN (export ?ALL))\n\n(defrule presentacion \n (declare (salience 10))\n =>\n (printout t \"----------------------------\" crlf)\n (printout t \"--Sistema de recomendacion--\" crlf)\n (printout t \"-----de entrenamientos------\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t \"----I'm no couch potato-----\" crlf)\n (printout t \"----------------------------\" crlf)\n (printout t crlf)\n (focus preguntas-persona)\n\n)\n \n \n(defmodule preguntas-persona \"Modulo de preguntas sobnre la persona\"\n (import MAIN ?ALL)\n (export ?ALL))\n \n(defrule pregunta-nombre\n =>\n (bind ?nombre (pregunta-general \"Nombre: \"))\n (assert (nombre ?nombre))\n)\n\n(deffunction anadir-ProblemaIMC (?persona ?problema)\n\t(bind ?instancia (find-instance ((?p Problema+IMC)) (eq (str-compare ?p:nombre ?problema) 0)))\n\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n)\n\n(defrule crea-persona\n (nombre ?nombre)\n (test (not (any-instancep ((?persona Persona)) (eq (str-compare ?persona:nombre ?nombre) 0))))\n =>\n (bind ?persona (make-instance persona of Persona))\n\t(send ?persona put-nombre ?nombre)\n (bind ?altura (pregunta-numerica \"Altura (m): \" 0.0 3.0))\n (send ?persona put-altura ?altura)\n (bind ?peso (pregunta-numerica \"Peso (kg): \" 0.0 600.0))\n (send ?persona put-peso ?peso)\n\t(bind ?imc (\/ ?peso (* ?altura ?altura)))\n (send ?persona put-imc ?imc)\n\t(if (< ?imc 18.5) then (anadir-ProblemaIMC ?persona \"Peso insuficiente\") else\n\t\t(if (> ?imc 50) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 4\") else\n\t\t\t(if (> ?imc 40) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 3\") else\n\t\t\t\t(if (> ?imc 35) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 2\") else \n\t\t\t\t\t(if (> ?imc 30) then (anadir-ProblemaIMC ?persona \"Obesidad tipo 1\") else\n\t\t\t\t\t\t(if (> ?imc 27) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 2\") else \n\t\t\t\t\t\t\t(if (> ?imc 25) then (anadir-ProblemaIMC ?persona \"Sobrepeso grado 1\"))\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t)\n (bind ?pMin (pregunta-numerica \"Cual es tu presion sanguinea minima (diastolica)? \" 0.0 200.0))\n\t(bind ?pMax (pregunta-numerica \"Cual es tu presion sanguinea maxima (sistolica)? \" 0.0 200.0))\n (send ?persona put-pMin ?pMin)\n (send ?persona put-pMax ?pMax)\n\t(if (or (>= ?pMin 90) (>= ?pMax 140)) then \n\t\t(bind ?instancia (find-instance ((?p Otros+problemas)) (eq (str-compare ?p:nombre \"Presion alta\") 0)))\n\t\t(slot-insert$ ?persona problemas+fisicos 1 ?instancia)\n\t)\n)\n\n(defrule pide-actividades\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?lista_actividades (find-all-instances ((?a Actividad)) TRUE))\n\t(printout t \"0 : Deja de aadir\" crlf)\n\t(loop-for-count (?i 1 (length$ ?lista_actividades)) do\n\t\t(bind ?aux (nth$ ?i ?lista_actividades))\n\t\t(printout t ?i \" : \" (send ?aux get-nombre) crlf)\n\t)\n\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t(while (> ?respuesta 0) do \n\t\t(slot-insert$ ?persona problemas+fisicos 1 (nth$ ?respuesta ?lista_actividades))\n\t\t(bind ?respuesta (pregunta-numerica \"Que actividad quieres anadir? \" 0 (length$ ?lista_actividades)))\n\t)\n)\n)\n\n\n\n(defrule crea-dieta\n\t(nombre ?nombre)\n\t?persona <-(object (is-a Persona)(nombre ?nombreA))\n\t(test (eq (str-compare ?nombre ?nombreA) 0))\n\t=>\n\t(bind ?dieta (make-instance dieta of Dieta))\n\t(send ?dieta put-nombre \"Much WOW\")\n (bind ?sal (pregunta-numerica \"Consumo de sal: \" 0.0 10.0))\n (send ?dieta put-abuso+de+sal ?sal)\n\t(bind ?picar (pregunta-numerica \"Picoteo entre horas: \" 0.0 10.0))\n (send ?dieta put-picar+entre+horas ?picar)\n (bind ?fruta (pregunta-numerica \"Cuantas piezas de fruta tomas a la semana? \" 0.0 500.0))\n (send ?dieta put-consumo+de+fruta ?fruta)\n)\n\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"6056f6b428925a8504fbeacbb70a18980a9a30cb","subject":"Fix typo in encoding-r.clp","message":"Fix typo in encoding-r.clp\n","repos":"tortinator\/asprilo","old_file":"mppd\/encoding-r.clp","new_file":"mppd\/encoding-r.clp","new_contents":"% = MPPD DOMAIN: CLINGCON ENCODING =================================================================\n\n% Move actions\n#include \".\/action-MPP.clp\".\n\n% Order fulfillment (Goal condition)\n#include \".\/goal-D-r.clp\".\n\n% Highway constraints\n#include \"..\/control\/highways.clp\".\n\n% Output conversion\n#include \".\/output-MPPD.lp\".\n","old_contents":"% = MPPD DOMAIN: CLINGCON ENCODING =================================================================\n\n% Move actions\n#include \".\/action-MPP.clp\".\n\n% Order fulfillment (Goal condition)\n#include \".\/goal-D-r.clp\n\n% Highway constraints\n#include \"..\/control\/highways.clp\".\n\n% Output conversion\n#include \".\/output-MPPD.lp\".\n","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"1f992a1c5e82c46955eeb7b5b90df8b8dcf2c50c","subject":"Added a new file (Functions.clp)","message":"Added a new file (Functions.clp)\n\nIt contains a single function symbol-to-pointer-list, which is responsible for\nconverting a list of object names into the native-pointer addresses that\nrepresent the given object outside of the CLIPS environment.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n\n(deffunction types::symbol-to-pointer-list\n\t\t\t\t \"Converts a given list of symbols that represent InteropObjects and pulls the\n\t\t\t\t pointer value out of it. This function assumes order is important\"\n\t\t\t\t (?list)\n\t\t\t\t (bind ?result (create$))\n\t\t\t\t (progn$ (?e ?list)\n\t\t\t\t\t\t\t (bind ?obj (symbol-to-instance-name ?e))\n\t\t\t\t\t\t\t (bind ?result (create$ ?result (send ?obj get-Pointer))))\n\t\t\t\t (return ?result))\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'lib\/durandal\/passes\/wavefront-scheduling\/common\/Functions.clp' did not match any file(s) known to git\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"ca7519e47a6fd92577e48f9bca83aefd789c97e1","subject":"Modified the ConstantFloatingPoint class in CLIPS to allow Value to be a symbol","message":"Modified the ConstantFloatingPoint class in CLIPS to allow Value to be a symbol\n\nThis is so that I can set the field to unknown if necessary.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/llvm\/LLVMConstant.clp","new_file":"lib\/durandal\/modules\/llvm\/LLVMConstant.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMConstant.clp - Contains classes that represent the different LLVM\n; constant types\n;------------------------------------------------------------------------------\n(defclass llvm::Constant \n (is-a LLVMUser)\n (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))\n (slot RelocationInfo (type SYMBOL) (default nil) \n\t\t (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))\n;------------------------------------------------------------------------------\n(defclass llvm::BlockAddress \n (is-a Constant)\n (slot TargetBlock (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantAggregateZero \n (is-a Constant)\n (slot Element (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantArray \n (is-a Constant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataSequential \n (is-a Constant)\n (multislot Elements)\n (slot ElementType (type SYMBOL))\n (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))\n (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))\n (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataArray \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataVector \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantExpression \n (is-a Constant)\n (slot Operation)\n (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot Opcode (type NUMBER) (range 0 ?VARIABLE))\n (slot Predicate (type NUMBER) (range 0 ?VARIABLE))\n (multislot Indices)\n (slot OpcodeName (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::BinaryConstantExpression \n (is-a ConstantExpression))\n;------------------------------------------------------------------------------\n(defclass llvm::CompareConstantExpression \n (is-a ConstantExpression)\n (slot Predicate (type NUMBER)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantFloatingPoint \n (is-a Constant)\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Value (type FLOAT SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantInteger \n (is-a Constant)\n (slot ZeroExtendedValue (type NUMBER))\n (slot SignExtendedValue (type NUMBER))\n (slot Width (type NUMBER) (range 0 ?VARIABLE))\n (slot Value (type SYMBOL NUMBER))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::PointerConstant \n (is-a Constant)\n (slot PointerType (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantPointerNull \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantStruct \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantVector \n (is-a PointerConstant)\n (slot SplatValue (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalValue \n (is-a Constant)\n (slot Alignment (type NUMBER))\n (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Section (type SYMBOL))\n (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAvailableExternallyLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))\n (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Initializer))\n\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalVariable \n (is-a GlobalValue)\n (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalAlias \n (is-a GlobalValue)\n (slot Aliasee))\n\n;------------------------------------------------------------------------------\n(defclass llvm::UndefValue \n (is-a Constant))\n\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; LLVMConstant.clp - Contains classes that represent the different LLVM\n; constant types\n;------------------------------------------------------------------------------\n(defclass llvm::Constant \n (is-a LLVMUser)\n (slot IsNullValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsAllOnesValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegativeZeroValue (type SYMBOL) (allowed-values FALSE TRUE))\n (slot CanTrap (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstantUsed (type SYMBOL) (allowed-values FALSE TRUE))\n (slot RelocationInfo (type SYMBOL) (default nil) \n\t\t (allowed-symbols nil NoRelocations LocalRelocation GlobalRelocations)))\n;------------------------------------------------------------------------------\n(defclass llvm::BlockAddress \n (is-a Constant)\n (slot TargetBlock (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantAggregateZero \n (is-a Constant)\n (slot Element (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantArray \n (is-a Constant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataSequential \n (is-a Constant)\n (multislot Elements)\n (slot ElementType (type SYMBOL))\n (slot ElementCount (type NUMBER) (range 0 ?VARIABLE))\n (slot ElementByteSize (type NUMBER) (range 0 ?VARIABLE))\n (slot IsString (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCString (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataArray \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantDataVector \n (is-a ConstantDataSequential))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantExpression \n (is-a Constant)\n (slot Operation)\n (slot IsCast (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsCompare (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasIndices (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsGEPWithNoNotionalOverIndexing (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot Opcode (type NUMBER) (range 0 ?VARIABLE))\n (slot Predicate (type NUMBER) (range 0 ?VARIABLE))\n (multislot Indices)\n (slot OpcodeName (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::BinaryConstantExpression \n (is-a ConstantExpression))\n;------------------------------------------------------------------------------\n(defclass llvm::CompareConstantExpression \n (is-a ConstantExpression)\n (slot Predicate (type NUMBER)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantFloatingPoint \n (is-a Constant)\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsNaN (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Value (type FLOAT)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantInteger \n (is-a Constant)\n (slot ZeroExtendedValue (type NUMBER))\n (slot SignExtendedValue (type NUMBER))\n (slot Width (type NUMBER) (range 0 ?VARIABLE))\n (slot Value (type SYMBOL NUMBER))\n (slot IsNegative (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsZero (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsOne (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMinusOne (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::PointerConstant \n (is-a Constant)\n (slot PointerType (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantPointerNull \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantStruct \n (is-a PointerConstant))\n;------------------------------------------------------------------------------\n(defclass llvm::ConstantVector \n (is-a PointerConstant)\n (slot SplatValue (type SYMBOL)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalValue \n (is-a Constant)\n (slot Alignment (type NUMBER))\n (slot HasUnnamedAddress (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefaultVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasHiddenVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasProtectedVisibility (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasSection (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Section (type SYMBOL))\n (slot UseEmptyExceptConstants (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAvailableExternallyLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLinkOnceLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasAppendingLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasInternalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasLinkerPrivateWeakDefAutoLinkage (type SYMBOL) \n\t\t (allowed-values FALSE TRUE))\n (slot HasLocalLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLImportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDLLExportLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasExternalWeakLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasCommonLinkage (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsWeakForLinker (type SYMBOL) (allowed-values FALSE TRUE))\n (slot MayBeOverridden (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDeclaration (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsMaterializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsDematerializable (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUnnamedAddr (type SYMBOL) (allowed-values FALSE TRUE))\n (slot Initializer))\n\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalVariable \n (is-a GlobalValue)\n (slot HasInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasDefinitiveInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot HasUniqueInitializer (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsConstant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot IsThreadLocal (type SYMBOL) (allowed-values FALSE TRUE)))\n;------------------------------------------------------------------------------\n(defclass llvm::GlobalAlias \n (is-a GlobalValue)\n (slot Aliasee))\n\n;------------------------------------------------------------------------------\n(defclass llvm::UndefValue \n (is-a Constant))\n\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"35f4a3ca57bd6f4271797f25317825b0bd6a2d43","subject":"update beerex.clp","message":"update beerex.clp\n","repos":"DonatoMeoli\/BeerEX","old_file":"clips\/beerex.clp","new_file":"clips\/beerex.clp","new_contents":"\n;;;==========================================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink with a meal.\n;;;\n;;; For use with BeerEX.bot.py\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===========================================================\n\n\n;;*****************************\n;;* DEFGLOBALS & DEFTEMPLATES *\n;;*****************************\n\n(defglobal\n ?*very-high-priority* = 10000\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000\n ?*very-low-priority* = -10000)\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (default 100.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;****************************\n;;* DEFFACTS & INITIAL STATE *\n;;****************************\n\n(deffacts startup\n (state-list))\n\n(defrule print-welcome-message\n =>\n (load-facts .\/clips\/beer-styles.clp)\n (load .\/clips\/beer-questions.clp)\n (load .\/clips\/beer-knowledge.clp)\n (load .\/clips\/beer-selection.clp)\n (load .\/clips\/gui-interaction.clp)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))","old_contents":"\n;;;==========================================================\n;;; BeerEX: the Beer EXpert system\n;;;\n;;; This expert system suggests a beer to drink with a meal.\n;;;\n;;; For use with BeerEX.bot.py\n;;;\n;;; CLIPS 6.30\n;;;\n;;; Author: Donato Meoli\n;;;===========================================================\n\n\n;;; ****************************\n;;; * DEFGLOBALS & DEFTEMPLATES *\n;;; ****************************\n\n(defglobal\n ?*very-high-priority* = 10000\n ?*high-priority* = 1000\n ?*medium-high-priority* = 100\n ?*medium-low-priority* = -100\n ?*low-priority* = -1000\n ?*very-low-priority* = -10000)\n\n(deftemplate UI-state\n (slot id\n (default-dynamic (gensym*)))\n (slot display)\n (slot relation-asserted\n (default none))\n (multislot valid-answers)\n (slot response\n (default none))\n (slot state\n (default middle)))\n\n(deftemplate state-list\n (slot current)\n (multislot sequence))\n\n(deftemplate attribute\n (slot name)\n (slot value)\n (slot certainty\n (default 100.0)))\n\n(deftemplate beer\n (slot style\n (type STRING)\n (allowed-strings \"Pale Ale\" \"Dark Lager\" \"Brown Ale\" \"India Pale Ale\" \"Wheat Beer\" \"Strong Ale\"\n \"Belgian Style\" \"Hybrid Beer\" \"Porter\" \"Stout\" \"Bock\" \"Scottish-Style Ale\"\n \"Wild\/Sour\" \"Pilsener & Pale Lager\" \"Specialty Beer\"))\n (slot name\n (type STRING))\n (multislot alcohol\n (type SYMBOL)\n (allowed-symbols not-detectable mild noticeable harsh))\n (multislot color\n (type SYMBOL)\n (allowed-symbols pale amber brown dark))\n (multislot flavor\n (type SYMBOL)\n (allowed-symbols crisp-clean malty-sweet dark-roasty hoppy-bitter fruity-spicy sour-tart-funky))\n (multislot fermentation\n (type SYMBOL)\n (allowed-symbols top bottom wild))\n (multislot carbonation\n (type SYMBOL)\n (allowed-symbols low medium high))\n (slot link\n (type STRING)))\n\n;;****************************\n;;* DEFFACTS & INITIAL STATE *\n;;****************************\n\n(deffacts startup\n (state-list))\n\n(defrule print-welcome-message\n =>\n (load-facts .\/clips\/beer-styles.clp)\n (load .\/clips\/beer-questions.clp)\n (load .\/clips\/beer-knowledge.clp)\n (load .\/clips\/beer-selection.clp)\n (load .\/clips\/gui-interaction.clp)\n (assert (UI-state (display (format nil \"%n%s %n%n%s %n%n%s\" \"Welcome to the Beer EXpert system \ud83c\udf7b\ufe0f\"\n (str-cat \"\u2049\ufe0f All I need is that you answer simple questions by choosing \"\n \"one of the responses that are offered to you.\")\n \"To start, please press the \/new button \ud83d\ude04\"))\n (relation-asserted start)\n (state initial))))","returncode":0,"stderr":"","license":"mit","lang":"CLIPS"} {"commit":"041eed5ec6a472b11d3e4d9ea26f71e3d29cda5e","subject":"Added a comment pertaining to a strange bug with [ ] in a doc string","message":"Added a comment pertaining to a strange bug with [ ] in a doc string\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_file":"src\/tools\/conv\/gl\/GLAPIConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n; Can't escape with double quotes with ] and [...strange\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%d]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t?self:array-size)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(retract ?msg)\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-fixed-size-array-argument\n\t\t\t(declare (salience 2))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \"[\" ?size \"]\" ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))\n\t\t\t\t\t\t\t\t(array-size ?size)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments-generic\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversion.clp - an expert system that reads a define and generates\n; corresponding CLIPS functions that convert the CLIPS values into\n; corresponding opengl types. This gets a little goofy when dealing with\n; multifields but the idea is sound. \n;------------------------------------------------------------------------------\n; We need to add functionality to diverge asterisks from a symbol\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"*\" \n\t\t\t\t\t\t\t\t identify-symbols-with-asterisks \n\t\t\t\t\t\t\t\t \"Splits asterisks (*) out of symbols if necessary\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"[\"\n\t\t\t\t\t\t\t\t identify-symbols-with-open-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on [\")\n;------------------------------------------------------------------------------\n(target-symbol-is-special \"]\"\n\t\t\t\t\t\t\t\t identify-symbols-with-close-square-bracket\n\t\t\t\t\t\t\t\t \"Splits an input string on ]\")\n;------------------------------------------------------------------------------\n; Unlike GLConstantConversion, I don't need to use the heading span objects.\n; This is because each file-line has already been correctly merged.\n;------------------------------------------------------------------------------\n(defrule build-groups::delete-heading-span\n\t\t\t\"We don't need heading spans in this expert system. So delete them\"\n\t\t\t?obj <- (object (is-a heading-span))\n\t\t\t=>\n\t\t\t(unmake-instance ?obj))\n;------------------------------------------------------------------------------\n; We need to define a transformation function\/rule f which is responsible for\n; taking in a knowledge representation of the original code from the input\n; language and translates it to a knowledge representation of the code in the\n; output language. In this case it is C => C with the added \"benefit\" of\n; needing to add CLIPS api calls to interact with the overall environment. \n;\n; This isn't really that hard as what we need to do is just parse the arguments\n; and generate the corresponding C code. \n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name)\n (multislot arguments)\n (message-handler add-argument))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFunction add-argument \n\t\t\t\t\t\t \"Adds the arg name and returns the index\"\n\t\t\t\t\t\t (?name)\n\t\t\t\t\t\t (bind ?index (length$ ?self:arguments))\n\t\t\t\t\t\t (if (= 0 ?index) then\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments 1 ?name)\n\t\t\t\t\t\t\t (return 1)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (slot-direct-insert$ arguments ?index ?name)\n\t\t\t\t\t\t\t (return ?index)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%d]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t?self:array-size)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" $?args \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(modify ?msg (to grouping-update)\n\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t (arguments ?objName => $?args))\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-glapi-function-void\n\t\t\t(declare (salience 1))\n\t\t\t?msg <- (message (to build-groups)\n\t\t\t\t\t\t\t\t (action add-to-span)\n\t\t\t\t\t\t\t\t (arguments ?id))\n\t\t\t?obj <- (object (is-a file-line) \n\t\t\t\t\t\t\t\t (id ?id)\n\t\t\t\t\t\t\t\t (type GLAPI-DEF)\n\t\t\t\t\t\t\t\t (contents GLAPI ?ret GLAPIENTRY ?name \"(\" void \")\"))\n\t\t\t=>\n\t\t\t;we need to set this up to do conversion of the different arguments\n\t\t\t(bind ?objName (gensym*))\n\t\t\t(retract ?msg)\n\t\t\t(make-instance ?objName of GLAPIFunction \n\t\t\t\t\t\t\t\t(return-type ?ret)\n\t\t\t\t\t\t\t\t(function-name ?name)\n\t\t\t\t\t\t\t\t(clips-function-name (sym-cat CLIPS_ ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-fixed-size-array-argument\n\t\t\t(declare (salience 2))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry \"[\" ?size \"]\" ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIFixedArrayArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))\n\t\t\t\t\t\t\t\t(array-size ?size)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::parse-arguments-generic\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?sentry ,|\",\" $?rest))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?rest))\n\t\t\t(bind ?name (gensym*))\n\t\t\t(duplicate ?fct (action populate-argument)\n\t\t\t\t\t\t (arguments ?name => $?sentry))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::create-last-argument\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ?o => $?all))\n\t\t\t(test (and (not (member$ , $?all))\n\t\t\t\t\t\t (not (member$ \",\" $?all))))\n\t\t\t?obj <- (object (is-a GLAPIFunction)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(bind ?name (gensym*))\n\t\t\t(modify ?fct (action populate-argument)\n\t\t\t\t\t (arguments ?name => $?all))\n\t\t\t(make-instance ?name of GLAPIArgument\n\t\t\t\t\t\t\t\t(parent ?o)\n\t\t\t\t\t\t\t\t(index (send ?obj add-argument ?name))))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-empty-parse-message\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action parse-arguments)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-pointer\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before \"*\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument) \n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-pointer TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::mark-argument-is-constant\n\t\t\t(declare (salience 1))\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => $?before const|\"const\" $?after))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(modify ?fct (arguments ?o => $?before $?after))\n\t\t\t(modify-instance ?obj (is-constant TRUE)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::set-argument-core-info\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ?o => ?type ?name))\n\t\t\t?obj <- (object (is-a GLAPIArgument)\n\t\t\t\t\t\t\t\t (id ?o))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(modify-instance ?obj (argument-type ?type)\n\t\t\t\t\t\t\t\t (argument-name ?name)))\n;------------------------------------------------------------------------------\n(defrule grouping-update::retract-arguments\n\t\t\t?fct <- (message (to grouping-update)\n\t\t\t\t\t\t\t\t (action populate-argument)\n\t\t\t\t\t\t\t\t (arguments ? =>))\n\t\t\t=>\n\t\t\t(retract ?fct))\n;------------------------------------------------------------------------------\n(defrule grouping-update::printout-arguments\n\t\t\t(declare (salience -10))\n\t\t\t?obj <- (object (is-a GLAPIArgument))\n\t\t\t=>\n\t\t\t(printout t (send ?obj reconstitute) crlf))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"c5e869331c4313ab137318d48583b0ec41396d29","subject":"src\/lib\/widget\/Library.clp: Added batch* statements to load starting objects","message":"src\/lib\/widget\/Library.clp: Added batch* statements to load starting objects\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/neutron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron","old_file":"src\/lib\/widget\/Library.clp","new_file":"src\/lib\/widget\/Library.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n(batch* \"lib\/widget\/WidgetEvent.clp\")\n(batch* \"lib\/widget\/WidgetElement.clp\")\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Library.clp - Defines the widget module and loads all corresponding files.\n; \n; Written by Joshua Scoggins \n; Started on 3\/11\/2013\n;------------------------------------------------------------------------------\n; Define the module\n;------------------------------------------------------------------------------\n(defmodule widget \n\t\t\t (import cortex ?ALL)\n\t\t\t (export ?ALL))\n;------------------------------------------------------------------------------\n; Load the corresponding types and functions \n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"5c30a943b4ddeb39d49f04f270bd5d050b02004f","subject":"Fixed a backwards logic condition in Pass.clp","message":"Fixed a backwards logic condition in Pass.clp\n\nThe code of the pass was not being loaded because it would only occur if the\nentry-point string returned a negative number...obviously this would never\noccur so the reverse condition needed to be set.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (> (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING) (visibility public))\n (slot pass-description (type STRING) (visibility public)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass init around () \n\t\t\t\t\t\t (call-next-handler)\n\t\t\t\t\t\t ;automatically load the code if there is an entry point\n\t\t\t\t\t\t (if (and (< (str-length ?self:entry-point) 0)\n\t\t\t\t\t\t\t\t\t (not (defmodule-exists ?self:pass-name))) then\n\t\t\t\t\t\t\t (batch* ?self:entry-point))\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (if (not (pass-registered ?self:pass-name)) then\n\t\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg)\n\t\t\t\t\t\t\t (return TRUE)\n\t\t\t\t\t\t\t else\n\t\t\t\t\t\t\t (printout werror \"ERROR: pass already registered\" crlf)\n\t\t\t\t\t\t\t (return FALSE)))\n\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"2f1a78bff48f4f9885a7c9c68d7fed712b22eb94","subject":"Rewrote indirect::Pass to work with the functions defined in libpipeline_clips","message":"Rewrote indirect::Pass to work with the functions defined in libpipeline_clips\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_file":"lib\/durandal\/modules\/indirect\/Pass.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING))\n (slot pass-description (type STRING)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot pass-type (type SYMBOL) (allowed-symbols Unknown Module Function Region\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t Loop BasicBlock CallGraphSCC MachineFunction))\n (slot is-analysis (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot is-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-loops (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot need-regions (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-all (type SYMBOL) (allowed-symbols FALSE TRUE))\n (slot preserves-cfg (type SYMBOL) (allowed-symbols FALSE TRUE))\n (multislot passes (type SYMBOL))\n (multislot required (type SYMBOL))\n (multislot required-transitive (type SYMBOL))\n (multislot preserved (type SYMBOL))\n ;begin CLIPS specific slots\n (slot entry-point (type STRING))\n (message-handler register)\n (message-handler unregister)\n (message-handler is-registered))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass register ()\n\t\t\t\t\t\t (register-pass ?self:pass-name \n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-description\n\t\t\t\t\t\t\t\t\t\t\t ?self:pass-type\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-analysis\n\t\t\t\t\t\t\t\t\t\t\t ?self:is-cfg\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-regions\n\t\t\t\t\t\t\t\t\t\t\t ?self:need-loops\n\t\t\t\t\t\t\t\t\t\t\t ?self:passes\n\t\t\t\t\t\t\t\t\t\t\t ?self:required\n\t\t\t\t\t\t\t\t\t\t\t ?self:required-transitive\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserved\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-all\n\t\t\t\t\t\t\t\t\t\t\t ?self:preserves-cfg))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass unregister ()\n\t\t\t\t\t\t (unregister-pass ?self:pass-name))\n;------------------------------------------------------------------------------\n(defmessage-handler indirect::Pass is-registered () \n\t\t\t\t\t\t (pass-registered ?self:pass-name))\n;------------------------------------------------------------------------------\n\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; Pass.clp - Pass types that interact with LibIndirect \n;------------------------------------------------------------------------------\n(defclass indirect::PassBase \n \"The base class of all passes (native or indirect)\"\n (is-a Object) \n (slot pass-name (type SYMBOL STRING))\n (slot pass-description (type STRING)))\n;------------------------------------------------------------------------------\n(defclass indirect::NativePass \n \"A wrapper over a native LLVM pass\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive))\n;------------------------------------------------------------------------------\n(defclass indirect::Pass \n \"Represents an indirect pass that uses LibIndirect to interact with LLVM\"\n (is-a PassBase)\n (role concrete)\n (pattern-match reactive)\n (slot entry (type STRING))\n (slot target (type SYMBOL) (allowed-symbols Any Module Function Region Loop\n BasicBlock Instruction Immutable))\n (multislot pass-uses (type SYMBOL STRING INSTANCE-NAME) \n (allowed-classes PassBase)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fff8c7a431cbb315b4252c0edad06b16aafa5a9a","subject":"Create task1.clp","message":"Create task1.clp","repos":"Imperat\/SSU-Courses,Imperat\/SSU-Courses","old_file":"ssu-ai-level-2\/chapter6\/task1.clp","new_file":"ssu-ai-level-2\/chapter6\/task1.clp","new_contents":"(deffunction length-otr (?a1 ?a2 ?b1 ?b2)\n (sqrt (+ (* (- ?b1 ?a1) (- ?b1 ?a1)) (* (- ?b2 ?a2) (- ?b2 ?a2))))\n)\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'ssu-ai-level-2\/chapter6\/task1.clp' did not match any file(s) known to git\n","license":"apache-2.0","lang":"CLIPS"} {"commit":"d95652ec75eefb12eb64274fe04e8ef960ba986e","subject":"Fixed bugs in PathUpdate.clp","message":"Fixed bugs in PathUpdate.clp\n\nI was trying to do a direct slot modify of a slot that didn't exist because\n\"values\" only exists in Hint and it's subtypes. The slot \"contents\" is used as\nthe standard backing for everything that inherits from list.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/loop-region-merging\/PathUpdate.clp","new_file":"lib\/durandal\/passes\/loop-region-merging\/PathUpdate.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-region\n\t\t\t(object (is-a Region) (id ?r))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?r))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?r)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-basicblock\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?b))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-population::populate-determinant\n \t\t\t?fct <- (message (to loop-region-merging) \n\t\t\t\t(action claim-owns) \n\t\t\t\t(arguments ?a => ?b))\n\t\t\t?obj <- (object (is-a OwnershipDeterminant) (parent ?b))\n\t\t\t?obj2 <- (object (is-a OwnershipDeterminant) (parent ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n (object-pattern-match-delay \n\t\t\t(slot-insert$ ?obj2 PotentialChildren 1 ?b)\n\t\t\t(slot-insert$ ?obj Claims 1 ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-resolution::determine-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?v ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b) \n\t\t\t\t\t (PotentialChildren $? ?b $?) (Claims $? ?a $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t\t\t\t(PotentialChildren $?t ?b $?r))\n\t\t\t=>\n\t\t\t;let's see if this is faster\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?v ?x))\n (modify-instance ?t1 (PotentialChildren ?t ?r))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-indirect-resolution::determine-indirect-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?l ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b&~?a) \n\t\t\t\t\t (IndirectClaims $? ?a $?) (PotentialChildren $? ?b $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a)\n\t\t\t\t\t\t\t\t(PotentialChildren $?z ?b $?q))\n\t\t\t=>\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?l ?x))\n (modify-instance ?t1 (PotentialChildren ?z ?q))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::delete-non-existent-references\n\t\t\t?region <- (object (is-a Region) (contents $? ?b $?))\n\t\t\t(not (exists (object (id ?b))))\n\t\t\t=>\n (object-pattern-match-delay \n\t\t\t(bind ?ind0 (member$ ?b (send ?region get-contents)))\n\t\t\t(slot-delete$ ?region contents ?ind0 ?ind0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) (Claims ?a))\n\t\t\t?obj <- (object (is-a Region) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) \n\t\t\t\t\t (Claims ?a))\n\t\t\t?obj <- (object (is-a BasicBlock) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::add-new-child-to-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p)\n\t\t\t\t\t (PotentialChildren $? ?a $?))\n\t\t\t?region <- (object (is-a Region) (id ?p) (contents $?c))\n (test (not (member$ ?a ?c)))\n\t\t\t=>\n\t\t\t(slot-insert$ ?region contents 1 ?a))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::cleanup-ownership-determinants\n\t\t\t\"Deletes all of the OwnershipDeterminant objects in a single rule \n\t\t\tfire\"\n\t\t\t?f0 <- (delete ownership-determinants)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?obj (find-all-instances ((?list OwnershipDeterminant)) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t TRUE))\n\t\t\t\t\t (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-rename::remove-unowned-elements\n\t\t\t\"Now that we have figured out and updated ownership claims it is \n\t\t\tnecessary to remove leftover entries in other regions\"\n\t\t\t?r <- (object (is-a Region) (id ?t) (contents $?a ?b $?c))\n\t\t\t(object (is-a ParentedObject) (id ?b) (parent ~?t))\n\t\t\t=>\n\t\t\t(modify-instance ?r (contents $?a $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-too-many-claims-of-ownership\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t (Claims $?z&:(> (length$ ?z) 1))\n\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?name \" has more than one claim of ownership on\"\n\t\t\t\t\t\t \" it!\" crlf \"The claims are \" ?z crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a Region) (id ?a) (IsTopLevelRegion FALSE))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a BasicBlock) (id ?a)) \n\t\t\t=>\n\t\t\t(printout t \"ERROR: BasicBlock \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-region\n\t\t\t(object (is-a Region) (id ?r))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?r))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?r)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-construction::construct-determinant-for-basicblock\n\t\t\t(object (is-a BasicBlock) (id ?b))\n\t\t\t(not (exists (object (is-a OwnershipDeterminant) (parent ?b))))\n\t\t\t=>\n\t\t\t(make-instance of OwnershipDeterminant (parent ?b)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-population::populate-determinant\n\t\t\t?fct <- (claim ?a owns ?b)\n\t\t\t?obj <- (object (is-a OwnershipDeterminant) (parent ?b))\n\t\t\t?obj2 <- (object (is-a OwnershipDeterminant) (parent ?a))\n\t\t\t=>\n\t\t\t(retract ?fct)\n (object-pattern-match-delay \n\t\t\t(slot-insert$ ?obj2 PotentialChildren 1 ?b)\n\t\t\t(slot-insert$ ?obj Claims 1 ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-resolution::determine-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?v ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b) \n\t\t\t\t\t (PotentialChildren $? ?b $?) (Claims $? ?a $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t\t\t\t(PotentialChildren $?t ?b $?r))\n\t\t\t=>\n\t\t\t;let's see if this is faster\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?v ?x))\n (modify-instance ?t1 (PotentialChildren ?t ?r))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-determinant-indirect-resolution::determine-indirect-indirect-claim\n\t\t\t?t0 <- (object (is-a OwnershipDeterminant) (parent ?b) \n\t\t\t\t\t\t\t\t(Claims $?l ?a $?x) (IndirectClaims $?ic))\n\t\t\t(object (is-a OwnershipDeterminant) (parent ~?b&~?a) \n\t\t\t\t\t (IndirectClaims $? ?a $?) (PotentialChildren $? ?b $?))\n\t\t\t?t1 <- (object (is-a OwnershipDeterminant) (parent ?a)\n\t\t\t\t\t\t\t\t(PotentialChildren $?z ?b $?q))\n\t\t\t=>\n (object-pattern-match-delay \n (modify-instance ?t0 (IndirectClaims ?ic ?a) (Claims ?l ?x))\n (modify-instance ?t1 (PotentialChildren ?z ?q))))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::delete-non-existent-references\n\t\t\t?region <- (object (is-a Region) (contents $? ?b $?))\n\t\t\t(not (exists (object (id ?b))))\n\t\t\t=>\n (object-pattern-match-delay \n\t\t\t(bind ?ind0 (member$ ?b (send ?region get-contents)))\n\t\t\t(slot-delete$ ?region contents ?ind0 ?ind0)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) (Claims ?a))\n\t\t\t?obj <- (object (is-a Region) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::update-owner-of-target-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p) \n\t\t\t\t\t (Claims ?a))\n\t\t\t?obj <- (object (is-a BasicBlock) (id ?p))\n\t\t\t=>\n\t\t\t(modify-instance ?obj (parent ?a)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-update::add-new-child-to-target-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?p)\n\t\t\t\t\t (PotentialChildren $? ?a $?))\n\t\t\t?region <- (object (is-a Region) (id ?p) (contents $?c))\n (test (not (member$ ?a ?c)))\n\t\t\t=>\n\t\t\t(slot-insert$ ?region values 1 ?a))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-cleanup-merger::cleanup-ownership-determinants\n\t\t\t\"Deletes all of the OwnershipDeterminant objects in a single rule \n\t\t\tfire\"\n\t\t\t?f0 <- (delete ownership-determinants)\n\t\t\t=>\n\t\t\t(retract ?f0)\n\t\t\t(progn$ (?obj (find-all-instances ((?list OwnershipDeterminant)) \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t TRUE))\n\t\t\t\t\t (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup-rename::remove-unowned-elements\n\t\t\t\"Now that we have figured out and updated ownership claims it is \n\t\t\tnecessary to remove leftover entries in other regions\"\n\t\t\t?r <- (object (is-a Region) (id ?t) (contents $?a ?b $?c))\n\t\t\t(object (is-a ParentedObject) (id ?b) (parent ~?t))\n\t\t\t=>\n\t\t\t(modify-instance ?r (values $?a $?c)))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-too-many-claims-of-ownership\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) \n\t\t\t\t\t (Claims $?z&:(> (length$ ?z) 1))\n\t\t\t\t\t (id ?name))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?name \" has more than one claim of ownership on\"\n\t\t\t\t\t\t \" it!\" crlf \"The claims are \" ?z crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-region\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a Region) (id ?a) (IsTopLevelRegion FALSE))\n\t\t\t=>\n\t\t\t(printout t \"ERROR: \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n(defrule loop-region-merging-fixup::FAILURE-no-remaining-claims-for-basicblock\n\t\t\t(object (is-a OwnershipDeterminant) (parent ?a) (Claims)\n\t\t\t\t\t (PotentialChildren $?pc) (IndirectClaims $?ic))\n\t\t\t(object (is-a BasicBlock) (id ?a)) \n\t\t\t=>\n\t\t\t(printout t \"ERROR: BasicBlock \" ?a \" has no remaining claims!\" crlf \n\t\t\t\t\t\t ?a \" has \" $?pc \" as it's potential children.\" crlf\n\t\t\t\t\t\t ?a \" has \" $?ic \" as it's indirect claims.\" crlf)\n\t\t\t(exit))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"fc4cf895a86619ad0728cefa518ed142004fb19f","subject":"Updated WavefrontDeterminantLogic.clp to use the new determinant module name","message":"Updated WavefrontDeterminantLogic.clp to use the new determinant module name\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/determinant\/WavefrontDeterminantLogic.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::InstanceFrequencyCounter\n\t\t\t\"Creates a frequency counter hint for basic blocks\"\n\t\t\t(declare (salience 2))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region))\n\t\t\t(not (exists (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t\t\t(parent ?p))))\n\t\t\t=>\n\t\t\t(make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::IncrementFrequencyCounter-BasicBlock\n\t\t\t\"Goes through a given Region counting the number of basic blocks found\n\t\t\twithin the region. Valid blocks are blocks that contain more than one \n\t\t\tinstruction as we don't want to count JS nodes as they don't usually \n\t\t\tcontain code.\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region) \n\t\t\t\t\t (contents $? ?t $?))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?t) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (contents $?insts&:(> (length$ $?insts) 1)))\n\t\t\t?wa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p))\n\t\t\t=>\n\t\t\t(send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-determinant::ImplyEnoughBlocks\n\t\t\t\"There are enough blocks within the target region to make it a \n\t\t\tcandidate for wavefront scheduling. Make a hint that says this.\"\n\t\t\t?fa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t(frequency ?z&:(and (< ?z 100) (> ?z 1))))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?p)\n\t\t\t\t\t\t\t\t\t (class Region))\n\t\t\t=>\n\t\t\t(unmake-instance ?fa)\n\t\t\t(assert (message (to wavefront-scheduling)\n\t\t\t\t\t\t\t\t (action can-wavefront-schedule)\n\t\t\t\t\t\t\t\t (argument ?p))\n\t\t\t\t\t (message (to path-conditional)\n\t\t\t\t\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; FrequencyAnalysis.clp - Determines which regions to apply wavefront\n; scheduling to \n; Written by Joshua Scoggins (6\/30\/2012) \n;------------------------------------------------------------------------------\n(defrule wavefront-determinant::InstanceFrequencyCounter\n\t\t\t\"Creates a frequency counter hint for basic blocks\"\n\t\t\t(declare (salience 2))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region))\n\t\t\t(not (exists (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t\t\t(parent ?p))))\n\t\t\t=>\n\t\t\t(make-instance of FrequencyAnalysis (parent ?p)))\n;------------------------------------------------------------------------------\n(defrule wavefront-determinant::IncrementFrequencyCounter-BasicBlock\n\t\t\t\"Goes through a given Region counting the number of basic blocks found\n\t\t\twithin the region. Valid blocks are blocks that contain more than one \n\t\t\tinstruction as we don't want to count JS nodes as they don't usually \n\t\t\tcontain code.\"\n\t\t\t(declare (salience 1))\n\t\t\t(object (is-a Region) \n\t\t\t\t\t (id ?p) \n\t\t\t\t\t (class Region) \n\t\t\t\t\t (contents $? ?t $?))\n\t\t\t(object (is-a BasicBlock) \n\t\t\t\t\t (id ?t) \n\t\t\t\t\t (parent ?p) \n\t\t\t\t\t (contents $?insts&:(> (length$ $?insts) 1)))\n\t\t\t?wa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p))\n\t\t\t=>\n\t\t\t(send ?wa increment-frequency))\n;------------------------------------------------------------------------------\n(defrule wavefront-determinant::ImplyEnoughBlocks\n\t\t\t\"There are enough blocks within the target region to make it a \n\t\t\tcandidate for wavefront scheduling. Make a hint that says this.\"\n\t\t\t?fa <- (object (is-a FrequencyAnalysis) \n\t\t\t\t\t\t\t\t(parent ?p) \n\t\t\t\t\t\t\t\t(frequency ?z&:(and (< ?z 100) (> ?z 1))))\n\t\t\t?region <- (object (is-a Region) \n\t\t\t\t\t\t\t\t\t (id ?p)\n\t\t\t\t\t\t\t\t\t (class Region))\n\t\t\t=>\n\t\t\t(unmake-instance ?fa)\n\t\t\t(assert (message (to wavefront-scheduling)\n\t\t\t\t\t\t\t\t (action can-wavefront-schedule)\n\t\t\t\t\t\t\t\t (argument ?p))\n\t\t\t\t\t (message (to path-conditional)\n\t\t\t\t\t\t\t\t (action valid-pathing-target)\n\t\t\t\t\t\t\t\t (arguments ?p))))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"d1f42acb2911505bf20f3e20fe2d50caf3c46f26","subject":"GLAPIConversionTypes.clp: Gave most slots public visibility for code gen","message":"GLAPIConversionTypes.clp: Gave most slots public visibility for code gen\n","repos":"DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/neutron,DrItanium\/electron-platform,DrItanium\/electron-platform","old_file":"src\/tools\/conv\/gl\/glapi\/lib\/GLAPIConversionTypes.clp","new_file":"src\/tools\/conv\/gl\/glapi\/lib\/GLAPIConversionTypes.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversionTypes.clp - Functions for the glapi conversion expert\n; system\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects (visibility public))\n (multislot variables (visibility public))\n (multislot parsing-entries (visibility public))\n (slot count))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot clips-type (type SYMBOL) (visibility public))\n (slot gl-type (type SYMBOL) (visibility public))\n (slot clips-function-name (type SYMBOL) (visibility public))\n (slot index (type INTEGER) (range 1 ?VARIABLE) (visibility public))\n (slot argument-name-base (type SYMBOL STRING) (visibility public))\n (slot data-object-argument-name (type SYMBOL STRING) (visibility public))\n (slot variable-argument-name (type SYMBOL STRING) (visibility public))\n (slot variable-declaration (type STRING) (visibility public))\n (slot data-object-declaration (type STRING) (visibility public))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-type-check-code ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,%s,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-type\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s = %s(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t(get-conversion-function \n\t\t\t\t\t\t\t\t\t\t\t\t (flatten-type ?self:clips-type))\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-length-variable-declaration (visibility public))\n (slot multifield-length-variable-name (visibility public))\n (slot multifield-pointer-argument-name (visibility public))\n (slot multifield-pointer-declaration (visibility public))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-type-check-code primary ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,MULTIFIELD,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s%n%s%n%s%n%s%n\"\n\t\t\t\t\t\t\t\t\t\t\t\t;GetLength\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetDOLength(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;GetValue\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetValue(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-pointer-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;Generate malloc\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = (%s*)calloc(%s,sizeof(%s));\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type)\n\t\t\t\t\t\t\t\t\t\t\t\t;Conversion\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s%n%s%n%s%n\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"int i, end;%nend = GetDOEnd(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"for(i = GetDOBegin(%s); i<=end; i++) {\", \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ;TODO: Continue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ))))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size (visibility public)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLAPIConversionTypes.clp - Functions for the glapi conversion expert\n; system\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFunction\n \"Defines a given GLAPI function\"\n (is-a Object)\n (slot return-type (type SYMBOL STRING))\n (slot function-name)\n (slot clips-function-name))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIArgument\n \"Defines a given GLAPI function argument\"\n (is-a Object)\n (slot argument-type (visibility public))\n (slot argument-name)\n (slot index)\n (slot is-constant (type SYMBOL) (allowed-values FALSE TRUE))\n (slot is-pointer (type SYMBOL) (allowed-values FALSE TRUE))\n (message-handler reconstitute))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIArgument reconstitute\n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s %s %s %s\" \n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-constant then \"const\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-type\n\t\t\t\t\t\t\t\t\t\t\t\t(if ?self:is-pointer then \"*\" else \"\")\n\t\t\t\t\t\t\t\t\t\t\t\t?self:argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::GLAPIFixedArrayArgument\n \"Refers to fixed size arrays\"\n (is-a GLAPIArgument)\n (slot array-size)\n (message-handler reconstitute around))\n;------------------------------------------------------------------------------\n(defmessage-handler types::GLAPIFixedArrayArgument reconstitute around \n\t\t\t\t\t\t ()\n\t\t\t\t\t\t (return (format nil \"%s[%s]\" \n\t\t\t\t\t\t\t\t\t\t\t\t(call-next-handler)\n\t\t\t\t\t\t\t\t\t\t\t\t(str-cat ?self:array-size))))\n;------------------------------------------------------------------------------\n(defclass types::FunctionBuilder\n \"Builds C functions\"\n (is-a Object)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSFunctionBuilder\n (is-a FunctionBuilder)\n (multislot data-objects)\n (multislot variables)\n (multislot parsing-entries)\n (slot count))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIArgumentBuilder\n (is-a Object)\n (slot clips-type (type SYMBOL))\n (slot gl-type (type SYMBOL))\n (slot clips-function-name (type SYMBOL))\n (slot index (type INTEGER) (range 1 ?VARIABLE))\n (slot argument-name-base (type SYMBOL STRING))\n (slot data-object-argument-name (type SYMBOL STRING))\n (slot variable-argument-name (type SYMBOL STRING))\n (slot variable-declaration (type STRING))\n (slot data-object-declaration (type STRING))\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-type-check-code ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,%s,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-type\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIArgumentBuilder get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s = %s(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t(get-conversion-function \n\t\t\t\t\t\t\t\t\t\t\t\t (flatten-type ?self:clips-type))\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIMultifieldArgumentBuilder\n (is-a CLIPSGLAPIArgumentBuilder)\n (slot multifield-length-variable-declaration)\n (slot multifield-length-variable-name)\n (slot multifield-pointer-argument-name)\n (slot multifield-pointer-declaration)\n (message-handler get-type-check-code)\n (message-handler get-conversion-code))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-type-check-code primary ()\n\t\t\t\t\t\t (return (format nil \n\t\t\t\t\t\t\t\t\t\t\t\t\"if(EnvArgTypeCheck(theEnv,%s,%d,MULTIFIELD,&%s) == -1) { return; }\"\n\t\t\t\t\t\t\t\t\t\t\t\t?self:clips-function-name\n\t\t\t\t\t\t\t\t\t\t\t\t?self:index\n\t\t\t\t\t\t\t\t\t\t\t\t?self:data-object-argument-name)))\n;------------------------------------------------------------------------------\n(defmessage-handler types::CLIPSGLAPIMultifieldArgumentBuilder\n\t\t\t\t\t\t get-conversion-code ()\n\t\t\t\t\t\t (return (format nil \"%s%n%s%n%s%n%s%n\"\n\t\t\t\t\t\t\t\t\t\t\t\t;GetLength\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetDOLength(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;GetValue\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = GetValue(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-pointer-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t;Generate malloc\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s = (%s*)calloc(%s,sizeof(%s));\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:variable-argument-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:multifield-length-variable-name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:gl-type)\n\t\t\t\t\t\t\t\t\t\t\t\t;Conversion\n\t\t\t\t\t\t\t\t\t\t\t\t(format nil \"%s%n%s%n%s%n\" \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"int i, end;%nend = GetDOEnd(%s);\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (format nil \"for(i = GetDOBegin(%s); i<=end; i++) {\", \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t ?self:data-object-argument-name)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ;TODO: Continue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t ))))\n;------------------------------------------------------------------------------\n(defclass types::CLIPSGLAPIFixedSizeMultifieldArgumentBuilder\n (is-a CLIPSGLAPIMultifieldArgumentBuilder)\n (slot multifield-size))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"0192d00bfcb87b3462e1931eed2f7e59a6b719a8","subject":"Modified the PathConstruction logic to path all regions.","message":"Modified the PathConstruction logic to path all regions.\n\nThis includes loops.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/path\/PathConstruction.clp","new_file":"lib\/durandal\/passes\/path\/PathConstruction.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths::initialize-path-construction-region\n\t\t\t(declare (salience 3))\n\t\t\t;?fct <- (compute paths in region ?id)\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a Region) (id ?z) (parent ?id) (Entrances $? ?a $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n&~?id))\n\t\t\t=>\n\t\t\t;(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths::initialize-path-construction-basicblock\n\t\t\t(declare (salience 3))\n\t\t\t;?fct <- (compute paths in region ?id)\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n))\n\t\t\t=>\n\t\t\t;(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?a)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; PathConstruction.clp - Contains rules devoted to starting the construction of\n; a given path through a given region. Rewritten to take advantage of modules\n;------------------------------------------------------------------------------\n(defrule paths::initialize-path-construction-region\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (compute paths in region ?id)\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a Region) (id ?z) (parent ?id) (Entrances $? ?a $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n&~?id))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?z)))\n;------------------------------------------------------------------------------\n(defrule paths::initialize-path-construction-basicblock\n\t\t\t(declare (salience 3))\n\t\t\t?fct <- (compute paths in region ?id)\n\t\t\t?r0 <- (object (is-a Region) (id ?id) (Entrances $? ?a $?) \n\t\t\t\t\t\t\t\t(contents $? ?z $?))\n\t\t\t(object (is-a BasicBlock) (id ?a) (parent ?n))\n\t\t\t=>\n\t\t\t(retract ?fct)\n\t\t\t(make-instance of Path (parent ?n) (values ?a)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"8e626d5cfd1ca803127cd5e04d8bb313801e9caa","subject":"Modified ConstantConversionFunctions.clp to put ; at the end of conditionals","message":"Modified ConstantConversionFunctions.clp to put ; at the end of conditionals\n","repos":"DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/neutron,DrItanium\/electron","old_file":"src\/tools\/conv\/gl\/constant\/lib\/ConstantConversionFunctions.clp","new_file":"src\/tools\/conv\/gl\/constant\/lib\/ConstantConversionFunctions.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ConstantConversionFunctions.clp - Defines the functions specific to the\n; constant conversion expert system\n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\") == 0) {\" \n (if ?if then \"if\" else \"} else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s;\" ?str)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; ConstantConversionFunctions.clp - Defines the functions specific to the\n; constant conversion expert system\n;------------------------------------------------------------------------------\n(deffunction grouping-update::retrieve-element (?s)\n (nth 1 (send (instance-address * (symbol-to-instance-name ?s))\n get-contents)))\n;------------------------------------------------------------------------------\n(deffunction grouping-update::to-conditional-field (?symbol ?if)\n (bind ?str (str-cat (retrieve-element ?symbol)))\n (create$ (format nil \"%s(strcmp(input, \\\"%s\\\") == 0) {\" \n (if ?if then \"if\" else \"} else if\")\n (sub-string (+ (str-index \"_\" ?str) 1) \n (str-length ?str) ?str))\n (format nil \"return %s\" ?str)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"a942c73bcfeb4819b5e6093c79c51d2f497bdfcc","subject":"Modified the code further to take advantage of modules","message":"Modified the code further to take advantage of modules\n","repos":"DrItanium\/neutron,DrItanium\/electron,DrItanium\/AdventureEngine,DrItanium\/electron-platform,DrItanium\/electron-platform,DrItanium\/electron,DrItanium\/electron-platform,DrItanium\/AdventureEngine,DrItanium\/electron","old_file":"src\/tools\/GLConstantConversion.clp","new_file":"src\/tools\/GLConstantConversion.clp","new_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (message (to identify-lines)\n (action read-file)\n (arguments ?name)))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (message (to identify-lines)\n (action read-file)\n (arguments ?name))\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (duplicate ?fct)\n (make-instance of file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result)))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule convert-templates::retract-unknowns \n ?f <- (object (is-a file-line) (type UNKNOWN))\n =>\n (unmake-instance ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (object (is-a file-line) \n (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify-instance ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (object (is-a file-line)\n (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify-instance ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (object (is-a file-line) \n (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (object (is-a file-line)\n (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (object (is-a file-line) \n (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (unmake-instance ?f1 ?f2)\n (modify-instance ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","old_contents":";------------------------------------------------------------------------------\n;Copyright (c) 2013, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n; GLConstantConversion.clp - an expert system that reads a define and generates\n; conversion code for it. \n;------------------------------------------------------------------------------\n(defmodule types \n (export ?ALL))\n;------------------------------------------------------------------------------\n(defmodule identify-lines \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule convert-templates\n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule build-groups \n (import types ?ALL))\n;------------------------------------------------------------------------------\n(defmodule MAIN \n (import types ?ALL)\n (export ?ALL))\n;------------------------------------------------------------------------------\n(defclass types::opened-file \n (is-a USER)\n (slot id)\n (slot index (type INTEGER) (range 0 ?VARIABLE))\n (message-handler next-index)\n (message-handler read-line)\n (message-handler close-file))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file next-index ()\n (bind ?old ?self:index)\n (bind ?self:index (+ ?old 1))\n (return ?old))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file read-line ()\n (readline ?self:id))\n;------------------------------------------------------------------------------\n(defmessage-handler types::opened-file close-file ()\n (close ?self:id))\n;------------------------------------------------------------------------------\n(deftemplate types::file-line \n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(deftemplate types::heading-span\n \"Defines a span between two different headings\"\n (slot header-name)\n (multislot contents)\n (slot from)\n (slot to)\n (slot parent)\n (slot distance))\n;------------------------------------------------------------------------------\n(deftemplate types::message \n (slot from)\n (slot to)\n (slot action)\n (multislot arguments))\n;------------------------------------------------------------------------------\n(defclass types::line-entry\n (is-a USER)\n (slot id)\n (slot index)\n (slot parent)\n (slot type)\n (multislot contents))\n;------------------------------------------------------------------------------\n(defmessage-handler types::line-entry init after ()\n (bind ?self:id (instance-name-to-symbol (instance-name ?self))))\n;------------------------------------------------------------------------------\n; INPUT FACT FORM: (parse constant file ?path)\n;------------------------------------------------------------------------------\n(deffunction types::get-input-form-factor () \n (printout t \"(parse constant file ?path)\" crlf))\n;------------------------------------------------------------------------------\n(defrule MAIN::open-target-file\n \"This rule takes a fact of the above INPUT FORM and attempts to open the file\"\n ?fct <- (parse constant file ?path)\n =>\n (bind ?name (gensym*))\n (retract ?fct)\n (if (open ?path ?name \"r\") then \n (make-instance of opened-file (id ?name) (index 0))\n (assert (read file ?name))\n (focus identify-lines convert-templates build-groups)\n else\n (printout t \"ERROR: target file at \" ?path \" does not exist!\" crlf \n \"Halting!\" crlf)\n (halt)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::build-file-line\n ?fct <- (read file ?fid)\n ?obj <- (object (is-a opened-file) \n (id ?fid))\n =>\n (retract ?fct)\n (bind ?result (send ?obj read-line))\n (if (neq ?result EOF) then\n (assert (read file ?fid)\n (file-line (index (send ?obj next-index))\n (type UNKNOWN)\n (parent ?fid)\n (contents (explode$ ?result))))\n else\n (send ?obj close-file)\n (unmake-instance ?obj)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::retract-unknowns \n (declare (salience -10))\n ?f <- (file-line (type UNKNOWN))\n =>\n (retract ?f))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-heading-groups\n \"Tags lines that consist of \/* $? *\/ as group headings\"\n ?f <- (file-line (type UNKNOWN)\n (contents \/* $? *\/))\n =>\n (modify ?f (type heading)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-entry-line\n \"Tags lines that are defines and modifies the associated contents\"\n ?f <- (file-line (type UNKNOWN) \n (contents #define ?name ?))\n =>\n (modify ?f (type #define) (contents ?name)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-three-line-headers\n \"Merges simple three line headings into one rule\"\n ?f0 <- (file-line (index ?i)\n (type UNKNOWN) \n (contents \/*))\n ?f1 <- (file-line (index ?i2&:(= ?i2 (+ ?i 1)))\n (type UNKNOWN) \n (contents * $?c))\n ?f2 <- (file-line (index ?i3&:(= ?i3 (+ ?i 2)))\n (type UNKNOWN)\n (contents *\/))\n =>\n (retract ?f1 ?f2)\n (modify ?f0 (contents \/* $?c *\/)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::mark-glapi-calls\n \"marks glapi calls\"\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $? \"(\" $? \")\"))\n =>\n (modify ?f (type GLAPI-DEF)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::merge-potential-glapi-calls\n \"Merges the next line of a GLAPI call if the line doesn't end with )\"\n (declare (salience -1))\n ?f <- (file-line (type UNKNOWN)\n (contents GLAPI $?vals \"(\" $?c)\n (index ?i))\n (test (not (member$ \")\" $?c)))\n ?f0 <- (file-line (index ?i0&:(= ?i0 (+ ?i 1)))\n (type UNKNOWN)\n (contents $?contents))\n =>\n (retract ?f)\n (modify ?f0 (contents GLAPI $?vals \"(\" $?c $?contents)))\n;------------------------------------------------------------------------------\n(defrule identify-lines::define-header-spans-initial\n \"Defines spans between headers\"\n (declare (salience -3))\n (file-line (type heading)\n (parent ?parent)\n (index ?i)\n (contents \/* $?name *\/))\n (not (exists (heading-span (from ?i) \n (parent ?parent))))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?i2 ?i)))\n =>\n (bind ?difference (- ?i2 ?i))\n (if (> ?difference 0) then\n (assert (heading-span (header-name (implode$ $?name))\n (from ?i) \n (to ?i2) \n (parent ?parent) \n (distance ?difference)))))\n;------------------------------------------------------------------------------\n(defrule identify-lines::modify-header-spans-for-smaller-size\n \"Retracts the heading-span in response to finding an earlier heading\"\n ?f <- (heading-span (from ?i)\n (to ?j)\n (parent ?parent))\n (file-line (type heading)\n (parent ?parent)\n (index ?i2&:(> ?j ?i2 ?i)))\n =>\n (modify ?f (to ?i2) \n (distance (- ?i2 ?i))))\n;------------------------------------------------------------------------------\n(defrule convert-templates::convert-line-objects\n ?f <- (file-line (type ?t) (parent ?p) (index ?i)\n (contents $?c))\n =>\n (retract ?f)\n (bind ?name (gensym*))\n (assert (message (to build-groups) \n (action add-to-span)\n (arguments ?name)))\n (make-instance ?name of line-entry \n (type ?t) \n (parent ?p) \n (index ?i)\n (contents $?c)))\n;------------------------------------------------------------------------------\n(defrule build-groups::build-grouping\n ?f <- (heading-span (from ?i) \n (to ?i2) \n (parent ?parent)\n (contents $?c))\n (object (is-a line-entry) \n (parent ?parent) \n (index ?loc&:(> ?i2 ?loc ?i))\n (id ?id))\n ?msg <- (message (to build-groups)\n (action add-to-span)\n (arguments ?id))\n =>\n (retract ?msg)\n (modify ?f (contents $?c ?id)))\n;------------------------------------------------------------------------------\n","returncode":0,"stderr":"","license":"bsd-2-clause","lang":"CLIPS"} {"commit":"880924daf9eb2ee9fd34ec52d2e004932b33145e","subject":"fixed problem caused duplicate names appear in Cousins","message":"fixed problem caused duplicate names appear in Cousins\n","repos":"The4Ms\/family-knowledgebase","old_file":"task 1\/Cousin, Nieve, Nephew.clp","new_file":"task 1\/Cousin, Nieve, Nephew.clp","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'task' did not match any file(s) known to git\nerror: pathspec '1\/Cousin,' did not match any file(s) known to git\nerror: pathspec 'Nieve,' did not match any file(s) known to git\nerror: pathspec 'Nephew.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"d6f9f2d3c1076e7a2b7a273f3d8894b09bb7f083","subject":"modified rules of task 1 to be triggered when their option is selected in the main menu","message":"modified rules of task 1 to be triggered when their option is selected in the main menu\n","repos":"The4Ms\/family-knowledgebase","old_file":"task 1\/rules.clp","new_file":"task 1\/rules.clp","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'task' did not match any file(s) known to git\nerror: pathspec '1\/rules.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"48e16cdcd1e2dbe1ee285af503bf3da2e95e676c","subject":"ladder sample - fix touchoff_z timer","message":"ladder sample - fix touchoff_z timer\n\nE and C pins must be connected for timer to work\n","repos":"ArcEye\/machinekit-testing,aschiffler\/linuxcnc,kinsamanka\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,ArcEye\/MK-Qt5,strahlex\/machinekit,unseenlaser\/linuxcnc,unseenlaser\/linuxcnc,araisrobo\/machinekit,araisrobo\/linuxcnc,unseenlaser\/machinekit,RunningLight\/machinekit,bobvanderlinden\/machinekit,cdsteinkuehler\/linuxcnc,araisrobo\/machinekit,kinsamanka\/machinekit,EqAfrica\/machinekit,ArcEye\/MK-Qt5,Cid427\/machinekit,unseenlaser\/machinekit,ArcEye\/MK-Qt5,ikcalB\/linuxcnc-mirror,EqAfrica\/machinekit,unseenlaser\/machinekit,bobvanderlinden\/machinekit,aschiffler\/linuxcnc,ArcEye\/machinekit-testing,unseenlaser\/linuxcnc,unseenlaser\/machinekit,ianmcmahon\/linuxcnc-mirror,kinsamanka\/machinekit,mhaberler\/machinekit,narogon\/linuxcnc,bmwiedemann\/linuxcnc-mirror,mhaberler\/machinekit,cdsteinkuehler\/linuxcnc,RunningLight\/machinekit,cdsteinkuehler\/MachineKit,cdsteinkuehler\/MachineKit,jaguarcat79\/ILC-with-LinuxCNC,ArcEye\/machinekit-testing,cdsteinkuehler\/MachineKit,Cid427\/machinekit,ianmcmahon\/linuxcnc-mirror,kinsamanka\/machinekit,cdsteinkuehler\/linuxcnc,bobvanderlinden\/machinekit,kinsamanka\/machinekit,bobvanderlinden\/machinekit,unseenlaser\/machinekit,cnc-club\/linuxcnc,cnc-club\/linuxcnc,cnc-club\/linuxcnc,strahlex\/machinekit,Cid427\/machinekit,araisrobo\/machinekit,cdsteinkuehler\/MachineKit,ArcEye\/MK-Qt5,ikcalB\/linuxcnc-mirror,ikcalB\/linuxcnc-mirror,ikcalB\/linuxcnc-mirror,EqAfrica\/machinekit,cdsteinkuehler\/linuxcnc,mhaberler\/machinekit,narogon\/linuxcnc,ikcalB\/linuxcnc-mirror,narogon\/linuxcnc,RunningLight\/machinekit,cdsteinkuehler\/MachineKit,unseenlaser\/linuxcnc,bobvanderlinden\/machinekit,bobvanderlinden\/machinekit,kinsamanka\/machinekit,mhaberler\/machinekit,unseenlaser\/machinekit,ianmcmahon\/linuxcnc-mirror,mhaberler\/machinekit,bmwiedemann\/linuxcnc-mirror,strahlex\/machinekit,ArcEye\/MK-Qt5,unseenlaser\/linuxcnc,ArcEye\/machinekit-testing,araisrobo\/linuxcnc,unseenlaser\/machinekit,araisrobo\/machinekit,narogon\/linuxcnc,Cid427\/machinekit,Cid427\/machinekit,araisrobo\/linuxcnc,cdsteinkuehler\/linuxcnc,unseenlaser\/machinekit,bmwiedemann\/linuxcnc-mirror,araisrobo\/linuxcnc,ianmcmahon\/linuxcnc-mirror,bmwiedemann\/linuxcnc-mirror,ArcEye\/MK-Qt5,ianmcmahon\/linuxcnc-mirror,aschiffler\/linuxcnc,araisrobo\/machinekit,bmwiedemann\/linuxcnc-mirror,strahlex\/machinekit,kinsamanka\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,aschiffler\/linuxcnc,cnc-club\/linuxcnc,araisrobo\/machinekit,bmwiedemann\/linuxcnc-mirror,cnc-club\/linuxcnc,kinsamanka\/machinekit,RunningLight\/machinekit,EqAfrica\/machinekit,RunningLight\/machinekit,narogon\/linuxcnc,EqAfrica\/machinekit,EqAfrica\/machinekit,Cid427\/machinekit,RunningLight\/machinekit,cdsteinkuehler\/linuxcnc,ArcEye\/MK-Qt5,araisrobo\/machinekit,ArcEye\/machinekit-testing,mhaberler\/machinekit,ianmcmahon\/linuxcnc-mirror,araisrobo\/linuxcnc,cdsteinkuehler\/MachineKit,bmwiedemann\/linuxcnc-mirror,ianmcmahon\/linuxcnc-mirror,mhaberler\/machinekit,ArcEye\/MK-Qt5,RunningLight\/machinekit,Cid427\/machinekit,strahlex\/machinekit,mhaberler\/machinekit,strahlex\/machinekit,araisrobo\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,ArcEye\/machinekit-testing,bobvanderlinden\/machinekit,RunningLight\/machinekit,ArcEye\/machinekit-testing,ikcalB\/linuxcnc-mirror,araisrobo\/machinekit,ArcEye\/machinekit-testing,EqAfrica\/machinekit,ikcalB\/linuxcnc-mirror,EqAfrica\/machinekit,bobvanderlinden\/machinekit,cnc-club\/linuxcnc,cnc-club\/linuxcnc,jaguarcat79\/ILC-with-LinuxCNC,Cid427\/machinekit,aschiffler\/linuxcnc,strahlex\/machinekit","old_file":"configs\/common\/configurable_options\/ladder\/touchoff_z.clp","new_file":"configs\/common\/configurable_options\/ladder\/touchoff_z.clp","new_contents":"_FILES_CLASSICLADDER\n_FILE-sequential.csv\n#VER=1.0\n_\/FILE-sequential.csv\n_FILE-timers_iec.csv\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n_\/FILE-timers_iec.csv\n_FILE-modbusioconf.csv\n#VER=1.0\n_\/FILE-modbusioconf.csv\n_FILE-timers.csv\n2,5\n1,0\n2,5\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-timers.csv\n_FILE-symbols.csv\n#VER=1.0\n%B0,step_1,\n%B1,step_2,\n%B2,%B2,\n%B3,%B3,\n%B4,%B4,\n%B5,%B5,\n%B6,%B6,\n%B7,%B7,\n%B8,%B8,\n%B9,%B9,\n%M0,cmd1_hold,\n%M1,cmd2-hold,\n%M2,cmd3-hold,\n%W0,%W0,\n%W1,%W1,\n%W2,%W2,\n%W3,%W3,\n%W4,%W4,\n%W5,%W5,\n%W6,%W6,\n%W7,%W7,\n%W8,%W8,\n%W9,%W9,\n%W10,%W10,\n%I0,touchoff,\n%I1,mdi_mode,\n%I2,in_posit.,\n%I3,%I3,\n%I4,%I4,\n%I5,%I5,\n%I6,%I6,\n%I7,%I7,\n%I8,%I8,\n%I9,%I9,\n%I10,%I10,\n%I11,%I11,\n%I12,%I12,\n%I13,%I13,\n%I14,%I14,\n%Q0,MDI_cmd1,\n%Q1,MDI_cmd2,\n%Q2,MDI_cmd3,\n%Q3,%Q3,\n%Q4,%Q4,\n%Q5,%Q5,\n%Q6,%Q6,\n%Q7,%Q7,\n%Q8,%Q8,\n%Q9,%Q9,\n%Q10,%Q10,\n%Q11,%Q11,\n%Q12,%Q12,\n%Q13,%Q13,\n%Q14,%Q14,\n%B10,%B10,\n%B11,%B11,\n%B12,%B12,\n%B13,%B13,\n%B14,%B14,\n%B15,%B15,\n%B16,%B16,\n%B17,%B17,\n%B18,%B18,\n%B19,%B19,\n%W11,%W11,\n%W12,%W12,\n%W13,%W13,\n%W14,%W14,\n%W15,%W15,\n%W16,%W16,\n%W17,%W17,\n%W18,%W18,\n%W19,%W19,\n%IW0,%IW0,\n%IW1,%IW1,\n%IW2,%IW2,\n%IW3,%IW3,\n%IW4,%IW4,\n%IW5,%IW5,\n%IW6,%IW6,\n%IW7,%IW7,\n%IW8,%IW8,\n%IW9,%IW9,\n%QW0,%QW0,\n%QW1,%QW1,\n%QW2,%QW2,\n%QW3,%QW3,\n%QW4,%QW4,\n%QW5,%QW5,\n%QW6,%QW6,\n%QW7,%QW7,\n%QW8,%QW8,\n%QW9,%QW9,\n%IF0,%IF0,\n%IF1,%IF1,\n%IF2,%IF2,\n%IF3,%IF3,\n%IF4,%IF4,\n%IF5,%IF5,\n%IF6,%IF6,\n%IF7,%IF7,\n%IF8,%IF8,\n%IF9,%IF9,\n%QF0,%QF0,\n%QF1,%QF1,\n%QF2,%QF2,\n%QF3,%QF3,\n%QF4,%QF4,\n%QF5,%QF5,\n%QF6,%QF6,\n%QF7,%QF7,\n%QF8,%QF8,\n%QF9,%QF9,\n%T0,cmd3-wait,\n%T1,%T1,Old Timer\n%T2,%T2,Old Timer\n%T3,%T3,Old Timer\n%T4,%T4,Old Timer\n%T5,%T5,Old Timer\n%T6,%T6,Old Timer\n%T7,%T7,Old Timer\n%T8,%T8,Old Timer\n%T9,%T9,Old Timer\n%TM0,%TM0,New Timer\n%TM1,%TM1,New Timer\n%TM2,%TM2,New Timer\n%TM3,%TM3,New Timer\n%TM4,%TM4,New Timer\n%TM5,%TM5,New Timer\n%TM6,%TM6,New Timer\n%TM7,%TM7,New Timer\n%TM8,%TM8,New Timer\n%TM9,%TM9,New Timer\n%M3,%M3,One-shot\n%M4,%M4,One-shot\n%M5,%M5,One-shot\n%M6,%M6,One-shot\n%M7,%M7,One-shot\n%M8,%M8,One-shot\n%M9,%M9,One-shot\n%C0,%C0,Counter\n%C1,%C1,Counter\n%C2,%C2,Counter\n%C3,%C3,Counter\n%C4,%C4,Counter\n%C5,%C5,Counter\n%C6,%C6,Counter\n%C7,%C7,Counter\n%C8,%C8,Counter\n%C9,%C9,Counter\n%E0,%E0,Error Flag Bit\n%E1,%E1,Error Flag Bit\n%E2,%E2,Error Flag Bit\n%E3,%E3,Error Flag Bit\n%E4,%E4,Error Flag Bit\n%E5,%E5,Error Flag Bit\n%E6,%E6,Error Flag Bit\n%E7,%E7,Error Flag Bit\n%E8,%E8,Error Flag Bit\n%E9,%E9,Error Flag Bit\n_\/FILE-symbols.csv\n_FILE-ioconf.csv\n#VER=1.0\n_\/FILE-ioconf.csv\n_FILE-monostables.csv\n2,5\n2,5\n2,5\n2,5\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-monostables.csv\n_FILE-general.txt\nPERIODIC_REFRESH=1\nSIZE_NBR_RUNGS=100\nSIZE_NBR_BITS=20\nSIZE_NBR_WORDS=20\nSIZE_NBR_TIMERS=10\nSIZE_NBR_MONOSTABLES=10\nSIZE_NBR_COUNTERS=10\nSIZE_NBR_TIMERS_IEC=10\nSIZE_NBR_PHYS_INPUTS=15\nSIZE_NBR_PHYS_OUTPUTS=15\nSIZE_NBR_ARITHM_EXPR=100\nSIZE_NBR_SECTIONS=10\nSIZE_NBR_SYMBOLS=160\n_\/FILE-general.txt\n_FILE-rung_0.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=0\n#NEXTRUNG=1\n1-0-50\/0 , 1-0-50\/1 , 2-0-0\/0 , 2-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 52-0-0\/0\n1-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/0\n0-0-0\/0 , 0-0-50\/2 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/1\n1-0-0\/0 , 3-0-50\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 53-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 52-1-0\/1\n_\/FILE-rung_0.csv\n_FILE-rung_1.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=0\n#NEXTRUNG=-1\n1-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/1\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/2\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/1\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 9-1-0\/0 , 99-0-0\/0 , 10-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/2 , 9-0-0\/0 , 50-0-60\/2\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-1-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 53-1-0\/1\n_\/FILE-rung_1.csv\n_FILE-arithmetic_expressions.csv\n#VER=2.0\n_\/FILE-arithmetic_expressions.csv\n_FILE-sections.csv\n#VER=1.0\n#NAME000=Prog1\n000,0,-1,0,1,0\n_\/FILE-sections.csv\n_FILE-counters.csv\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n_\/FILE-counters.csv\n_FILE-com_params.txt\nMODBUS_MASTER_SERIAL_PORT=\nMODBUS_MASTER_SERIAL_SPEED=9600\nMODBUS_MASTER_SERIAL_DATABITS=8\nMODBUS_MASTER_SERIAL_STOPBITS=1\nMODBUS_MASTER_SERIAL_PARITY=0\nMODBUS_ELEMENT_OFFSET=0\nMODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0\nMODBUS_MASTER_TIME_INTER_FRAME=100\nMODBUS_MASTER_TIME_OUT_RECEIPT=500\nMODBUS_MASTER_TIME_AFTER_TRANSMIT=0\nMODBUS_DEBUG_LEVEL=0\nMODBUS_MAP_COIL_READ=0\nMODBUS_MAP_COIL_WRITE=0\nMODBUS_MAP_INPUT=0\nMODBUS_MAP_HOLDING=0\nMODBUS_MAP_REGISTER_READ=0\nMODBUS_MAP_REGISTER_WRITE=0\n_\/FILE-com_params.txt\n_\/FILES_CLASSICLADDER\n","old_contents":"_FILES_CLASSICLADDER\n_FILE-timers_iec.csv\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n1,0,0\n_\/FILE-timers_iec.csv\n_FILE-com_params.txt\nMODBUS_MASTER_SERIAL_PORT=\nMODBUS_MASTER_SERIAL_SPEED=9600\nMODBUS_MASTER_SERIAL_DATABITS=8\nMODBUS_MASTER_SERIAL_STOPBITS=1\nMODBUS_MASTER_SERIAL_PARITY=0\nMODBUS_ELEMENT_OFFSET=0\nMODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0\nMODBUS_MASTER_TIME_INTER_FRAME=100\nMODBUS_MASTER_TIME_OUT_RECEIPT=500\nMODBUS_MASTER_TIME_AFTER_TRANSMIT=0\nMODBUS_DEBUG_LEVEL=0\nMODBUS_MAP_COIL_READ=0\nMODBUS_MAP_COIL_WRITE=0\nMODBUS_MAP_INPUT=0\nMODBUS_MAP_HOLDING=0\nMODBUS_MAP_REGISTER_READ=0\nMODBUS_MAP_REGISTER_WRITE=0\n_\/FILE-com_params.txt\n_FILE-rung_1.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=0\n#NEXTRUNG=-1\n1-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/1\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-60\/2\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/1\n0-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 9-1-0\/0 , 99-0-0\/0 , 10-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/2 , 9-0-0\/0 , 50-0-60\/2\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 53-1-0\/1\n_\/FILE-rung_1.csv\n_FILE-sequential.csv\n#VER=1.0\n_\/FILE-sequential.csv\n_FILE-modbusioconf.csv\n#VER=1.0\n_\/FILE-modbusioconf.csv\n_FILE-general.txt\nPERIODIC_REFRESH=50\nSIZE_NBR_RUNGS=100\nSIZE_NBR_BITS=20\nSIZE_NBR_WORDS=20\nSIZE_NBR_TIMERS=10\nSIZE_NBR_MONOSTABLES=10\nSIZE_NBR_COUNTERS=10\nSIZE_NBR_TIMERS_IEC=10\nSIZE_NBR_PHYS_INPUTS=15\nSIZE_NBR_PHYS_OUTPUTS=15\nSIZE_NBR_ARITHM_EXPR=100\nSIZE_NBR_SECTIONS=10\nSIZE_NBR_SYMBOLS=160\n_\/FILE-general.txt\n_FILE-counters.csv\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n_\/FILE-counters.csv\n_FILE-sections.csv\n#VER=1.0\n#NAME000=Prog1\n000,0,-1,0,1,0\n_\/FILE-sections.csv\n_FILE-ioconf.csv\n#VER=1.0\n_\/FILE-ioconf.csv\n_FILE-arithmetic_expressions.csv\n#VER=2.0\n_\/FILE-arithmetic_expressions.csv\n_FILE-symbols.csv\n#VER=1.0\n%B0,step_1,\n%B1,step_2,\n%B2,%B2,\n%B3,%B3,\n%B4,%B4,\n%B5,%B5,\n%B6,%B6,\n%B7,%B7,\n%B8,%B8,\n%B9,%B9,\n%M0,cmd1_hold,\n%M1,cmd2-hold,\n%M2,cmd3-hold,\n%W0,%W0,\n%W1,%W1,\n%W2,%W2,\n%W3,%W3,\n%W4,%W4,\n%W5,%W5,\n%W6,%W6,\n%W7,%W7,\n%W8,%W8,\n%W9,%W9,\n%W10,%W10,\n%I0,touchoff,\n%I1,mdi_mode,\n%I2,in_posit.,\n%I3,%I3,\n%I4,%I4,\n%I5,%I5,\n%I6,%I6,\n%I7,%I7,\n%I8,%I8,\n%I9,%I9,\n%I10,%I10,\n%I11,%I11,\n%I12,%I12,\n%I13,%I13,\n%I14,%I14,\n%Q0,MDI_cmd1,\n%Q1,MDI_cmd2,\n%Q2,MDI_cmd3,\n%Q3,%Q3,\n%Q4,%Q4,\n%Q5,%Q5,\n%Q6,%Q6,\n%Q7,%Q7,\n%Q8,%Q8,\n%Q9,%Q9,\n%Q10,%Q10,\n%Q11,%Q11,\n%Q12,%Q12,\n%Q13,%Q13,\n%Q14,%Q14,\n%B10,%B10,\n%B11,%B11,\n%B12,%B12,\n%B13,%B13,\n%B14,%B14,\n%B15,%B15,\n%B16,%B16,\n%B17,%B17,\n%B18,%B18,\n%B19,%B19,\n%W11,%W11,\n%W12,%W12,\n%W13,%W13,\n%W14,%W14,\n%W15,%W15,\n%W16,%W16,\n%W17,%W17,\n%W18,%W18,\n%W19,%W19,\n%IW0,%IW0,\n%IW1,%IW1,\n%IW2,%IW2,\n%IW3,%IW3,\n%IW4,%IW4,\n%IW5,%IW5,\n%IW6,%IW6,\n%IW7,%IW7,\n%IW8,%IW8,\n%IW9,%IW9,\n%QW0,%QW0,\n%QW1,%QW1,\n%QW2,%QW2,\n%QW3,%QW3,\n%QW4,%QW4,\n%QW5,%QW5,\n%QW6,%QW6,\n%QW7,%QW7,\n%QW8,%QW8,\n%QW9,%QW9,\n%IF0,%IF0,\n%IF1,%IF1,\n%IF2,%IF2,\n%IF3,%IF3,\n%IF4,%IF4,\n%IF5,%IF5,\n%IF6,%IF6,\n%IF7,%IF7,\n%IF8,%IF8,\n%IF9,%IF9,\n%QF0,%QF0,\n%QF1,%QF1,\n%QF2,%QF2,\n%QF3,%QF3,\n%QF4,%QF4,\n%QF5,%QF5,\n%QF6,%QF6,\n%QF7,%QF7,\n%QF8,%QF8,\n%QF9,%QF9,\n%T0,cmd3-wait,\n%T1,%T1,Old Timer\n%T2,%T2,Old Timer\n%T3,%T3,Old Timer\n%T4,%T4,Old Timer\n%T5,%T5,Old Timer\n%T6,%T6,Old Timer\n%T7,%T7,Old Timer\n%T8,%T8,Old Timer\n%T9,%T9,Old Timer\n%TM0,%TM0,New Timer\n%TM1,%TM1,New Timer\n%TM2,%TM2,New Timer\n%TM3,%TM3,New Timer\n%TM4,%TM4,New Timer\n%TM5,%TM5,New Timer\n%TM6,%TM6,New Timer\n%TM7,%TM7,New Timer\n%TM8,%TM8,New Timer\n%TM9,%TM9,New Timer\n%M3,%M3,One-shot\n%M4,%M4,One-shot\n%M5,%M5,One-shot\n%M6,%M6,One-shot\n%M7,%M7,One-shot\n%M8,%M8,One-shot\n%M9,%M9,One-shot\n%C0,%C0,Counter\n%C1,%C1,Counter\n%C2,%C2,Counter\n%C3,%C3,Counter\n%C4,%C4,Counter\n%C5,%C5,Counter\n%C6,%C6,Counter\n%C7,%C7,Counter\n%C8,%C8,Counter\n%C9,%C9,Counter\n%E0,%E0,Error Flag Bit\n%E1,%E1,Error Flag Bit\n%E2,%E2,Error Flag Bit\n%E3,%E3,Error Flag Bit\n%E4,%E4,Error Flag Bit\n%E5,%E5,Error Flag Bit\n%E6,%E6,Error Flag Bit\n%E7,%E7,Error Flag Bit\n%E8,%E8,Error Flag Bit\n%E9,%E9,Error Flag Bit\n_\/FILE-symbols.csv\n_FILE-monostables.csv\n2,5\n2,5\n2,5\n2,5\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-monostables.csv\n_FILE-timers.csv\n2,5\n1,0\n2,5\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n1,0\n_\/FILE-timers.csv\n_FILE-rung_0.csv\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=0\n#NEXTRUNG=1\n1-0-50\/0 , 1-0-50\/1 , 2-0-0\/0 , 2-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 52-0-0\/0\n1-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/0\n0-0-0\/0 , 0-0-50\/2 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/1\n1-0-0\/0 , 3-0-50\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 53-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 52-1-0\/1\n_\/FILE-rung_0.csv\n_\/FILES_CLASSICLADDER\n","returncode":0,"stderr":"","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"25c9fc6a67943a4bd747a31de047a5115be4b555","subject":"Initial revision.","message":"Initial revision.\n","repos":"bmwiedemann\/linuxcnc-mirror,mhaberler\/machinekit,yishinli\/emc2,Cid427\/machinekit,ikcalB\/linuxcnc-mirror,unseenlaser\/machinekit,kinsamanka\/machinekit,araisrobo\/machinekit,araisrobo\/machinekit,RunningLight\/machinekit,Cid427\/machinekit,bobvanderlinden\/machinekit,RunningLight\/machinekit,bmwiedemann\/linuxcnc-mirror,unseenlaser\/linuxcnc,ArcEye\/machinekit-testing,jaguarcat79\/ILC-with-LinuxCNC,EqAfrica\/machinekit,kinsamanka\/machinekit,unseenlaser\/machinekit,aschiffler\/linuxcnc,ArcEye\/machinekit-testing,aschiffler\/linuxcnc,cdsteinkuehler\/MachineKit,Cid427\/machinekit,unseenlaser\/machinekit,EqAfrica\/machinekit,ianmcmahon\/linuxcnc-mirror,ArcEye\/MK-Qt5,cnc-club\/linuxcnc,mhaberler\/machinekit,bobvanderlinden\/machinekit,aschiffler\/linuxcnc,narogon\/linuxcnc,ikcalB\/linuxcnc-mirror,mhaberler\/machinekit,kinsamanka\/machinekit,RunningLight\/machinekit,cnc-club\/linuxcnc,cnc-club\/linuxcnc,araisrobo\/machinekit,ikcalB\/linuxcnc-mirror,ArcEye\/MK-Qt5,RunningLight\/machinekit,yishinli\/emc2,unseenlaser\/machinekit,RunningLight\/machinekit,Cid427\/machinekit,ArcEye\/MK-Qt5,ianmcmahon\/linuxcnc-mirror,yishinli\/emc2,cdsteinkuehler\/linuxcnc,mhaberler\/machinekit,mhaberler\/machinekit,unseenlaser\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,kinsamanka\/machinekit,bmwiedemann\/linuxcnc-mirror,ikcalB\/linuxcnc-mirror,yishinli\/emc2,cdsteinkuehler\/linuxcnc,EqAfrica\/machinekit,bmwiedemann\/linuxcnc-mirror,strahlex\/machinekit,cnc-club\/linuxcnc,aschiffler\/linuxcnc,ArcEye\/machinekit-testing,ianmcmahon\/linuxcnc-mirror,araisrobo\/linuxcnc,ianmcmahon\/linuxcnc-mirror,bobvanderlinden\/machinekit,ikcalB\/linuxcnc-mirror,mhaberler\/machinekit,cnc-club\/linuxcnc,cdsteinkuehler\/linuxcnc,unseenlaser\/linuxcnc,EqAfrica\/machinekit,bmwiedemann\/linuxcnc-mirror,cdsteinkuehler\/linuxcnc,bobvanderlinden\/machinekit,bobvanderlinden\/machinekit,ArcEye\/MK-Qt5,araisrobo\/machinekit,kinsamanka\/machinekit,bobvanderlinden\/machinekit,unseenlaser\/linuxcnc,araisrobo\/linuxcnc,kinsamanka\/machinekit,EqAfrica\/machinekit,RunningLight\/machinekit,unseenlaser\/machinekit,Cid427\/machinekit,ianmcmahon\/linuxcnc-mirror,EqAfrica\/machinekit,strahlex\/machinekit,araisrobo\/machinekit,ArcEye\/machinekit-testing,EqAfrica\/machinekit,RunningLight\/machinekit,strahlex\/machinekit,araisrobo\/linuxcnc,strahlex\/machinekit,ianmcmahon\/linuxcnc-mirror,cdsteinkuehler\/MachineKit,aschiffler\/linuxcnc,mhaberler\/machinekit,bobvanderlinden\/machinekit,EqAfrica\/machinekit,ianmcmahon\/linuxcnc-mirror,ArcEye\/MK-Qt5,cdsteinkuehler\/linuxcnc,cdsteinkuehler\/MachineKit,unseenlaser\/machinekit,araisrobo\/linuxcnc,araisrobo\/machinekit,mhaberler\/machinekit,unseenlaser\/linuxcnc,Cid427\/machinekit,cnc-club\/linuxcnc,araisrobo\/machinekit,ArcEye\/machinekit-testing,narogon\/linuxcnc,cdsteinkuehler\/MachineKit,araisrobo\/machinekit,Cid427\/machinekit,ikcalB\/linuxcnc-mirror,unseenlaser\/machinekit,narogon\/linuxcnc,ikcalB\/linuxcnc-mirror,narogon\/linuxcnc,strahlex\/machinekit,araisrobo\/linuxcnc,kinsamanka\/machinekit,bmwiedemann\/linuxcnc-mirror,ArcEye\/MK-Qt5,bobvanderlinden\/machinekit,cdsteinkuehler\/MachineKit,Cid427\/machinekit,ArcEye\/MK-Qt5,RunningLight\/machinekit,jaguarcat79\/ILC-with-LinuxCNC,narogon\/linuxcnc,ArcEye\/MK-Qt5,strahlex\/machinekit,ArcEye\/machinekit-testing,jaguarcat79\/ILC-with-LinuxCNC,unseenlaser\/linuxcnc,ArcEye\/machinekit-testing,cnc-club\/linuxcnc,cdsteinkuehler\/MachineKit,strahlex\/machinekit,cdsteinkuehler\/linuxcnc,jaguarcat79\/ILC-with-LinuxCNC,araisrobo\/machinekit,ArcEye\/machinekit-testing,kinsamanka\/machinekit,bmwiedemann\/linuxcnc-mirror","old_file":"src\/hal\/classicladder\/projects_examples\/example2.clp","new_file":"src\/hal\/classicladder\/projects_examples\/example2.clp","new_contents":"_FILES_CLASSICLADDER\n_FILE-monostables.csv\n; Monostables :\n; Base(see classicladder.h),Preset\n1,3\n1,10\n1,10\n1,10\n1,10\n1,10\n1,10\n1,10\n_\/FILE-monostables.csv\n_FILE-arithmetic_expressions.csv\n; Arithmetic expressions :\n; Compare or Operate ones\n@200\/0@:=@200\/0@+1\n@200\/0@>10\n@200\/0@:=0\n@200\/1@:=@200\/1@+1\n@200\/2@:=@200\/2@+2\n@200\/2@-@200\/1@>50\n@200\/1@:=@200\/1@+100\n@200\/1@>1000\n@200\/1@:=@200\/1@\/10\n@200\/2@:=@200\/2@\/5\n@200\/1@>=200\n@200\/1@<=300\n@200\/3@:=MINI(@200\/1@,@200\/2@)\n@200\/4@:=@200\/2@|$400\n@200\/4@&$80=$80\n@200\/4@&$40=$40\n@200\/4@&$20=$20\n@200\/4@&$10=$10\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n_\/FILE-arithmetic_expressions.csv\n_FILE-rung_3.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=\n#COMMENT=Start pump for at least 10s\n#PREVRUNG=2\n#NEXTRUNG=4\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n1-0-50\/12 , 9-0-0\/0 , 99-0-0\/3 , 11-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 2-0-0\/10 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/7\n0-0-0\/0 , 0-1-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 9-1-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 0-1-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n_\/FILE-rung_3.csv\n_FILE-rung_6.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=5\n#NEXTRUNG=0\n9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/12\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-1-0\/0 , 99-0-0\/0 , 60-0-0\/13\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/14 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/11\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/15 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/12\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/16 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/13\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/17 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/14\n_\/FILE-rung_6.csv\n_FILE-rung_0.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=START\n#COMMENT=Big one\n#PREVRUNG=0\n#NEXTRUNG=1\n1-0-50\/1 , 2-0-50\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 10-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/0\n1-0-0\/1 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/1\n1-0-50\/2 , 2-1-50\/3 , 2-0-50\/4 , 3-0-50\/5 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 52-0-0\/2\n0-0-0\/0 , 0-0-0\/0 , 1-1-50\/6 , 4-0-50\/5 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 53-0-0\/2\n2-0-20\/0 , 9-0-0\/0 , 99-0-0\/0 , 10-0-0\/1 , 9-0-0\/0 , 99-0-0\/0 , 11-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/3\n0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 54-1-0\/2\n_\/FILE-rung_0.csv\n_FILE-sections.csv\n; Sections\n#VER=1.0\n#NAME000=Prog1\n000,0,-1,0,6,0\n_\/FILE-sections.csv\n_FILE-rung_2.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=LBL6\n#COMMENT=Very Fast...\n#PREVRUNG=1\n#NEXTRUNG=3\n1-0-50\/10 , 1-0-50\/11 , 2-0-0\/3 , 99-0-0\/0 , 10-0-0\/2 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/5\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/6\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n_\/FILE-rung_2.csv\n_FILE-timers.csv\n; Timers :\n; Base(see classicladder.h),Preset\n0,2\n1,5\n2,5\n1,10\n1,10\n1,10\n1,10\n1,10\n_\/FILE-timers.csv\n_FILE-rung_1.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=LBL4\n#COMMENT=Copy only if not (J)umping\n#PREVRUNG=0\n#NEXTRUNG=2\n1-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/8\n2-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-0\/9\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n_\/FILE-rung_1.csv\n_FILE-rung_4.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=\n#COMMENT=Test if sensor is unstable\n#PREVRUNG=3\n#NEXTRUNG=5\n3-0-50\/14 , 1-0-0\/14 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/0\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/1 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/8\n2-0-0\/14 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/2\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0\n_\/FILE-rung_4.csv\n_FILE-rung_5.csv\n; Rung :\n; all the blocks with the following format :\n; type (see classicladder.h) - ConnectedWithTop - VarType (see classicladder.h) \/ VarOffset\n#VER=2.0\n#LABEL=\n#COMMENT=\n#PREVRUNG=4\n#NEXTRUNG=6\n9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/3\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-1-0\/0 , 99-0-0\/0 , 60-0-0\/4\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/5 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/6\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/10 , 99-0-0\/0 , 99-0-0\/10 , 20-0-0\/11 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 50-0-60\/10\n99-0-0\/0 , 99-0-0\/0 , 20-0-0\/7 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 9-0-0\/0 , 99-0-0\/0 , 99-0-0\/0 , 60-0-0\/8\n0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 0-0-0\/0 , 99-1-0\/0 , 99-0-0\/0 , 60-0-0\/9\n_\/FILE-rung_5.csv\n_\/FILES_CLASSICLADDER\n","old_contents":"","returncode":1,"stderr":"error: pathspec 'src\/hal\/classicladder\/projects_examples\/example2.clp' did not match any file(s) known to git\n","license":"lgpl-2.1","lang":"CLIPS"} {"commit":"9cfd1fb74c582a52c4ddc4272f33b04a90b02027","subject":"Changed the goofy comment","message":"Changed the goofy comment\n","repos":"grettke\/scribfile","old_file":"scribfile\/sample.clp","new_file":"scribfile\/sample.clp","new_contents":"","old_contents":"","returncode":128,"stderr":"remote: Support for password authentication was removed on August 13, 2021.\nremote: Please see https:\/\/docs.github.com\/en\/get-started\/getting-started-with-git\/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.\nfatal: Authentication failed for 'https:\/\/github.com\/grettke\/scribfile.git\/'\n","license":"bsd-3-clause","lang":"CLIPS"} {"commit":"926e44c6985432042c18426b9179d50b21ef1717","subject":"added Listing individuals properties by spouse","message":"added Listing individuals properties by spouse\n","repos":"The4Ms\/family-knowledgebase","old_file":"task 5\/PersonDisplay.clp","new_file":"task 5\/PersonDisplay.clp","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'task' did not match any file(s) known to git\nerror: pathspec '5\/PersonDisplay.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"fff824d9a9d3b8267aa7ed40e8056f09354fafc6","subject":"removed unneeded values when matching Persons in the rules in task 1","message":"removed unneeded values when matching Persons in the rules in task 1\n","repos":"The4Ms\/family-knowledgebase","old_file":"task 1\/rules.clp","new_file":"task 1\/rules.clp","new_contents":"","old_contents":"","returncode":1,"stderr":"error: pathspec 'task' did not match any file(s) known to git\nerror: pathspec '1\/rules.clp' did not match any file(s) known to git\n","license":"mit","lang":"CLIPS"} {"commit":"fef8b0e7754b8fb04be76e18868f16c364ac7fe9","subject":"Added two new modules to Loader.clp","message":"Added two new modules to Loader.clp\n\nThe two modules are wavefront-scheduling-identify and\nwavefront-scheduling-pathing.\n\nThe first module (wavefront-scheduling-identify) is responsible for identifying\nwhich blocks on the wavefront can be scheduled into. A block is considered a\nvalid target for scheduling into if it only has one successor. Blocks that have\nmore than one successor or no successors are not allowed.\n\nThe second module (wavefront-scheduling-pathing) is responsible for figuring\nout the \"range\" of blocks that follow the target block which can be scheduled\nout of and into the target block. The code used to identify this was rewritten\nto not use the (return) command because that command removes an element from\nthe focus stack if modules are used. While the pipeline manager is robust, it\nwill be be able to continue execution if the focus stack has the pipeline\nmodule removed from being executed next.\n\nI also modified some of the internal facts generated by the modules to use\nmessages instead to allow me to use the modify command instead of retract and\nassert. This reduces the amount of typing I have to do and, according to the\ndocumentation, the memory that represents the original template is reused and\nmodified which saves space.\n","repos":"DrItanium\/durandal,DrItanium\/durandal","old_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_file":"lib\/durandal\/passes\/wavefront-scheduling\/scheduler\/Loader.clp","new_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-init\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-identify\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-pathing\n (import core ?ALL)\n (import llvm ?ALL)\n (import types ?ALL)\n (import pipeline ?ALL)\n (import indirect ?ALL)\n (import rampancy ?ALL)\n (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-code::macro-expand\n ?msg <- (message (from pipeline) \n (to wavefront-scheduling-code)\n (action initial-fact))\n ?p <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?msg)\n (modify-instance ?p (passes \n wavefront-scheduling-init\n wavefront-scheduling-identify\n wavefront-scheduling-pathing\n ;TODO: add more modules\n $?passes)))\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","old_contents":";Copyright (c) 2012, Joshua Scoggins \n;All rights reserved.\n;\n;Redistribution and use in source and binary forms, with or without\n;modification, are permitted provided that the following conditions are met:\n; * Redistributions of source code must retain the above copyright\n; notice, this list of conditions and the following disclaimer.\n; * Redistributions in binary form must reproduce the above copyright\n; notice, this list of conditions and the following disclaimer in the\n; documentation and\/or other materials provided with the distribution.\n; * Neither the name of Joshua Scoggins nor the\n; names of its contributors may be used to endorse or promote products\n; derived from this software without specific prior written permission.\n;\n;THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n;ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n;WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n;DISCLAIMED. IN NO EVENT SHALL Joshua Scoggins BE LIABLE FOR ANY\n;DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n;(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n;ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n;SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n;------------------------------------------------------------------------------\n(defmodule wavefront-scheduling-init\n\t\t\t (import core ?ALL)\n\t\t\t (import llvm ?ALL)\n\t\t\t (import types ?ALL)\n\t\t\t (import pipeline ?ALL)\n\t\t\t (import indirect ?ALL)\n\t\t\t (import rampancy ?ALL)\n\t\t\t (import MAIN ?ALL))\n;------------------------------------------------------------------------------\n(defrule wavefront-scheduling-code::macro-expand\n ?msg <- (message (from pipeline) \n (to wavefront-scheduling-code)\n (action initial-fact))\n ?p <- (object (is-a pass-description) (passes $?passes))\n =>\n (retract ?msg)\n (modify-instance ?p (passes \n wavefront-scheduling-init\n ;TODO: add more modules\n $?passes)))\n;------------------------------------------------------------------------------\n(load* \"Stages\/Wavefront\/WavefrontInitialization.clp\")\n(load* \"Stages\/Wavefront\/ValidBlockIdentification.clp\")\n(load* \"Stages\/Wavefront\/WavefrontScheduling.clp\")\n(load* \"Stages\/Wavefront\/WavefrontPropagation.clp\")\n(load* \"Stages\/Wavefront\/WavefrontAdvancement.clp\")\n(load* \"Stages\/Wavefront\/WavefrontDependencyUpdate.clp\")\n(load* \"Stages\/Wavefront\/WavefrontOperandRename.clp\")\n(load* \"Stages\/Wavefront\/WavefrontInstructionMerging.clp\")\n(load* \"Stages\/Wavefront\/WavefrontBlockReopen.clp\")\n","returncode":0,"stderr":"","license":"bsd-3-clause","lang":"CLIPS"}