TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Using obscure graph theory to solve programming languages problems

106 点作者 matt_d24 天前

6 条评论

garganzol24 天前
Problem solvers based on graphs are hard to get your head around at first, but then you get extremely elegant and powerful solutions to seemingly unsolvable problems.<p>The only gotchas are: 1) time to get your head around 2) algorithmic complexity of the resulting solution.<p>Graph theory is probably the most fulfilling math application in the computer science. In a way, graph-based algorithms do magic similar to AI but in a fully determined manner. If you think about it more broadly, a graph resembles a subset of a neural network but only with {0, 1} weights.
评论 #43981291 未加载
georgewsinger24 天前
If you like reasoning about a program in terms of expression trees&#x2F;graphs, I recently discovered that Wolfram Language has built-ins for this:<p><a href="https:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;ExpressionTree.html.en" rel="nofollow">https:&#x2F;&#x2F;reference.wolfram.com&#x2F;language&#x2F;ref&#x2F;ExpressionTree.ht...</a>
tekknolagi24 天前
This seems, at least upon first read, analogous to global value numbering (GVN). Or, depending on how you look at it, common subexpression elimination (CSE). I am mostly wondering why they are not mentioned in the article.
评论 #43981577 未加载
评论 #43980195 未加载
评论 #43981137 未加载
评论 #43979032 未加载
kazinator23 天前
&gt; <i>This transformation is affectionately known as sharing</i><p>No, it is ubiquitously known as CSE: common subexpression elimination.<p>The original DAG representation of the abstract syntax, on the other hand, exhibits <i>substructure sharing</i>.<p>&gt; <i>Of course, that invariant eventually changed. We added a way in the source langauge to introduce lets, which meant my algorithm was wrong.</i><p>Because you have to identify variables by more than just their symbol, due to shadowing, like De Brujn indexing and other schemes.<p>CSE is not particularly difficult in a functional language. Variable assignments throw a monkey wrench into it. Any terms with side effects also.<p>By the way, CSE can be done over intermediate representations, rather than abstract syntax. In an intermediate representation, you look for identical instructions with the same operands, not arbitrarily large expressions, while paying attention to variable liveness.<p>Another by the way is that not only do we have to worry about side effects, but we also cannot do CSE on expressions that guarantee returning a fresh object. E.g. if we are compiling Lisp we cannot merge two occurrences of (cons 1 2). The expressions must produce fresh cells which are not <i>eq</i> to each other. Ultimately that is linked to side effects; being able to mutate one cell with no effect on the other. Construction <i>per se</i> is not a side effect, even if it guarantees freshness.
anonymousDan24 天前
A great example of the value of academia and scientific research.
评论 #43989792 未加载
评论 #43986295 未加载
lifelesson70124 天前
Yivycy