The DLQ IDE
Write a DLQ program on the left, see its model on the right. The IDE runs the engine in your browser: nothing is sent anywhere, and it works offline once loaded.
minpath on the right.Every screenshot here is a link that opens the IDE in the same state, so you can try each thing as you read.
Write
- Examples. The list at the top loads one of the examples: minimal paths, the Towers of Hanoi, map colouring, examples from the DLV manual and more. Your own program is kept in the browser and comes back the next time you open the IDE.
- Errors as you type. The program is checked while you write: an error is underlined, and a list below the editor says what is wrong. Click a line of the list to go to it. Notes say what the engine noticed, for example that a recursion through a counter may not end.
- Completion. Suggestions appear as you type: your predicates, the
built-in comparisons (
lt,ne…), functions and aggregates, types and section names, each with a short explanation. Ctrl+Space asks for them, Enter or Tab takes one. - A line for the mode. A program can say how it is to be run with a comment
at its top,
// mode: search; loading it sets the mode.
Run
Run (Ctrl+Enter) evaluates the program in the mode chosen next to it:
| Compute | Step-wise evaluation, as the dissertation defines it: one model, stratum by stratum, each step adding what the rules derive from the facts before it. |
|---|---|
| Search | Model search: every order of deriving facts. It runs programs that negate themselves inside a recursion, which Compute must reject, and finds all their models. Weak constraints keep only the cheapest. |
| Search (stable) | The same, keeping only the outcomes where every ~{ … }
still holds at the end: the stable models (answer sets). |
max steps stops an evaluation that does not end, such as a counter that keeps numbering new facts. The line above the result says how many steps and facts there were, and the strata in the order they were evaluated.
Read the result
- Tables. One tab per relation: the derived ones, then the given (
ext) ones, and the answers of agoalfirst. The step column says when each fact was derived. Copy puts the table on the clipboard for a spreadsheet; CSV saves it. - Why? Click a row to see how the fact was derived: a tree of the facts and rules it came from, down to the given facts. Click a fact in the tree to explain that one.
- Models. A search shows a button for each model it found, with its cost when there are weak constraints; restrictions that a computed model breaks are listed in red.
Debug: step by step
Debug runs the program and replays it one step of the evaluation at a time, as a debugger steps through code. Step 0 is the given facts; each step after it applies the rules to the facts derived before, and a stratum ends with a step that derives nothing new.
- In the program the rules that fired are banded, with ▶ at their line numbers. Below the editor, the step says what it added, and lists the new facts; click one to see its derivation.
- In the result the tables hold only the facts derived so far. The table follows the step: it opens the relation the step added to, and every tab that grew shows +N. Click a tab to stay on it; tick Follow to follow again.
- Moving: ▶ Step (F10) and ◀ go one step on and back, the slider anywhere, Play plays the steps, Continue (F8) runs to the next breakpoint, ✕ (Esc) ends.
- Breakpoints: click a rule's line number (or press F9 on it) to set one, marked with a red dot. Continue and Play stop at the next step where that rule derives something.
Debug replays Compute. A program only Search can run shows its search in the picture instead, as a film.
Graphs
The Graph tab draws the program as the dissertation's chapter 3 does. Hover over a node for its definition; click it to go to it in the program: its line is banded, its name in bold, and every other place it is mentioned shaded. Click the node again to go on to the next mention. SVG and DOT save the graph.
| Predicate dependencies | Which predicate is derived from which (Fig. 3.1): attributives as nodes of their own, not on negations, strata as colour groups, the number of facts under each predicate; a full attributive inside a cycle in red. |
|---|---|
| Relations and rules | Each rule between the relations it reads and the one it derives (Fig. 3.2), with how the engine evaluates it: once, in semi-naive passes, or as an aggregate. |
| Argument dependencies | How argument positions pass values to each other (Fig. 3.6): arcs through function terms marked f, bold on a cycle, which safety condition 7 forbids. |
| Variable dependencies | For one rule, which of its variables depend on which (Fig. 3.5); a new counter is a vertex of its own. |
| Why … | The derivation of a fact, after you ask Why? for it. |
ancestor, clicked: its declaration banded, its six mentions shaded.Pictures
A program can ask for its result to be drawn as the problem looks: the rings of the Towers of Hanoi moving, a map being coloured, shortest paths being found. It does so with a comment line at its top, a kind of picture followed by the relations it reads:
// picture: towers plan start stick
The Picture tab plays it (Space), steps through it frame by frame, and Video records it as a video file. For a model search, the colouring, seating, matching, pick and arcs pictures can also play how the search found them: every choice, dead end and model in turn, beside the tree of the search.
The kinds of picture
Each kind takes the names of the relations it draws, in this order; the example in brackets uses it.
| Line | What it draws |
|---|---|
towers plan start stick | The Towers of Hanoi: plan(move, ring, from, to) played from the
rings' places in start, the sticks in stick's order (towers of Hanoi). |
stacks plan start | The blocks world: plan(move, block, to) played from start,
whose columns are the blocks and whose row says what each stands on (blocks world). |
paths arc path minpath a | Shortest paths from a over arc(from, to, len): the paths
step by step, a shorter one replacing a longer one, then the tree of the shortest (minimal paths). |
spread edge dist | A breadth-first search: dist(node, d) revealed ring by ring over the graph
edge(a, b) (collaboration distance). |
tree parent closure badge … | A tree of parent(a, b); a closure relation (or -) drawn as
curved arrows step by step; relations (node, value) as badges under the nodes (ancestors,
bill of materials, org chart). |
layers requires depth passed open | Items in columns by depth, arrows from each prerequisite; per person,
what they passed and what is open (course prerequisites). |
groups road component | A directed graph, coloured group by group by component(node, leader)
(connected components). |
colouring border colour | A map: regions joined by border(a, b), coloured by colour(region,
colour), model after model (map colouring). |
seating at like dislike | Guests at tables, at(person, table), friends and foes joined; one seating
after another (seating, team building). |
matching can_do assign | Two columns joined by can_do(a, b, cost); a model's assign
drawn bold (task assignment). |
pick cover ground | A graph cover(a, b); the nodes a model picks in ground(node)
filled (network search, cheapest network). |
arcs edge in_tree root | A weighted graph edge(a, b, cost); a model's in_tree arcs
bold, the root ringed (spanning tree with a weak constraint). |
trees edge arc tree_cost best_cost root | Candidate spanning trees, each tree's arcs and cost, then the cheapest (spanning tree). |
sets cover output ground_cost optimum_output point | Candidate sets on a graph, their costs, the best (monitoring). |
teams member cost best … | Candidate splits into teams, their costs, the best; pair relations drawn between two people of one team (team building). |
bars emp name salary marker … | Bars of a relation by the named columns; each marker relation marks the bars it agrees with (employees). |
search relation … | The search itself: the facts it chooses, the tree of its choices, its models and dead ends. |
Data
- The Data tab (left) shows the facts of each
extpredicate as a table you can edit: change a cell and press Enter, add or delete rows, paste rows copied from a spreadsheet. What you change is written into the program'sfactssection. - Load data… reads facts from files: CSV files named after their predicates
(
arc.csv), or a SQLite database whose tables are matched to predicates by name. The files stay in your browser. - Export saves the result as an SQL script (
CREATE TABLEandINSERTfor the derived relations), the table shown as CSV, or all tables as a zip of CSV files.
Keys
| Ctrl+Enter | Run |
| Ctrl+Space | Suggestions; ↑ ↓ choose, Enter or Tab take, Esc closes |
| Tab | Indent by four spaces |
| F10 · Shift+F10 | Debug: the next step · the step before |
| F8 | Debug: on to the next breakpoint |
| F9 | Set or clear a breakpoint on the rule at the cursor |
| Esc | End debugging; clear the highlight a graph node left |
| Space | Play or pause the picture |
| ← → | On the divider between the panes: make the program narrower or wider |
Links to a state
A link can open the IDE on an example in a given state, to share it or to point at something:
dlq-lang.org/ide/?example=minpath&debug=3 dlq-lang.org/ide/?example=ancestors&graph=pdg&node=ancestor dlq-lang.org/ide/?example=towers-of-hanoi&view=picture&frame=7
example is an example's name as the list shows it; mode compute, search or
stable; view model, graph or picture; tab a relation; graph pdg, goa,
gza or vars:R1; node a graph node to go to; debug a step; why
relation:row; frame a frame of the picture; show=film the search's film;
left=data the Data tab.