Using the debugger

From Dyna
Jump to: navigation, search



Dynasty has been completely rewritten, so this page is temporarily out of date.

Navigating the Graph

A note on speed

This is a graphical user interface. So if you want it to run fast, sit physically at the machine where it is running. If you're willing to wait for the graphics to come to you over the net, you can sit at the other end of an ssh session, at any machine that is running an X server (e.g., a Unix or Cygwin machine).

Alternatively, any ssh user can scp the output of ./path to her local machine and run Dynasty on it locally. Installing Dynasty for Windows is quick and easy, compared to doing a full local install of Cygwin and Dyna. But we need instructions for this somewhere on the wiki.

Scrolling and Zooming

Using the left mouse button, click and drag some empty space. This lets you scroll by essentially dragging the graph around.

Using the right mouse button, click and drag some empty space. Dragging up and down will zoom in and out on the spot where you clicked.

Note: Clicking on nodes or near edges will do something else. You need to click on empty space if you want to zoom or scroll.

You can also zoom in and out with the + and - keys. (for now, don't hold down shift: use = and -.)

Examining items and edges

Hover over an item with the mouse. A "tool tip" should pop up with the full name of the item and its value.

You may want to choose "Show Node Values" from the Tools menu. Now all items show their values, all the time.

If you click on the item you'll see its full name in the status area at the bottom of the Dynasty window. This is useful for long names.

What happens if you hover over an edge? (new feature on its way)

Keyboard navigation

You can navigate logically in the graph using the arrow keys. A cursor will appear in the form of a red box surrounding one of the items. Try exploring!

Click on one of the pathto items to move the cursor there.

Up and down will take you to an item's parents and children. If an item is connected to several children below it, which combined to give birth to it, the down key can only guess which one you meant to go to.

If you went down but landed at the wrong child, try pressing left and right to visit that child's siblings -- the other children of the parent you came from. (That parent is helpfully boxed in pink. It is called the "pivot," because it stays fixed as you rotate left/right through its children.)

Who's the parent around here anyway?

Skip this section unless you are confused (or curious).

Perhaps you were surprised that the previous section referred to lower nodes as "children" and the higher nodes as their "parents." You're right, there are also arguments for swapping those names.

Official Dyna terminology avoids the confusing terms "parent" and "child." We say that "antecedents" (shown lower down) combine with one another to make "consequents" (shown higher up):

consequent min= antecedent + antecedent.

These neutral words are borrowed from deductive logic. So now you know how keep_best_antecedents got its name.

Sometimes it is convenient to think of the antecedents as parents, and sometimes it is convenient to think of them as children. It depends on how you look at things. If you are thinking about who gave birth to whom, did the goal at the top give birth to subgoals below it (as in Prolog's backward chaining), or did the axioms at the bottom combine and give birth to theorems (as in Dyna's forward chaining)? If you are using Dyna for context-free parsing, are you thinking about the top-down derivation process that produced the sentence, or the bottom-up parsing process that Dyna follows to rediscover the derivation tree? It's up to you.

This tutorial does refer casually to the higher nodes as "parents" of the lower nodes, simply because that is a common way to talk about trees, and you happen to be looking at a proof tree right now.

Seeing All Paths

So far, you are only looking at the best way to find each item -- the same information shown by --driver=backtrace. The notion of "best" is meaningful in path.dyna because its items are defined with min= (rather than, say, +=).

Now let's look at all ways to find each item. In your path.dyna file, change :- pragma(keep_best_antecedents(item)) to

:- pragma(keep_all_antecedents(item)).

Now let's use a different driver that graphs all the antecedents:

dynac path.dyna --driver=dynasty     # instead of "dynasty_bestonly"
./path flights.par | dynasty - &     # the & says to run in the background

When dynasty loads up, you may wish to make the window bigger, and press HOME to fill it. You should then see something like this:

Dijkstra full.JPG

This drawing includes more items than before. It does not just show the best way to get from "Start" to "End," or from some of the edge items to the goal item. All of the facts from the input file are shown. So are all of the conclusions that Dyna drew from those facts.

For example, Dyna found that you can get to Los Angeles from either Miami or Detroit. So in the drawing, you see that pathto("LAX") is the min= of two expressions: pathto("MIA")+edge("MIA", "LAX"), and pathto("DFW")+edge("DFW", "LAX").

Warning: --driver=dynasty currently shows all node values as 1, which is incorrect.

Understanding backedges

Somewhere you should see a blue edge (darker than the others). This is a backedge: it should be interpreted as pointing down instead of up. In the picture above, pathto("ORD") goes downwards to combine with edge("ORD", "DFW") to make pathto("DFW").

Dynasty avoids using backedges when it can. A backedge is necessary here, however, because the drawing has a directed cycle, whose edges can't all point upward. You can get from pathto("DFW") up to pathto("ORD") and then back down again (via the backedge) to pathto("DFW").

The cycle in the drawing comes from the DFW -> ORD -> DFW cycle in the input graph. In fact, the drawing for this particular algorithm is basically isomorphic to the input graph. Each "edge" node helps to connect one "pathto" node to another, mimicking the original graph. If you were to remove all nodes but the "pathto" nodes, you would see a drawing identical to the original.

More about navigation

Now that you are looking at a bigger graph, you may want to know about some more features.

Simplifying the graph

Large graphs may be too big, or too tangled, to be worth viewing in full. Dynasty usually displays only part of a large graph -- the part near the cursor.

Use the < and > keys to reduce or increase the number of nodes shown. (shift is required)

The View menu shows some other useful commands and their keyboard shortcuts.

You can drag nodes around manually if some of the edges are obscured.

Hints about keyboard navigation

In this more complicated graph, a node may have multiple parents, not just multiple children.

So if you press up, you might land at the wrong parent.

Remember that if you pressed down and landed at the wrong child, you could press left and right to visit that child's "siblings" -- the other children of the "pivot" parent you came from.

In the same way, if you press up and land at the wrong parent, you can press left and right to visit its "mates" -- the other parents of the "pivot" child you came from.

Pivots are helpfully boxed in pink. If you are having trouble going where you want to go, it's probably because you want a different pivot. Dynasty may sometimes obligingly change the pivot for you if you are trying to go in an impossible direction. Holding down the Ctrl key lets you move the pivot explicitly.

If you get confused, you can always click on a node to move the cursor there!

Searching and Highlighting

You can search for items by name, using the "search box" above the graph.

Suppose you're interested in the Miami airport. Enter "MIA" into the search box and click "Find by Regex." Or if you're a keyboard jockey, just type "/ MIA Enter". (The slash key starts a search.)

All the items that mention MIA will helpfully light up in yellow. The cursor jumps to one of them. Repeatedly press Ctrl-S or click "Find by Regex" to visit the others. To make the yellow highlights go away, press the Esc key or click Clear.

Search is not limited to just the items you can see right now. It can also bring new parts of the graph into view. Use Ctrl-R to search backward to nodes you've already visited with Ctrl-S.

Search supports full regular expressions. Suppose you're interested in just the edges (not the pathtos) involving Miami. Then try searching for "edge.*MIA".

Warning: Parentheses in the search string will be treated as regex special characters. So it is hard to search for the literal parenthesis character. Literal parentheses (like literal asterisks, etc.) must be preceded like a backslash.

Probably we should make parentheses literal by default.

If you're not familiar with regular expressions, you can get started here. The precise syntax of Java's regular expressions can be found here.

The Dyna tutorial is not yet finished. To learn more, check out the reference guide (from the Main Page), which lays out the language properly in a reasonable order. Or check out these examples.
Personal tools