Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle logic rules #1

Open
meneguzzi opened this issue Jul 27, 2016 · 10 comments
Open

Handle logic rules #1

meneguzzi opened this issue Jul 27, 2016 · 10 comments
Assignees

Comments

@meneguzzi
Copy link
Contributor

meneguzzi commented Jul 27, 2016

As a feature request, I'd like for the planner to handle logic rules, as shown in the healthcare domain.

@Maumagnaguagno
Copy link
Owner

Maumagnaguagno commented Jul 27, 2016

Some details about the healthcare domain that we need to consider:

  • Some axioms are redefined to an equal (null) or different description.
    • If each definition adds one possible case the evaluation is unnecessary for repeated cases.
  • Some axioms and preconditions contain a complex expression.
    • Today only conjunctions are supported, disjunctions are other branches of the search.
  • More than one problem defined in the problem file.
    • Can it be broken or it has an special meaning?

It will take some time to solve each detail for the automatic converter to handle it.

Some parts of the domain are confusing:

  • The operator suspend is redefined, is it correct?
  • Why is ?t between parentheses in some methods (:method (achieveGoal g4 ?gi (?t) c) ...

@meneguzzi
Copy link
Contributor Author

  • The complex expressions are useful, so I'd prefer if they actually worked. You can probably compile them away when you translate things to ruby. If you translate the condition into a disjunctive normal form, you could change Hypertension.applicable? to process lists of lists of the disjunctions.
  • I see a problem now with suspend, there should be one suspend for goals and another for commitments, thanks for pointing this out
  • the ?t in parenthesis is to enforce it to the a list (so parameters now can be lists too)

@Maumagnaguagno Maumagnaguagno self-assigned this Jul 27, 2016
@Maumagnaguagno
Copy link
Owner

Maumagnaguagno commented Jul 27, 2016

I already started to model expressions to replace applicable?.
The goal is to eventually support and or not call forall exists assign in the intermediate representation to be able to convert the parsed data as needed.

Unification of lists is currently not supported, every term is internally represented as a String.

UPDATE:

  • Since commit 58eb7a2 operator preconditions are handled by an AST evaluator (compute).
  • Since commit 278e4f4 operator preconditions are evaluated by Ruby logical connectors.
  • Since commit db737ad operator preconditions and axioms may contain axioms.

@Maumagnaguagno
Copy link
Owner

Now we lack the DNF, call (used 30 times for equality tests) and assign (used 2 times).
I will focus on supporting call and then DNF.

Questions:

  • I am not familiar with JSHOP assignment scope, is assign really required, couldn't you just reuse the variables?
  • I also did not found eqGSCP definition.
(:method (achieveGoal ?g ?gi ?a ?gv)
  genericEnticeToAchieve
  (
    (activeG ?g ?gi ?gv)
    (goal ?g ?gi ?a)
    (commitment ?c ?ci ?a ?d)
    (assign ?cv ?gv)
    (eqGSCP ?g ?gv ?c ?cv)
    (goal ?g2 ?gi2 ?a)
    (assign ?gv2 ?cv)
    (eqGSCQ ?g2 ?gv2 ?c ?cv)
    (call != ?g ?g2)
  )
  (
    (entice ?g ?gi ?gv ?c ?ci ?cv ?a ?d)
    (detach ?c ?ci ?cv)
    (deliver ?g2 ?gi2 ?gv2 ?c ?ci ?cv ?a ?d)
    (achieveGoal ?g2 ?gi2 ?gv2 ?a)
  )
)

@meneguzzi
Copy link
Contributor Author

I don't seem to use assign in my code for the healthcare scenario, so I think it's OK not to have it implemented.

As for the eqGSCP, it seems this is missing there, but the definition of all the axioms related to reasoning patterns are as follows

;==========================================================
  ;Equalities between conditions on commitments and on goals
  ;==========================================================
  ; True if the success condition of ?g matches the antecedent of ?c 
  ;(?gv and ?cv will unify with the specific instance of ?g and ?c that match this)
  (:- (eqGSCP ?g ?gv ?c ?cv) (and (imply (s ?g ?gi ?gv) (p ?c ?ci ?cv)) (imply (p ?c ?ci ?cv) (s ?g ?gi ?gv)) ) ) ; Basically a logical equivalence <-> 
      ;TODO make sure that the variables ?gv and ?cv get instantiated
  ; True of the success condition of ?g matches the consequent of ?c
  (:- (eqGSCQ ?g ?gv ?c ?cv) (and (imply (s ?g ?gi ?gv) (q ?c ?ci ?cv)) (imply (q ?c ?ci ?cv) (s ?g ?gi ?gv)) ) ) ; Basically a logical equivalence <->
  ; True of the the antecedent of commitment ?c1 matches the consequent of commitment ?c2 (so they are reciprocal)
  (:- (eqCPCQ ?c1 ?cv1 ?c2 ?cv2) (and (imply (p ?c1 ?ci1 ?cv1) (q ?c2 ?ci2 ?cv2)) (imply (q ?c2 ?ci2 ?cv2) (p ?c1 ?ci1 ?cv1)) ) ) ; Basically a logical equivalence <->

@Maumagnaguagno
Copy link
Owner

Maumagnaguagno commented Sep 18, 2016

There are assign statements here

@meneguzzi
Copy link
Contributor Author

meneguzzi commented Sep 20, 2016

I can live without them, those were just testing code.

@meneguzzi
Copy link
Contributor Author

meneguzzi commented Oct 11, 2016

@Maumagnaguagno, I was trying to parse my domain again and find the replications, but one parse error you seem to report is a "redefinition" of the axioms. However, when you have axioms for the p and q of different commitments, you are talking about different possibilities for the variables in the axiom (like when you have multiple rules in Prolog).
For example, the code from here
to here, must work

We need to support this "redefinition", much in the same way we can have different methods for the same task. While I agree that redefining actions may create ambiguity, there is no such problem for the axioms.

@Maumagnaguagno
Copy link
Owner

Yes, I am working on it.

@Maumagnaguagno
Copy link
Owner

Maumagnaguagno commented Oct 14, 2016

Let's try to deal with the constants first then. Check the boxes here when you are finished:

  • Handling constants in axiom declarations
  • Support calls/axioms/attachments in methods
  • Propagate ground lists
  • Unify list terms
  • Support disjunctions (DNF) in methods (complex unification)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants