Skip to content

Commit

Permalink
Hooked in changes from ShadowProver and introduced grapevine domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-Rozek committed Nov 3, 2023
1 parent f6e1dc1 commit 48971ad
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/main/java/org/rairlab/planner/Operations.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.rairlab.planner.utils.Visualizer;
import org.rairlab.shadow.prover.core.Prover;
import org.rairlab.shadow.prover.core.SnarkWrapper;
import org.rairlab.shadow.prover.core.ccprovers.CognitiveCalculusProver;
import org.rairlab.shadow.prover.core.proof.Justification;
import org.rairlab.shadow.prover.representations.formula.BiConditional;
import org.rairlab.shadow.prover.representations.formula.Formula;
Expand Down Expand Up @@ -44,9 +44,7 @@ public static void reset(){
applyCache.clear();
}
static {
prover = SnarkWrapper.getInstance();


prover = new CognitiveCalculusProver();
}

public static synchronized Optional<Justification> proveCached(Set<Formula> assumptions, Formula goal) {
Expand Down Expand Up @@ -192,6 +190,7 @@ public static Optional<Set<Pair<State, Action>>> apply(Set<Formula> background,
// Apply binding to get grounded action and calculate the next state
// newState = (oldState - Deletions(a)) U Additions(a)
Action groundedAction = action.instantiate(binding);

State newState = State.initializeWith(Sets.union(
Sets.difference(state.getFormulae(), groundedAction.getDeletions()),
groundedAction.getAdditions()
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/org/rairlab/planner/State.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.rairlab.planner;

import org.rairlab.shadow.prover.core.Prover;
import org.rairlab.shadow.prover.core.SnarkWrapper;
import org.rairlab.shadow.prover.representations.formula.Formula;
import org.rairlab.shadow.prover.utils.CollectionUtils;
import org.rairlab.shadow.prover.utils.Reader;
Expand All @@ -14,7 +12,6 @@
public class State {

final Set<Formula> formulae;
private static final Prover prover = SnarkWrapper.getInstance();
static Formula FALSE;

static{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{:name "GrapeVine"
:background [
(agent a)
(agent b)
(agent c)
(room p1)
(room p2)
(not (= a b))
(not (= a c))
(not (= b c))
]
:actions [
(define-action left [?a] {
:preconditions [
(agent ?a) ; Type restriction
(at ?a p2)
]
:additions [
(at ?a p1)
(not (at ?a p2))
]
:deletions [
(at ?a p2)
(not (at ?a p1))
]
})


(define-action right [?a] {
:preconditions [
(agent ?a) ; Type restriction
(at ?a p1)
]
:additions [
(at ?a p2)
(not (at ?a p1))
]
:deletions [
(at ?a p1)
(not (at ?a p2))
]
})

(define-action share-both [?a1 ?a2 ?a3 ?r] {
:preconditions [
; Type restrictions
(agent ?a1)
(agent ?a2)
(agent ?a3)
(room ?r)
; Precondition
(at ?a1 ?r)
(at ?a2 ?r)
(at ?a3 ?r)
(not (= ?a1 ?a2))
(not (= ?a1 ?a3))
(not (= ?a2 ?a3))
]
:additions [
(Believes! ?a2 (the ?a1))
(Believes ?a3 (the ?a1))
(Believes ?a1 (Believes! ?a2 (the ?a1)))
(Believes ?a1 (Believes! ?a3 (the ?a1)))
]
:deletions [
(not (Believes! ?a2 (the ?a1)))
(not (Believes! ?a3 (the ?a1)))
]
})

(define-action share-single [?a1 ?a2 ?a3 ?r] {
:preconditions [
; Type restrictions
(agent ?a1)
(agent ?a2)
(agent ?a3)
(room ?r)
; Precondition
(at ?a1 ?r)
(at ?a2 ?r)
(not (at ?a3 ?r))
(not (= ?a1 ?a2))
(not (= ?a1 ?a3))
(not (= ?a2 ?a3))
]
:additions [
(Believes! ?a2 (the ?a1))
(Believes! ?a1 (Believes! ?a2 (the ?a1)))
]
:deletions [
(not (Believes! ?a2 (the ?a1)))
]
})

]
:start [
; Locations
(at a p1)
(not (at a p2))
(at b p1)
(not (at b p2))
(at c p1)
(not (at c p2))

; Each agent has a secret
(Believes! a (the a))
(Believes! b (the b))
(Believes! c (the c))

; No one believes a's secret
(not (Believes! b (the a)))
(not (Believes! c (the a)))
]
:goal [
(Believes! b (the a))
(Believes! a (Believes! b (the a)))
(not (Believes! c (the a)))
]

}






0 comments on commit 48971ad

Please sign in to comment.