Functional Modelling System
ingdas
25.2K views
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Syntax Overview
This document should serve as a quick overview of the statements which are possible in IDP4.
Directives
Directives are always of the form
# directiveName number.
Supported directives are:
nbModels
, determines the number of models which need to be printedprintFullStructure
, determines whether the full ASP structure needs to be outputted to the model or notprintASP
, determines whether the full ASP source needs to be printed or notconstrain
, determines whether you want to see all the structures given the definitions or only the modelsinline
, determines whether the inliner does its workpushNegs
, determines whether negations are pushed
Scripts
It is possible to directly write external functions scripts for use in clingo. These are not conform the other directives. (See the example for more info about these)
Imports
Import statements are of the form:
import "filename.fml".
A file containing only definitions is considered a library file and can be imported. Some useful symbols are predefined in the stdlib which is implicitly imported.
Declarations
It is possible to introduce a new symbol in a few ways:
a := expression.
, which defines the new symbola
to have the interpretation of the expressions.a :: subset of expression.
, which introduces a to be a subset of the set determined by the expression.a :: element of expression.
, same as the previous one but a will be a single element instead of the full seta :: function to expression.
, which introduces a to be a unary function with codomain the set determined by the expressiona :: predicate.
, which introduces a to be a predicate (a unary function to booleans).a :: proposition.
, introduces a to be a propositiona\2 :: constructor.
, introduces the binary constructor functiona
a\2 :: external function.
, introduces the binary external functiona
, this should only be used in conjunction with a script directive
Expressions
Expressions are based on the lambda calculus:
! set predicate
is used to say that the functionpredicate
should hold for every member of setset
.? set predicate
same as!
but existential.- Arithmetic operators over integers
+
-
/
*
are supported. - Comparison operators over integers
<
=<
>=
>
=
~=
are supported - Boolean operators
&
|
~
<=>
=>
<=
are supported - Integers and strings can be used
1
"Hello World"
let a := 1 ; b := 2 in a+b.
is used to locally definea
andb
so this expressions evaluates to3
{x,y || a <- {{1,2},{3,4}}, x <- a, x != 1, y := x + 1}
the set consisting of thex
andy
's, such thata
is an element of the set{{1,2},{3,4}}
,x
is an element ofa
,x
is not equal to 1, andy
is one larger thanx
.if p then a else b
represents is equal toa
if booleanp
is true, andb
otherwise.
Patterns
variableName
constructor [arg1 arg2 ...]
5
,"a"
<5
>5
_
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content