Re: JESS: question on slot specific

2011-06-12 Thread Ernest Friedman-Hill
Argh, sorry, I used "no-loop" in my example, but I meant "slot- 
specific."



On Jun 12, 2011, at 11:12 PM, Ernest Friedman-Hill wrote:

Oooh, that's a bad example; I'll have to fix the manual. If you type  
(watch all) before your code, you'll see that the rule actually  
fires twice; once when B is nil, and once when it's 3. But the  
second time it fires, the "modify" has no effect, since the slot is  
being modified to contain the value it already contains. Try this  
rule instead, both with and without no-loop (and use (watch all) so  
you can see what's going on:)


(defrule R (declare (no-loop TRUE))
 ?d <- (D (A 1))
 =>
 (modify ?d (B (+ ?d.B 1

Note that your initial assert needs to have a number in the B slot,  
or you'll get an error.




On Jun 12, 2011, at 8:08 PM, Felix Chan wrote:


Hi,

I have been trying to understand the slot-specific functionality  
which

is described in the JESS manual as follows:

---
6.18. The 'slot-specific' declaration for deftemplates
Deftemplate definitions can now include a "declare" section just as
defrules can. There are several different properties that can be
declared. One is "slot-specific". A template with this declaration
will be matched in a special way: if a fact, created from such a
template, which matches the left-hand-side of a rule is modified, the
result depends on whether the modified slot is named in the pattern
used to match the fact. As an example, consider the following:

Jess> (deftemplate D (declare (slot-specific TRUE)) (slot A) (slot  
B))

Jess> (defrule R
?d <- (D (A 1))
=>
(modify ?d (B 3)))
Without the "slot-specific" declaration, this rule would enter an
endless loop, because it modifies a fact matched on the LHS in such a
way that the modified fact will still match. With the declaration, it
can simply fire once. This behavior is actually what many new users
expect as the default; the technical term for it is refraction.
--

I tried the following without the slot-specific declaration,  
expecting

an infinite loop to occur:

(reset)
(deftemplate D (slot A) (slot B))

(defrule R
?d <- (D (A 1))
=>
(modify ?d (B 3)))

(bind ?f (assert (D (A 1
(facts)
(run)
(facts)

But I got the following outcome with no infinite loop:
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B nil))
For a total of 2 facts in module MAIN.
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B 3))
For a total of 2 facts in module MAIN.

It seems slot-specific makes no difference in the outcome. I  
suspect I

am missing a key concept here. Could someone explain?

Thanks.

Felix



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com 
'

in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov 
.




-
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com








To unsubscribe, send the words 'unsubscribe jess-users  
y...@address.com'

in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov 
.




-
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com








To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




Re: JESS: question on slot specific

2011-06-12 Thread Ernest Friedman-Hill
Oooh, that's a bad example; I'll have to fix the manual. If you type  
(watch all) before your code, you'll see that the rule actually fires  
twice; once when B is nil, and once when it's 3. But the second time  
it fires, the "modify" has no effect, since the slot is being modified  
to contain the value it already contains. Try this rule instead, both  
with and without no-loop (and use (watch all) so you can see what's  
going on:)


(defrule R (declare (no-loop TRUE))
  ?d <- (D (A 1))
  =>
  (modify ?d (B (+ ?d.B 1

Note that your initial assert needs to have a number in the B slot, or  
you'll get an error.




On Jun 12, 2011, at 8:08 PM, Felix Chan wrote:


Hi,

I have been trying to understand the slot-specific functionality which
is described in the JESS manual as follows:

---
6.18. The 'slot-specific' declaration for deftemplates
Deftemplate definitions can now include a "declare" section just as
defrules can. There are several different properties that can be
declared. One is "slot-specific". A template with this declaration
will be matched in a special way: if a fact, created from such a
template, which matches the left-hand-side of a rule is modified, the
result depends on whether the modified slot is named in the pattern
used to match the fact. As an example, consider the following:

Jess> (deftemplate D (declare (slot-specific TRUE)) (slot A) (slot B))
Jess> (defrule R
 ?d <- (D (A 1))
 =>
 (modify ?d (B 3)))
Without the "slot-specific" declaration, this rule would enter an
endless loop, because it modifies a fact matched on the LHS in such a
way that the modified fact will still match. With the declaration, it
can simply fire once. This behavior is actually what many new users
expect as the default; the technical term for it is refraction.
--

I tried the following without the slot-specific declaration, expecting
an infinite loop to occur:

(reset)
(deftemplate D (slot A) (slot B))

(defrule R
 ?d <- (D (A 1))
 =>
 (modify ?d (B 3)))

(bind ?f (assert (D (A 1
(facts)
(run)
(facts)

But I got the following outcome with no infinite loop:
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B nil))
For a total of 2 facts in module MAIN.
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B 3))
For a total of 2 facts in module MAIN.

It seems slot-specific makes no difference in the outcome. I suspect I
am missing a key concept here. Could someone explain?

Thanks.

Felix



To unsubscribe, send the words 'unsubscribe jess-users  
y...@address.com'

in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov 
.




-
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com








To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




JESS: question on slot specific

2011-06-12 Thread Felix Chan
Hi,

I have been trying to understand the slot-specific functionality which
is described in the JESS manual as follows:

---
6.18. The 'slot-specific' declaration for deftemplates
Deftemplate definitions can now include a "declare" section just as
defrules can. There are several different properties that can be
declared. One is "slot-specific". A template with this declaration
will be matched in a special way: if a fact, created from such a
template, which matches the left-hand-side of a rule is modified, the
result depends on whether the modified slot is named in the pattern
used to match the fact. As an example, consider the following:

Jess> (deftemplate D (declare (slot-specific TRUE)) (slot A) (slot B))
Jess> (defrule R
  ?d <- (D (A 1))
  =>
  (modify ?d (B 3)))
Without the "slot-specific" declaration, this rule would enter an
endless loop, because it modifies a fact matched on the LHS in such a
way that the modified fact will still match. With the declaration, it
can simply fire once. This behavior is actually what many new users
expect as the default; the technical term for it is refraction.
--

I tried the following without the slot-specific declaration, expecting
an infinite loop to occur:

(reset)
(deftemplate D (slot A) (slot B))

(defrule R
  ?d <- (D (A 1))
  =>
  (modify ?d (B 3)))

(bind ?f (assert (D (A 1
(facts)
(run)
(facts)

But I got the following outcome with no infinite loop:
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B nil))
For a total of 2 facts in module MAIN.
f-0   (MAIN::initial-fact)
f-1   (MAIN::D (A 1) (B 3))
For a total of 2 facts in module MAIN.

It seems slot-specific makes no difference in the outcome. I suspect I
am missing a key concept here. Could someone explain?

Thanks.

Felix



To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.




RE: JESS: On the Performance of Logical Retractions

2011-06-12 Thread John Everett
If truth maintenance is a central part of your architecture, I recommend
Building Problem Solvers, by Kenneth Forbus and Johan de Kleer.  It's on
Amazon:

http://www.amazon.com/Building-Problem-Solvers-Artificial-Intelligence/dp/02
62061570/ref=sr_1_1?ie=UTF8&qid=1307815663&sr=8-1

and you can find the source code for the truth maintenance systems described
in the book here:

http://www.qrg.northwestern.edu/BPS/readme.html

As part of my PhD work, I developed a reasoning system based on the LTRE, a
forward-chaining rule engine on top of a logic-based TMS that is described
in Building Problem Solvers. Coming from this background, I continually find
Jess to be a Swiss Army knife of capabilities. However, if the logical
conditional in Jess is not sufficient for your architecture, you'll probably
need to implement a separate TMS layer. The logic-based TMS, which does fast
(but incomplete) Boolean constraint propagation, provides a good balance
between expressivity and efficiency. 

The problem solver architectures presented in Building Problem Solvers use
the rule engine's rules to construct a problem-specific dependency network,
through which the TMS propagates truth values.  For example, the CyclePad
system

http://www.qrg.northwestern.edu/projects/NSF/Cyclepad/aboutcp.html

enables the user to assemble and analyze thermodynamic cycles from a palette
of devices (turbines, pumps, heaters, throttles, coolers, etc). Once the
user has completed the cycle design, CyclePad runs its knowledge base of
rules to generate a dependency network that captures the relationships among
the thermodynamic properties at the inlet and outlet of each device. The
user can choose the working fluid for the system, and this imposes further
logical dependencies. For example, water will condense at certain
combinations of pressure and temperature. The user analyzes the system by
making assumptions about thermodynamic properties that the system then
propagates through the dependency network.



-John



-Original Message-
From: Ernest Friedman-Hill [mailto:ejfr...@sandia.gov] 
Sent: Saturday, June 11, 2011 8:20 AM
To: jess-users@sandia.gov
Subject: Re: JESS: On the Performance of Logical Retractions


On Jun 11, 2011, at 6:11 AM, Oliya wrote:

>
> But still I have a question: what type of truth maintenance is 
> supported in Jess? Can you provide links to more information please.


The "logical" conditional element is the only form of truth  
maintenance in Jess. I thought you said you were already using it?


> 

Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com








To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.






To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.