Describe desired workflows
This page describes how to specify the workflows to be generated by the APE library. The workflows are specified using a JSON configuration file as described in in the previous section. The initial description of the problem is given by the workflow inputs and outputs described in the configuration file. In addition, the configuration file references a constraint file that specifies the constraints that the workflow must satisfy. The constraints are used to guide the workflow synthesis process and ensure that the generated workflows meet the requirements of the problem. This page describes how to specify the constraints in the constraint file.
Constraint file is a JSON document that contains a list of constraints that must be satisfied by each generated workflow. In case constraints are contradicting each other (e.g., “Use tool X” and “Never use tool X”) so solution will be found. The constraints can be specified in two ways: using predefined templates or using SLTLx (Semantic Linear Time Temporal Logic extended) constraints. The predefined templates are a set of common constraints that can be used to specify the relationships between the operations in the workflow. The SLTLx constraints are more flexible and allow the user to define complex constraints using logical formulas. The following sections describe how to specify constraints using predefined templates and SLTLx constraints.
Constraint Templates
As an example we will present one of the constraint templates, namely “if then generate type” is represented as follows:
{
"constraintid": "use_m",
"description": "Use the specified tool in the solution.",
"parameters": [
["${parameter_1}"]
]
}
"${parameter_1}"
represent a tool or an abstract operation from the domain taxonomy. The following encoding represents a use of such constraint in practice (tag "description"
is not obligatory):
{
"constraintid": "gen_ite_t",
"parameters": [
["Transformation"]
]
}
The constraint is interpreted as: “A tool that performs Transformation must be used in the workflow.”
All pre-defined constraints that can be used:
ID |
Description |
---|---|
|
If we use operation then use |
|
If we use operation then do not use |
|
If we use operation then we must have used |
|
If we use operation then use |
|
If we use operation then we must have used |
|
Use operation |
|
Do not use operation |
|
Use |
|
Use type |
|
Generate type |
|
Do not use type |
|
Do not generate type |
|
If we have used data type then use type |
|
If we have generated data type then generate type |
|
If we have used data type then do not use type |
|
If we have generated data type then do not generate type |
|
Use the operation with an input of the given type. |
|
Use the operation to generate an output of the given type. |
|
The 1st operation should generate an output used bt the 2nd operation. |
|
The 1st operation should never generate an output sued by the 2nd operation. |
|
No operation that belongs to the subtree should be repeated within the workflow. |
SLTLx constraints
SLTLx (Semantic Linear Time Temporal Logic extended) allows the user to define constraints using logical formulas.
For example, the following constraint prevents an operation within the subtree Transformation
from using the same input twice:
{
"constraintid": "SLTLx",
"formula": "!F Exists (?x) (<'Transformation'(?x,?x;)> true)"
}
The formula above can be broken down as follows:
!
: negation operatorF
: Finally operator - the formula holds at some point in the future (future in Time Logics can be seen as the following states in the workflow)Exists
: Existential quantifier?x
: variable<Transformation’(?x,?x;)> true : after applying operation
Transformation
with at least 2 distinct inputs?x
and?x
we reach a state where the formula holds (true). Notice that the semicolon;
is used to separate the inputs and outputs of the operation. In our specification no outputs were specified.
The formula above can be interpreted as: “It is not the case that in the workflow there exists an operation Transformation
that uses the same input twice.”
This second example specifies a constraint which makes sure a workflow input is used only once. To tell APE which inputs are not to be used twice, the workflow inputs have been labeled as “Input” in the run configuration file:
"inputs": [
{
"data_0006": ["data_9003"],
"format_1915": ["format_3989"],
"APE_label": ["Input"]
},
{
"data_0006": ["data_9003"],
"format_1915": ["format_3989"],
"APE_label": ["Input"]
},
{
"data_0006": ["data_9001"],
"format_1915": ["format_1929", "format_3331"],
"APE_label": ["Input"]
}
],
The labeled inputs can now be used in the SLTLx formula:
{
"constraintid": "SLTLx",
"formula": "! Exists (?x) ('Input'(?x) & (F <'Tool'(?x;)> F <'Tool'(?x;)> true))"
}
In our example Tool
is the root of the tool taxonomy, therefore it’s the most general type of operation. The formula above can be broken down as follows:
!
: negation operatorExists
: Existential quantifier?x
: variable'Input'(?x)
: the variable?x
is of typeInput
&
: logical AND operatorF
: Finally operator - the formula holds at some point in the future (future in Time Logics can be seen as the following states in the workflow)<'Tool'(?x;)> X
: after applying operationTool
with input?x
we reach a state where the formulaX
holds (in our case, the formulaX
isF <'Tool'(?x;)> true
)F <'Tool'(?x;)> true
: at some point in the future, the operationTool
with input?x
is applied and the formula holds (true)
The formula above can be interpreted as: “It is not the case that in the workflow there exists an input that is used twice.”
SLTLx syntax
This document provides a list of syntax options available in the SLTLx logic.
Formulas (formula
)
A formula
can be one of the following:
true
( formula )
< TOOL > formula
CONSTANT ( VARIABLE )
VARIABLE = VARIABLE
! formula
Forall ( VARIABLE ) formula
Exists ( VARIABLE ) formula
UN_MODAL formula
formula BIN_CONNECTIVE formula
formula BIN_MODAL formula
R ( VARIABLE , VARIABLE )
Binary Connectives (BIN_CONNECTIVE
)
&
(AND)|
(OR)->
(IMPL)<->
(EQUIVALENT)
Unary Modal Operators (UN_MODAL
)
G
(GLOBALLY)F
(FINALLY)X
(NEXT STEP)
Binary Modal Operators (BIN_MODAL
)
U
(SLTL_UNTIL
)
Tool (TOOL
)
A TOOL
is defined as:
CONSTANT ( VARIABLE,...,VARIABLE ; VARIABLE,...,VARIABLE )
Variables (VARIABLE
)
A variable is denoted by a
?
followed by alphanumeric characters or underscores.
Tokens
true
: The constant true.VARIABLE
: A variable starting with?
.CONSTANT
: A constant enclosed in single quotes'
.R
: Relation.U
: Until.G
: Globally.F
: Finally.X
: Next.|
: OR.&
: AND.->
: Implies.<->
: Equivalent.=
: Equals.!
: Negation.Exists
: Existential quantifier.Forall
: Universal quantifier.
Examples
!F Exists (?x) (<'Transformation'(?x,?x;)> true)
- No operation within the subtreeTransformation
uses the same input twice.! Exists (?x) ('Input'(?x) & (F <'Tool'(?x;)> F <'Tool'(?x;)> true))
- NoInput
is used twice (whereInput
is a custom label added to all the inputs).
See SLTL:sup:`x Constraints <#sltlx-constraints>`_ for more detailed explanation of the constraints.