From: Tim Vieira Date: Mon, 1 Jul 2013 19:47:37 +0000 (-0400) Subject: minor cleanup. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=1ae2309954ddc9e74ffd11f153b32a341d63a7de;p=dyna2 minor cleanup. --- diff --git a/src/Dyna/Backend/Python/post/draw_circuit.py b/src/Dyna/Backend/Python/post/draw_circuit.py index b01a5e7..add8c47 100644 --- a/src/Dyna/Backend/Python/post/draw_circuit.py +++ b/src/Dyna/Backend/Python/post/draw_circuit.py @@ -5,6 +5,7 @@ from debug import Hypergraph from cStringIO import StringIO from utils import lexer, subst + def circuit(edges): # create hypergraph object g = Hypergraph() diff --git a/src/Dyna/Backend/Python/post/trace.py b/src/Dyna/Backend/Python/post/trace.py index 58c2d48..dbdb5bc 100644 --- a/src/Dyna/Backend/Python/post/trace.py +++ b/src/Dyna/Backend/Python/post/trace.py @@ -1,22 +1,19 @@ # -*- coding: utf-8 -*- -""" -Examine solution as an outline of computation. - -TODO: shared substructure. - -""" import re -from utils import yellow, green, cyan, red, _repr, drepr -import debug, defn +from collections import defaultdict +import debug, defn from draw_circuit import infer_edges -from collections import defaultdict +from utils import yellow, green, cyan, red, _repr class trace(object): """ - Examine solution as an outline of computation. + Examine solution as an outline of computation. Essentially it computes + `trace` for every term in the current solution. + + See `help trace` for more information on `trace`. """ def __init__(self, interp): diff --git a/src/Dyna/Backend/Python/repl.py b/src/Dyna/Backend/Python/repl.py index c3cd441..fccbf9e 100644 --- a/src/Dyna/Backend/Python/repl.py +++ b/src/Dyna/Backend/Python/repl.py @@ -422,7 +422,6 @@ class REPL(cmd.Cmd, object): > b :- c. > c. - In our solution we see that `a` is true. > sol @@ -481,7 +480,7 @@ class REPL(cmd.Cmd, object): The way trace lets you know that it has omitted something is with a message `item: shared structure see above` or `item: *cycle*`. - > trace bar(10,10) + > trace bar(10, 10) bar(10,10) = 220 | @@ -495,11 +494,17 @@ class REPL(cmd.Cmd, object): │ │ foo(X=10) = (X=10 + 1)=11. │ + │ └─ += 110 bar(A=10, B=10) += (A=10 * foo(B=10)=11)=110. | - └─ foo(10): shared structure see above + └─ foo(10) = 11 + | + └─ continue as before (shared structure) + + + Now, let's have a look at the geometric series, `a`. > trace a @@ -508,11 +513,14 @@ class REPL(cmd.Cmd, object): ├─ += 1 │ │ a += 1. + │ └─ += 1.0 a += (a=2.0 / 2)=1.0. | - └─ a: *cycle* + └─ a = 2.0 + | + └─ continue as before (cyclic structure, will continue forever) """