mirror of
https://github.com/RAIRLab/Spectra.git
synced 2024-11-23 01:16:30 -05:00
TORA example
This commit is contained in:
parent
2624b0c411
commit
32e7a8fe4c
6 changed files with 88 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -23,3 +23,4 @@ planner.iml
|
||||||
.idea/libraries/Maven__us_bpsm_edn_java_0_5_0.xml
|
.idea/libraries/Maven__us_bpsm_edn_java_0_5_0.xml
|
||||||
target/*
|
target/*
|
||||||
|
|
||||||
|
*.fasl
|
||||||
|
|
|
@ -90,15 +90,15 @@
|
||||||
(defun setup-snark (&key (time-limit 5) (verbose nil))
|
(defun setup-snark (&key (time-limit 5) (verbose nil))
|
||||||
(snark:initialize :verbose verbose)
|
(snark:initialize :verbose verbose)
|
||||||
(if (not verbose) (snark-deverbose) )
|
(if (not verbose) (snark-deverbose) )
|
||||||
(temp-sorts)
|
(snark:run-time-limit 0.5)
|
||||||
(snark:run-time-limit 5)
|
|
||||||
(snark:assert-supported t)
|
(snark:assert-supported t)
|
||||||
(snark:assume-supported t)
|
(snark:assume-supported t)
|
||||||
(snark:prove-supported t)
|
(snark:prove-supported t)
|
||||||
(snark:use-resolution t)
|
(snark:use-hyperresolution t)
|
||||||
(snark:use-paramodulation t)
|
(snark:use-paramodulation t)
|
||||||
|
|
||||||
(snark:allow-skolem-symbols-in-answers t))
|
(snark::declare-code-for-lists)
|
||||||
|
(snark:allow-skolem-symbols-in-answers nil))
|
||||||
|
|
||||||
(defun row-formula (name))
|
(defun row-formula (name))
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,14 @@ public class Action {
|
||||||
|
|
||||||
public List<Variable> openVars() {
|
public List<Variable> openVars() {
|
||||||
|
|
||||||
return freeVariables;
|
Set<Variable> variables = Sets.newSet();
|
||||||
|
|
||||||
|
variables.addAll(freeVariables);
|
||||||
|
|
||||||
|
List<Variable> variablesList = CollectionUtils.newEmptyList();
|
||||||
|
|
||||||
|
variablesList.addAll(variables);
|
||||||
|
return variablesList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,18 @@ public class Sandbox {
|
||||||
|
|
||||||
public static void main(String[] args) throws com.naveensundarg.shadow.prover.utils.Reader.ParsingException {
|
public static void main(String[] args) throws com.naveensundarg.shadow.prover.utils.Reader.ParsingException {
|
||||||
|
|
||||||
List<PlanningProblem> planningProblemList = (PlanningProblem.readFromFile(Sandbox.class.getResourceAsStream("../problems/tora/sodacan.clj")));
|
List<PlanningProblem> planningProblemList = (PlanningProblem.readFromFile(Sandbox.class.getResourceAsStream("../problems/tora/attend.clj")));
|
||||||
|
|
||||||
Planner depthFirstPlanner = new DepthFirstPlanner();
|
Planner depthFirstPlanner = new DepthFirstPlanner();
|
||||||
|
|
||||||
PlanningProblem planningProblem = planningProblemList.stream().filter(problem -> problem.getName().equals("soda can challenge")).findFirst().get();
|
PlanningProblem planningProblem = planningProblemList.stream().filter(problem -> problem.getName().equals("soda can challenge 2")).findFirst().get();
|
||||||
|
|
||||||
|
|
||||||
depthFirstPlanner.plan(planningProblem.getBackground(), planningProblem.getActions(), planningProblem.getStart(), planningProblem.getGoal()).ifPresent(
|
depthFirstPlanner.plan(planningProblem.getBackground(), planningProblem.getActions(), planningProblem.getStart(), planningProblem.getGoal()).ifPresent(
|
||||||
System.out::println
|
y->{
|
||||||
|
|
||||||
|
System.out.println(y);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{:name "soda can challenge 2"
|
||||||
|
:background [ ;; Membership in a list
|
||||||
|
(forall [?u ?l]
|
||||||
|
(iff (member ?u ?l)
|
||||||
|
(exists [?v ?rest]
|
||||||
|
(and (= ?l (cons ?v ?rest))
|
||||||
|
(or (= ?u ?v)
|
||||||
|
(member ?u ?rest))))))
|
||||||
|
;; Empty list
|
||||||
|
(forall ?x (not (member ?x el)))
|
||||||
|
;; Removal clause 1
|
||||||
|
(forall [?item] (= (remove ?item el) el))
|
||||||
|
;; Removal clause 2
|
||||||
|
(forall [?item ?rest]
|
||||||
|
(= (remove ?item (cons ?item ?rest))
|
||||||
|
(remove ?item ?rest)))
|
||||||
|
;; Remove clause 3
|
||||||
|
(forall [?item ?head ?rest]
|
||||||
|
(if
|
||||||
|
(not (= ?head ?item))
|
||||||
|
(= (remove ?item (cons ?head ?rest))
|
||||||
|
(cons ?head (remove ?item ?rest)))))]
|
||||||
|
|
||||||
|
:start [(state (cons a (cons b (cons c el))))
|
||||||
|
(and (not (= a b))
|
||||||
|
(not (= b c))
|
||||||
|
(not (= c a))
|
||||||
|
(not (= a el))
|
||||||
|
(not (= b el))
|
||||||
|
(not (= c el)))]
|
||||||
|
|
||||||
|
:goal [(attend a)
|
||||||
|
(attend b)
|
||||||
|
(attend c)]
|
||||||
|
|
||||||
|
:actions [;; checkbehind an object
|
||||||
|
(define-action attend [?item]
|
||||||
|
{:preconditions [(member ?item ?list)
|
||||||
|
(state ?list)]
|
||||||
|
:additions [(attend ?item)
|
||||||
|
(state (remove ?item ?list))]
|
||||||
|
:deletions [(state ?list)]})]}
|
|
@ -0,0 +1,27 @@
|
||||||
|
{:name "soda can challenge 2"
|
||||||
|
:background [;; Checks if something is an element of a list
|
||||||
|
(forall [?thing ?w ?list] (iff (Elem ?thing ?list) (Elem ?thing (Cons ?w ?list))))
|
||||||
|
(forall [?thing] (Elem ?thing (Cons ?thing el)))
|
||||||
|
;; Removes an element from a list
|
||||||
|
(forall [?u ?l1 ?l2]
|
||||||
|
(if
|
||||||
|
(and
|
||||||
|
(not (Elem ?u ?l2))
|
||||||
|
(forall [?x]
|
||||||
|
(if
|
||||||
|
(Elem ?x ?l1)
|
||||||
|
(or (= ?x ?u) (Elem ?x ?l2)))))
|
||||||
|
(Removed ?u ?l1 ?l2)))]
|
||||||
|
|
||||||
|
:start [(Cons a (Cons b (Cons f el)))]
|
||||||
|
|
||||||
|
:goal [(Cons a el)
|
||||||
|
(Cons b el)
|
||||||
|
(Cons f el)]
|
||||||
|
|
||||||
|
:actions [;; Checkbehind an object
|
||||||
|
(define-action attend [?q ?l]
|
||||||
|
{:preconditions [(Elem ?q ?l)
|
||||||
|
(Removed ?q ?l ?l2)]
|
||||||
|
:additions [(Cons ?q el)]
|
||||||
|
:deletions []})]}
|
Loading…
Reference in a new issue