TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Learn You an Agda

127 pointsby bkirwiover 10 years ago

15 comments

pronover 10 years ago
Languages that use types for elaborate proofs always seem to me like they only prove the most uninteresting properties of programs, namely the parts that deal with data transformations. Not that data transformations aren&#x27;t important, but the properties they need to preserve are usually easy to be convinced of without any assistance by the compiler.<p>At the end of the day, programs are written for their side effects (unless your program is a compiler, which is the classical example of an &quot;interesting&quot;, non-trivial data transformation, and possibly the only example). What I&#x27;m most interested in is proofs that, say, in a concurrent environment, a function that closes a socket will never be called as long as there are pending tasks to write to the socket. Or, because I write concurrent data structures, I&#x27;m interested to prove that a certain function will eventually release all locks it acquires. Are there any such languages?<p>I&#x27;ve heard of effect systems, but I couldn&#x27;t find enough information on them. Are effect systems capable of the kind of proofs I&#x27;m interested in? Are there practical programming languages with powerful effect systems?<p>EDIT: Some Googling yielded this: <a href="http://lambda-the-ultimate.org/node/4768" rel="nofollow">http:&#x2F;&#x2F;lambda-the-ultimate.org&#x2F;node&#x2F;4768</a> tldr: Not yet.<p>EDIT: At least the lock proof seems to be implemented as one of Java 8&#x27;s pluggable type systems: <a href="http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#lock-checker" rel="nofollow">http:&#x2F;&#x2F;types.cs.washington.edu&#x2F;checker-framework&#x2F;current&#x2F;che...</a><p>It lets you add a type (Java 8&#x27;s pluggable types are intersection types) to a function called @EnsuresLockHeld(locks...) that proves some locks will be held when a function returns and even @EnsuresLockHeldIf(locks..., result) that proves a function grabs certain locks if its boolean result is equal to the one specified in the type.
评论 #8690878 未加载
评论 #8690778 未加载
评论 #8690815 未加载
评论 #8692311 未加载
评论 #8690928 未加载
评论 #8691289 未加载
评论 #8693259 未加载
评论 #8693930 未加载
digitalzombieover 10 years ago
I really like these &quot;learn you a&quot; books.<p>I have no reason why but I just like the freaking pictures. It keeps me going. It&#x27;s like a children book but it also teaches me the subject I like, programming languages.
评论 #8690500 未加载
lelfover 10 years ago
I like to show you the immense beauty of the Agda standard library: <a href="http://agda.github.io/agda-stdlib/html/README.html" rel="nofollow">http:&#x2F;&#x2F;agda.github.io&#x2F;agda-stdlib&#x2F;html&#x2F;README.html</a> (all clickable and…you&#x27;d better have proper unicode fonts).
评论 #8690940 未加载
agumonkeyover 10 years ago
First time I read about &#x27;mixfix&#x27; operators, one less thing I&#x27;ll have to invent I guess. <a href="https://www.google.fr/search?q=mixfix+notation" rel="nofollow">https:&#x2F;&#x2F;www.google.fr&#x2F;search?q=mixfix+notation</a>
akkartikover 10 years ago
It lost me at this point:<p><i>Type the following into an emacs buffer, and then type C-c C-l (use \_1 to type the subscript symbol ₁):</i><p><pre><code> proof₁ : suc (suc (suc (suc zero))) even proof₁ = ? </code></pre> On my newly created emacs setup from the earlier instructions, it&#x27;s not clear what &quot;type into an emacs buffer&quot; means. Do I create a new file with C-x C-f? Create a new buffer with C-x b? I tried both, and promptly lost agda-mode.<p>I then tried restarting emacs and opening a new .agda file so I get agda mode. Loaded the earlier module and then tried loading this, and it didn&#x27;t seem to know about <i>suc</i> in the context of this buffer&#x2F;file. So now I&#x27;m lost.
评论 #8696743 未加载
tomwildeover 10 years ago
If I wrote a natural number calculator in Agda; would all my numbers be represented as lists of successions from zero or can the compiler convert them to two&#x27;s-complement integers as we know and love them?<p>In case the compiler can do that conversion: is it is programmed to do that for some subset of numeric types or can it infer an optimal binary representation of a value somehow?<p>On the other hand, if they really were represented as lists then I presume this language is intended as purely academic work and has no application in a production environment. Am I wrong?
评论 #8691351 未加载
评论 #8692940 未加载
评论 #8691153 未加载
gosubover 10 years ago
<p><pre><code> If we can construct a value of a certain type, we have simultaneously constructed a proof that the theorem encoded by that type holds. data _even : ℕ → Set where </code></pre> I do not understand how to interpret this passage. _ even, given a number, returns a type? in this case, zero even is a type, but we have not created any value with that type. What am I missing?
评论 #8691304 未加载
评论 #8691639 未加载
评论 #8691271 未加载
mjflover 10 years ago
Recently learned this language in a functional programming course. Very cool language. The Curry-Howard Isomorphism proves that programming languages are equivalent to mathematical proofs and you can really feel it here. I could see this language being very useful in math-y applications such as cryptography and verification.
kxyvrover 10 years ago
Is there any reason to use Agda over Coq or vice versa?
评论 #8691121 未加载
Energy1over 10 years ago
How does Agda compare to the likes of Clojure, Haskell, ML, Scheme etc? What are the best reasons to learn it?
评论 #8690493 未加载
frontsideairover 10 years ago
I always wondered about dependent types. Even though it was a little bit too technical for me, at least I have some idea about what it really is.<p>By the way, Z notation rocks.
eli_gottliebover 10 years ago
Ok, that&#x27;s neat. Is there a proof checker and an editor&#x2F;IDE other than Emacs&#x27; Agda mode?<p>Because I&#x27;m probably going to stick with Coq for its tooling.
alphonse23over 10 years ago
I posted this on lobste.rs and somebody stole my link....<p>Hackernews always gets so much more comments.
评论 #8691324 未加载
评论 #8691717 未加载
olderwannalearover 10 years ago
My thanks OVERFLOWS. For those who are &#x27;older but not quite Learn U Agda vs &#x27;wiser strategies&#x27; HELPFUL.<p>Think eric raymond and too bad that perl is just another dead language -- your wisdom though as recompense. When you are older, it becomes EASIER for crunchfit and yes, it sometimes becomes harder to exercise to point of vomit - &quot;ad nauseum&#x27; in Latin, but the pain is much easier. Don&#x27;t you do three hundred (300) pushups a day?<p>So, the routine is simple. Get stuck running Haskell (another bump on the road to the true language of Coq) - go ahead and flame - do the pushups. Then laugh cause it releaxes and then refrshed back to AGDA.<p>PS. Engineering school was arduous and graduate school. The personal private books&#x2F;research were just hobbies and no I will not mention my name. Even the so-called Yourdon &#x27;death marches&#x27; are just a bump on the road.<p>It&#x27;s worse than some females - over the period of a &#x27;big city man.&#x27; - go ahead flame - Just take code from arxiv, run it in Haskell and Agda and there are only three explanations 1.)the programmer is stupdi - yup that&#x27;s me 2.)scientific fraud - always possible 3.)the &#x27;compiler&#x27; or the strange AMD CPU is fickle in a feminine way? 4.)the language paradigm is &#x27;slightly broken.&#x27; 5.) all of the above<p>Fair Warning and Serpents be Here. Haskell, Agda and even Coq are DEFINED as EXPERIMENTAL RESEARCH Languages. Of course, you can always go Python (which version?) and Javascript, which is the bubble gum and string that holds together the Internet.. along with BAsh shellshock.<p>It this why they call it a bit of &#x27;hacking&#x27;? PPS. learn to ride bicycle in big city and survived with most of my fingers intact.
mike_hearnover 10 years ago
Ah yes, dependent types. They tried to teach this at my university because some researchers there were working on it. Too bad they didn&#x27;t bother to teach something more useful, like what malloc and free do.<p>But let&#x27;s see. Perhaps the field has become less wonkish and more relevant to real programmers in the last ten years.<p><i>Most language tutorials start with the typical “Hello, World” example, but this is not really appropriate for a first example in Agda. Unlike other languages, which rely on a whole lot of primitive operations and special cases for basic constructs, Agda is very minimal - most of the “language constructs” are actually defined in libraries.</i><p>That sounds reasonable ...<p><i>Agda doesn’t even have numbers built in, so the first thing we’re going to do is define them</i><p>That&#x27;s much less reasonable ...<p><i>This is a very elegant way to define infinitely large sets. This way of defining natural numbers was developed by a mathematician named Giuseppe Peano, and so they’re called the Peano numbers .... Now we can express the number one as suc zero, and the number two as suc (suc zero), and the number three as suc (suc (suc zero)), and so on.</i><p>Oh dear. This is a new use of the word elegant I have not encountered before.<p>I was expecting the next stage of the tutorial to describe how to make numbers in Agda resemble number systems actually used by humans, or even machines, but no such luck. They stick with a Lisp-style Peano representation throughout the entire thing. Having defined an entirely unworkable method of representing integers because their standard library apparently doesn&#x27;t do so (?!) they then go on to prove things like 1 + 1 == 2.<p>Yeah, I think I&#x27;ll skip. Perhaps in another few decades someone will have bothered to make a dependently typed language that doesn&#x27;t use untypeable characters as part of its syntax, and has an integer type built in, and we&#x27;ll all get awesome statically checkable code for free. Until then I&#x27;m gonna stick with FindBugs.
评论 #8690586 未加载
评论 #8690547 未加载
评论 #8690585 未加载