Encodings
Generates a section with one section for each file included in the root file.
Each section will include the encoding where comments are rendered as markdown. This means that any markdown code can be rendered, including sections, admonitions, code, etc.
Commented clingo code
If a comment can be interpreted by clingo as a valid statement, it will be ignored.
% Will skip the next comment since it is parsable
% a:-b.
%% This is also skipped since it is a comment in clingo
c:-d,e.
% The next line prints a line separator
%----------------------
% The following lines will not be printed and can use in the encodings to separate sections
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%=================================
%%---------------------------------
Will skip the next comment
c:-d,e.
The next line prints a line separator
The following lines will not be printed and can use in the encodings as separator
For each encoding, a section in the table of content will be created.
Example
Encodings ¶
examples/sudoku/encoding.lp
¶
Source
% # Sudoku Puzzle
% Uses the well known [puzzle](https://en.wikipedia.org/wiki/Sudoku)
%
#const dim = 3.
val(1..dim*dim).
pos(X,Y) :- val(X), val(Y).
%*
#sudoku(X,Y,V).
Describes a sudoku board. The value of cell (X,Y) is V.
#parameters
- X: the row of the cell
- Y: the column of the cell
- V: the value of the cell
*%
%*
#initial(X,Y,V).
Initial values of the sudoku board. The value of cell (X,Y) is V.
#parameters
- X: the row of the cell
- Y: the column of the cell
- V: the value of the cell
*%
%*
#pos(X,Y).
The cell (X,Y) is in the sudoku board.
#parameters
- X: the row of the cell
- Y: the column of the cell
*%
%*
#val(V).
The value V is a possible value for a cell.
#parameters
- V: the value
*%
subgrid(X,Y,(((X-1)/dim)*dim+((Y-1)/dim))) :- pos(X,Y).
% A choice rule for each cell
1 { sudoku(X,Y,V) : val(V) } 1 :- pos(X,Y).
%## Constraints
:- sudoku(X,Y,V), sudoku(X',Y,V), X != X'.
:- sudoku(X,Y,V), sudoku(X,Y',V), Y != Y'.
:- sudoku(X,Y,V), sudoku(X',Y',V), subgrid(X,Y,S), subgrid(X',Y',S), (X,Y)!=(X',Y').
sudoku(X,Y,V) :- initial(X,Y,V).
%## Shows
#show .
#show sudoku/3.
Encoding
Sudoku Puzzle¶
Uses the well known puzzle
#const dim = 3.
val(1..dim*dim).
pos(X,Y) :- val(X), val(Y).
subgrid(X,Y,(((X-1)/dim)*dim+((Y-1)/dim))) :- pos(X,Y).
A choice rule for each cell
1 { sudoku(X,Y,V) : val(V) } 1 :- pos(X,Y).
Constraints¶
:- sudoku(X,Y,V), sudoku(X',Y,V), X != X'.
:- sudoku(X,Y,V), sudoku(X,Y',V), Y != Y'.
:- sudoku(X,Y,V), sudoku(X',Y',V), subgrid(X,Y,S), subgrid(X',Y',S), (X,Y)!=(X',Y').
sudoku(X,Y,V) :- initial(X,Y,V).
Shows¶
#show .
#show sudoku/3.
::: examples/sudoku/encoding.lp
handler: asp
options:
encodings:
source: true
start_level: 3
Notice the use of start_level
passed for rendering headers and the TOC.
Configuration options¶
The option encodings
can be further customized with the following options:
source
Boolean indicating if the source code is included. Default to True.git_link
Boolean indicating if github links should be added in the encoding title. Default to False.
Example
Encodings ¶
examples/sudoku/encoding.lp
¶
Encoding
Sudoku Puzzle¶
Uses the well known puzzle
#const dim = 3.
val(1..dim*dim).
pos(X,Y) :- val(X), val(Y).
subgrid(X,Y,(((X-1)/dim)*dim+((Y-1)/dim))) :- pos(X,Y).
A choice rule for each cell
1 { sudoku(X,Y,V) : val(V) } 1 :- pos(X,Y).
Constraints¶
:- sudoku(X,Y,V), sudoku(X',Y,V), X != X'.
:- sudoku(X,Y,V), sudoku(X,Y',V), Y != Y'.
:- sudoku(X,Y,V), sudoku(X',Y',V), subgrid(X,Y,S), subgrid(X',Y',S), (X,Y)!=(X',Y').
sudoku(X,Y,V) :- initial(X,Y,V).
Shows¶
#show .
#show sudoku/3.
::: examples/sudoku/encoding.lp
handler: asp
options:
encodings:
git_link: true
source: false
start_level: 3