Question 3: This question is about semantic checking in the context of a planning application. Such plans are successfully solved by translating the plans to CSP instances (but here we are not concerned with the translation). The structure of a plan is given by the class dictionary called Plans. A plan consists of objects, predicates and operators. The objects part defines the objects that may be used elsewhere in the plan. The predicates part defines the predicate namess that may be used elsewhere in the plan. The operators part defines the operator names that may be used elsewhere in the plan and it gives the definies of the operators in terms of preconditions and effects. The class dictionary, program and input and output are given below. Find the UNKNOWNs. // class dictionary Plans import edu.neu.ccs.demeter.dj.*; import java.util.*; Plans = Set(Plan). Plan = "objects" Set(Obj) "predicates" Set(PredName) "operators" Set(Op) "initial" Set(PosLit) "goal" Set(Literal) "solution" Set(OpName). Literal : PosLit | NegLit common PredName Set(Obj). PosLit = . NegLit = "!". Op = OpName "preconditions" Set(Literal) "effects" Set(Literal). Obj = Ident. PredName = Ident. OpName = Ident. Set(S) ~ "(" {S} ")". Main = . PROGRAM ------------------------------------------------------------------- Main { public static void main(String args[]) throws Exception {{ Plans m = Plans.parse(System.in); ClassGraph cg1 = new ClassGraph(true, false); final ClassGraph cg = new ClassGraph(cg1, "from Plans bypassing -> *,tail,* to *"); cg.traverse(m, "from Plans to Plan", new Visitor(){ void before(Plan host) { host.process(cg); } }); System.out.println("done"); }} } Plan { {{ void process(ClassGraph cg){ System.out.println(" UNKNOWN1 "); cg.traverse(this ,"from Plan via ->*,objects,* to Obj", new Visitor(){ void before (Obj host) {System.out.println(host.get_ident());} }); System.out.println(" UNKNOWN2 "); cg.traverse(this ,"from Plan bypassing ->*,objects,* to Obj", new Visitor(){ void before (Obj host) {System.out.println(host.get_ident());} }); System.out.println(" UNKNOWN3 "); cg.traverse(this ,"from Plan via ->*,predicates,* to PredName", new Visitor(){ void before (PredName host) {System.out.println(host.get_ident());} }); System.out.println(" UNKNOWN4 "); cg.traverse(this ,"from Plan bypassing ->*,predicates,* to PredName", new Visitor(){ void before (PredName host) {System.out.println(host.get_ident());} }); System.out.println("The number of operators defined by the plan "); List l = cg.gather(this,"from Plan via ->*,operators,* to Op"); System.out.println(l.size()); } }} } INPUT ------------------------------------------------------------- ( objects (Battery1 Battery2 Cap Flashlight) predicates (On In) operators ( PlaceCap preconditions (!On(Cap Flashlight)) effects (On(Cap Flashlight)) RemoveCap preconditions (On(Cap Flashlight)) effects (!On(Cap Flashlight)) Insert1 preconditions (!On(Cap Flashlight) !In(Battery1 Flashlight)) effects (In(Battery1 Flashlight)) Insert2 preconditions (!On(Cap Flashlight) !In(Battery2 Flashlight)) effects (In(Battery2 Flashlight)) ) initial (On(Cap Flashlight)) goal ( On(Cap Flashlight) In(Battery1 Flashlight) In(Battery2 Flashlight) ) solution(RemoveCap Insert1 Insert2 PlaceCap) ) OUTPUT ------------------------------------------------------------- UNKNOWN1 Battery1 Battery2 Cap Flashlight UNKNOWN2 Cap Flashlight Cap Flashlight Cap Flashlight Cap Flashlight Cap Flashlight Battery1 Flashlight Battery1 Flashlight Cap Flashlight Battery2 Flashlight Battery2 Flashlight Cap Flashlight Cap Flashlight Battery1 Flashlight Battery2 Flashlight UNKNOWN3 On In UNKNOWN4 On On On On On In In On In In On On In In The number of operators defined by the plan 4 done