Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • N ndl
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pro
  • ndl
  • Wiki
  • specification

specification · Changes

Page history
Adds custom predicates. authored Nov 06, 2018 by Mateusz Ślażyński's avatar Mateusz Ślażyński
Hide whitespace changes
Inline Side-by-side
specification.md
View page @ ff964d15
......@@ -112,7 +112,7 @@ This extension adds three additional constructs:
* `top(+Type:type, -Arg:Type)` - gets the last added element of `Type` from the stack, but doesn't remove it from the stack
* `while(pop(+Type:type, -Arg:Type), Query:query)` - new loop that loops while the stack contains value of a type `Type`. It can be used to simulate recursion, there is no guarantee it finishes.
## Semantics
### Semantics
Motivation: user can define constraint and auxiliary variables semantics in the model. Exploiting semantic part of the model often simplifies the operator.
This extension adds additional constructs:
......@@ -121,19 +121,30 @@ This extension adds additional constructs:
* `is_satisfied(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is satisfied for arguments `Arg1` and `Arg2`
* `is_violated(+Name:name, +Arg1:arg1(Name), +Arg2:arg2(Name))` - succeeds if the constraint named `Name` is not satisfied for arguments `Arg1` and `Arg2`
## Generative semantics
### Generative semantics
Motivation: the common strategy when implementing a neighborhood operator is to make a move and then fix constraints that got violated by the move.
The biggest difference between the **normal** and *generative* semantics is that in the latter case one can query the violated constraints in a generative manner.
This extension adds additional constructs:
* all from the weak semantics
* all from the normal semantics
* `violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)) is nondet` - finds a violated constraint named `Name` if there is any. Otherwise it fails.
* loop `for_each(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)`
* loop `while(violated(+Name:name, ?Arg1:arg1(Name), ?Arg2:arg2(Name)), +Query:query)` - a common patter used in the neighborhood operators.
**Warning** using generative semantics adds an overhead to all operations modifying the solution.
### Custom predicates
Motivation: it's often desirable to group common query parts into named predicates.
This extension allows to define custom (possibly recursive) predicates that can be used later in the query.
Every predicate has to have defined name, arity and types of its' arguments, i.e. `predicate/2 : [arg1type, arg2type]`.
Using this extension it is possible to replace all control structure (loops, conditional, stacks, memory) with recursion, making it a plain logic program suitable for logical induction approaches.
Clone repository
  • 20181018
  • Theory
  • Home
  • knowledge base
  • specification