Back
Close

Functional Modelling System

IngmarDasseville
24.1K views

(Anonymous) functions

Traditional Functions

While writing down theories, it is very common that multiple expressions take on the same form. Luckily it is possible to abstract these away using functions.

Note that function application is done by just writing a space between the function and the argument.

Functions

Warning: Equality and comparisons between functions is not guaranteed to give any useful result.

It is also possible to use infix notation for binary function application. In this case you need to write your function name between backticks a `plus` b

Infix Functions

Anonymous Functions

It is also possible to define a function and not give it a name, this is done with a backslash. Note that just like let-constructs, functions also introduce a local scope so the x within the function definition is not the same as the x we are defining.

Anonymous Functions

A function declaration: f a b := g a b is actually syntactical sugar for f := (\a -> (\b -> g a b)).

Currying

If a function takes two arguments, it is not necesary to apply them to both at once. You can reuse a partially applied function multiple times like this:

Currying

The other way around

Functions

Similarly to constraints with variables, FMS allows the introduction of unknown functions that take a value satisfying the given constraints. You can declare a function with the statement: name/arity :: function to setExpression.

Uninterpreted Functions

Predicates

A special case are Boolean functions, also known as predicates. Again, as with propositions, IDP4 has efficient support predicates through the declaration name/arity :: predicate.

Predicates
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io