From 197cec923eeefc052c3fdb9b82ee9f8ad9390cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 13 Aug 2016 18:47:01 +0200 Subject: [PATCH] Added introductory example to output format documentation. --- doc/output-format.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/doc/output-format.md b/doc/output-format.md index a7619ad..50c45ae 100644 --- a/doc/output-format.md +++ b/doc/output-format.md @@ -2,7 +2,49 @@ `plasp` 3 translates SAS and PDDL files into the same ASP fact format. -`plasp` structures the translated ASP facts into the multiple sections, which are explained in the following. +## In a Nutshell + +The following illustrates `plasp`’s output format for the problem of turning switches on and off. + +```prolog +% declares the type "type(switch)" +type(type(switch)). + +% introduces a switch "constant(a)" +constant(constant(a)). +has(constant(a), type(switch)). + +% introduces another switch "constant(a)" +constant(constant(b)). +has(constant(b), type(switch)). + +% declares a variable "variable(on(X))" for each switch X +variable(variable(on(X))) :- has(X, type(switch)). + +% the variable may be true or false +contains(variable(on(X)), value(on(X)), true)) :- has(X, type(switch)). +contains(variable(on(X)), value(on(X)), false)) :- has(X, type(switch)). + +% declares the action "action(turnOn(X))", which requires switch X to be off and then turns it on +action(action(turnOn(X))) :- has(X, type(switch)). +precondition(action(turnOn(X)), variable(on(X)), value(on(X), false)) :- has(X, type(switch)). +postcondition(action(turnOn(X)), effect(0), variable(on(X)), value(on(X), true)) :- has(X, type(switch)). + +% declares the action "action(turnOff(X))", which requires switch X to be on and then turns it off +action(action(turnOff(X))) :- has(X, type(switch)). +precondition(action(turnOff(X)), variable(on(X)), value(on(X), true)) :- has(X, type(switch)). +postcondition(action(turnOff(X)), effect(0), variable(on(X)), value(on(X), false)) :- has(X, type(switch)). + +% initially, switch a is off and switch b is on +initialState(variable(on(constant(a))), value(on(constant(a)), false)). +initialState(variable(on(constant(b))), value(on(constant(b)), true)). + +% in the end, switch a should be on and switch b should be off +goal(variable(on(constant(a))), value(on(constant(a)), true)). +goal(variable(on(constant(b))), value(on(constant(b)), false)). +``` + +When translating SAS or PDDL problems, `plasp` structures the translated ASP facts into multiple sections, which are explained in the following. ## Feature Requirements