<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2013-01-03:1881992</id>
  <title>Anton Salikhmetov</title>
  <subtitle>Anton Salikhmetov</subtitle>
  <author>
    <name>Anton Salikhmetov</name>
  </author>
  <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom"/>
  <updated>2018-02-08T18:06:50Z</updated>
  <dw:journal username="codedot" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:181371</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/181371.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=181371"/>
    <title>Exhausting Combinators</title>
    <published>2018-02-04T14:23:23Z</published>
    <updated>2018-02-08T18:06:50Z</updated>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <category term="elementary mathematics"/>
    <category term="howtos"/>
    <category term="ideas"/>
    <category term="talks"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;i&gt;Early this year, I made a &lt;a href="http://lambda-the-ultimate.org/node/5487"&gt;post on LtU&lt;/a&gt; about the experimental "abstract" algorithm in &lt;a href="https://www.npmjs.com/package/@alexo/lambda"&gt;MLC&lt;/a&gt;. Soon after that, &lt;a href="http://gallium.inria.fr/~scherer/"&gt;Gabriel Scherer&lt;/a&gt; suggested doing exhaustive search through all possible inputs up to a particular size. Recently, I decided to conduct such an experiment. Here are&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Some results&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I managed to collect some results [1]. First of all, I had to pick a particular definition for "size" of a λ-term, because there are many. I chose the one that is used in A220894 [2]:&lt;br /&gt;&lt;br /&gt;size(x) = 0;&lt;br /&gt;size(λx.M) = 1 + size(M);&lt;br /&gt;size(M N) = 1 + size(M) + size(N).&lt;br /&gt;&lt;br /&gt;For sizes from 1 to 9, inclusively, there exist 5663121 closed λ-terms. I tested all of them against both "abstract" [3] and "optimal" [4] algorithms in MLC, with up to 250 interactions per term. The process took almost a day of CPU time. Then, I automatically compared them [5] using a simple awk(1) script (also available in [1]), looking for terms for which normal form or number of β-reductions using "abstract" would deviate from "optimal".&lt;br /&gt;&lt;br /&gt;No such terms have been found this way. Surprisingly, there have been identified apparent Lambdascope counterexamples instead, the shortest of which is λx.(λy.y y) (λy.x (λz.y)) resulting in a fan that reaches the interaction net interface. I plan to look into this in near future.&lt;br /&gt;&lt;br /&gt;As for sizes higher than 9, testing quickly becomes unfeasible. For example, there are 69445532 closed terms of sizes from 1 to 10, inclusively, which takes a lot of time and space just to generate and save them. [6] is a 200MB gzip(1)'ed tarball (4GB unpacked) with all these terms split into 52 files with 1335491 terms each. In my current setting, it is unfeasible to test them.&lt;br /&gt;&lt;br /&gt;I may come up with optimizations at some point to make it possible to process terms of sizes up to 10, but 11 and higher look completely hopeless to me.&lt;br /&gt;&lt;br /&gt;[1] &lt;a href="https://gist.github.com/codedot/3b99edd504678e160999f12cf30da420"&gt;https://gist.github.com/codedot/3b99edd504678e160999f12cf30da420&lt;/a&gt;&lt;br /&gt;[2] &lt;a href="http://oeis.org/A220894"&gt;http://oeis.org/A220894&lt;/a&gt;&lt;br /&gt;[3] &lt;a href="https://drive.google.com/open?id=1O2aTULUXuLIl3LArehMtwmoQiIGB62-A"&gt;https://drive.google.com/open?id=1O2aTULUXuLIl3LArehMtwmoQiIGB62-A&lt;/a&gt;&lt;br /&gt;[4] &lt;a href="https://drive.google.com/open?id=16W_HSmwlRB6EAW5XxwVb4MqvkEZPf9HN"&gt;https://drive.google.com/open?id=16W_HSmwlRB6EAW5XxwVb4MqvkEZPf9HN&lt;/a&gt;&lt;br /&gt;[5] &lt;a href="https://drive.google.com/open?id=1ldxxnbzdxZDk5-9VMDzLvS7BouxwbCfH"&gt;https://drive.google.com/open?id=1ldxxnbzdxZDk5-9VMDzLvS7BouxwbCfH&lt;/a&gt;&lt;br /&gt;[6] &lt;a href="https://drive.google.com/open?id=1XjEa-N40wSqmSWnesahnxz6SXVUzzBig"&gt;https://drive.google.com/open?id=1XjEa-N40wSqmSWnesahnxz6SXVUzzBig&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=181371" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:181057</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/181057.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=181057"/>
    <title>Bitcoin Proof of Work in Pure Lambda Calculus</title>
    <published>2017-11-24T20:40:27Z</published>
    <updated>2017-12-01T17:33:11Z</updated>
    <category term="howtos"/>
    <category term="elementary mathematics"/>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <dw:security>public</dw:security>
    <dw:reply-count>3</dw:reply-count>
    <content type="html">From &lt;a href="https://codedot.dreamwidth.org/158739.html"&gt;command line&lt;/a&gt; to MLC:&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; npm i -g &lt;a href="https://www.npmjs.com/package/@alexo/lambda"&gt;@alexo/lambda&lt;/a&gt;
&lt;span style="color: #888888"&gt;└── @alexo/lambda@0.3.6&lt;/span&gt;

&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; node work2mlc.js getwork.json 381353fa | tee test.mlc
&lt;span style="color: #888888"&gt;Mid = x: x&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(24e39e50)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(1efebbc8)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(fb545b91)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(db1ff3ca)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(a66f356d)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(7482c0f3)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(acc0caa8)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(00f10dad);&lt;/span&gt;

&lt;span style="color: #888888"&gt;Data = x: x&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(a7f5f990)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(fd270c51)&lt;/span&gt;
&lt;span style="color: #888888"&gt;        hex(378a0e1c);&lt;/span&gt;

&lt;span style="color: #888888"&gt;Nonce = hex(381353fa);&lt;/span&gt;

&lt;span style="color: #888888"&gt;Zero32 (Pop 8 (RunHash Mid Data Nonce))&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; lambda -pem lib.mlc -f test.mlc
&lt;span style="color: #888888"&gt;3335648(653961), 17837 ms&lt;/span&gt;
&lt;span style="color: #888888"&gt;v1, v2: v1&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="https://gist.github.com/codedot/721469173df8dd197ba5bddbe022c487"&gt;https://gist.github.com/codedot/721469173df8dd197ba5bddbe022c487&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=181057" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:180914</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/180914.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=180914"/>
    <title>Implementation of SHA-256 in Macro Lambda Calculus</title>
    <published>2017-11-22T20:15:04Z</published>
    <updated>2017-11-24T21:18:18Z</updated>
    <category term="howtos"/>
    <category term="elementary mathematics"/>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="https://gist.github.com/codedot/721469173df8dd197ba5bddbe022c487"&gt;https://gist.github.com/codedot/721469173df8dd197ba5bddbe022c487&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; npm i -g &lt;a href="https://www.npmjs.com/package/@alexo/lambda"&gt;@alexo/lambda&lt;/a&gt;
&lt;span style="color: #888888"&gt;└── @alexo/lambda@0.3.6&lt;/span&gt;

&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; make
&lt;span style="color: #888888"&gt;	shasum -a 256 /dev/null&lt;/span&gt;
&lt;span style="color: #888888"&gt;e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  /dev/null&lt;/span&gt;
&lt;span style="color: #888888"&gt;	lambda -pem lib.mlc &amp;#39;Pri32 hex(e3b0c442)&amp;#39;&lt;/span&gt;
&lt;span style="color: #888888"&gt;857(230), 19 ms&lt;/span&gt;
&lt;span style="color: #888888"&gt;_1 _1 _1 _0 _0 _0 _1 _1 _1 _0 _1 _1 _0 _0 _0 _0 _1 _1 _0 _0 _0 _1 _0 _0 _0 _1 _0 _0 _0 _0 _1 _0&lt;/span&gt;
&lt;span style="color: #888888"&gt;	lambda -pem lib.mlc &amp;#39;Pri32 (Shift 8 (Hash1 NullMsg))&amp;#39;&lt;/span&gt;
&lt;span style="color: #888888"&gt;3247721(688463), 17211 ms&lt;/span&gt;
&lt;span style="color: #888888"&gt;_1 _1 _1 _0 _0 _0 _1 _1 _1 _0 _1 _1 _0 _0 _0 _0 _1 _1 _0 _0 _0 _1 _0 _0 _0 _1 _0 _0 _0 _0 _1 _0&lt;/span&gt;
&lt;span style="color: #888888"&gt;	shasum -a 256 &amp;lt;/dev/null | xxd -r -p | shasum -a 256&lt;/span&gt;
&lt;span style="color: #888888"&gt;5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456  -&lt;/span&gt;
&lt;span style="color: #888888"&gt;	lambda -pem lib.mlc &amp;#39;Pri32 hex(5df6e0e2)&amp;#39;&lt;/span&gt;
&lt;span style="color: #888888"&gt;856(230), 15 ms&lt;/span&gt;
&lt;span style="color: #888888"&gt;_0 _1 _0 _1 _1 _1 _0 _1 _1 _1 _1 _1 _0 _1 _1 _0 _1 _1 _1 _0 _0 _0 _0 _0 _1 _1 _1 _0 _0 _0 _1 _0&lt;/span&gt;
&lt;span style="color: #888888"&gt;	lambda -pem lib.mlc &amp;#39;Pri32 (Shift 8 (Hash2 NullMsg))&amp;#39;&lt;/span&gt;
&lt;span style="color: #888888"&gt;6448027(1373506), 38750 ms&lt;/span&gt;
&lt;span style="color: #888888"&gt;_0 _1 _0 _1 _1 _1 _0 _1 _1 _1 _1 _1 _0 _1 _1 _0 _1 _1 _1 _0 _0 _0 _0 _0 _1 _1 _1 _0 _0 _0 _1 _0&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=180914" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:178694</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/178694.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=178694"/>
    <title>Useful Software</title>
    <published>2017-06-02T09:27:00Z</published>
    <updated>2017-06-03T06:43:03Z</updated>
    <category term="favorites"/>
    <category term="howtos"/>
    <category term="computers"/>
    <category term="personal"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>2</dw:reply-count>
    <content type="html">&lt;p&gt;&lt;b&gt;Command line&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/"&gt;POSIX&lt;/a&gt; (XCU "Shell &amp; Utilities"): &lt;code&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html"&gt;vi&lt;/a&gt;(1)&lt;/code&gt;, &lt;code&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html"&gt;awk&lt;/a&gt;(1)&lt;/code&gt;, &lt;code&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html"&gt;make&lt;/a&gt;(1)&lt;/code&gt;, &lt;code&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/bc.html"&gt;bc&lt;/a&gt;(1)&lt;/code&gt;, &lt;code&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html"&gt;sed&lt;/a&gt;(1)&lt;/code&gt;, &lt;code&gt;grep(1)&lt;/code&gt;, &lt;code&gt;sort(1)&lt;/code&gt;, &lt;code&gt;uniq(1)&lt;/code&gt;, &lt;code&gt;tee(1)&lt;/code&gt;, &lt;code&gt;wc(1)&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/screen/"&gt;GNU Screen&lt;/a&gt; (useful to &lt;code&gt;echo exec screen -xR &amp;gt;&amp;gt;~/.profile&lt;/code&gt; on a remote host)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/"&gt;Git&lt;/a&gt;: &lt;code&gt;git-grep(1)&lt;/code&gt;, &lt;code&gt;git-stash(1)&lt;/code&gt;, &lt;code&gt;git-bisect(1)&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ledger-cli.org/"&gt;Ledger&lt;/a&gt; (useful for optimizing both finances and &lt;a href="https://codedot.dreamwidth.org/178514.html"&gt;time&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://taskwarrior.org/"&gt;Taskwarrior&lt;/a&gt; (TODO manager, highly recommended)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/odeke-em/drive"&gt;drive&lt;/a&gt; (one of CLIs for Google Drive)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jekyllrb.com/"&gt;Jekyll&lt;/a&gt; (generates static websites from markdown)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Web&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://musescore.org/"&gt;MuseScore&lt;/a&gt; (large sheet music library)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://app.flowkey.com/"&gt;flowkey&lt;/a&gt; (supports WebMIDI)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://feedly.com/"&gt;Feedly&lt;/a&gt; (RSS reader)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.plex.tv/"&gt;Plex&lt;/a&gt; (media server)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ovh.com/us/vps/vps-ssd.xml"&gt;OVH VPS SSD&lt;/a&gt; (affordable VPS)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://letsencrypt.org/"&gt;Let's Encrypt&lt;/a&gt; (automated free SSL certificates)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Chrome OS&lt;/b&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://keep.google.com/"&gt;Google Keep&lt;/a&gt; (quite convenient for grocery lists)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://drive.google.com/"&gt;Google Drive&lt;/a&gt; (directly accessible in Chrome OS' Files)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chrome.google.com/webstore/detail/secure-shell/pnhechapfaindjhompbnflcldabbghjo"&gt;Secure Shell&lt;/a&gt; (the main SSH client for Chrome OS, supports SFTP in Files and SSH bookmarks, type &lt;code&gt;ssh name@example.com&lt;/code&gt; in the address field)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chrome.google.com/webstore/detail/wolframalpha-official/icncamkooinmbehmkeilcccmoljfkdhp"&gt;Wolfram Alpha&lt;/a&gt; (type &lt;code&gt;= universe age in planck times&lt;/code&gt; in the address field)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;i&gt;Disclaimer: I'm celebrating five years as a Chromebook user.&lt;/i&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=178694" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:178514</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/178514.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=178514"/>
    <title>How to Profile Google Calendar</title>
    <published>2017-05-30T09:21:24Z</published>
    <updated>2017-05-30T12:47:54Z</updated>
    <category term="personal"/>
    <category term="howtos"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;p&gt;Here is one way to profile calendars:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Export calendars in iCalendar format.&lt;/li&gt;
&lt;li&gt;Check out &lt;a href="https://gist.github.com/codedot/1cce55b4fd354b470becb8ce341b6598"&gt;this Awk script&lt;/a&gt;:
&lt;p&gt;
&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #008800; font-weight: bold"&gt;function&lt;/span&gt; parse(dt)
{
	Y &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;1&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;4&lt;/span&gt;);
	M &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;5&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;2&lt;/span&gt;);
	D &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;7&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;2&lt;/span&gt;);
	h &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;10&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;2&lt;/span&gt;);
	m &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;12&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;2&lt;/span&gt;);
	s &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;substr&lt;/span&gt;(dt, &lt;span style="color: #0000DD; font-weight: bold"&gt;14&lt;/span&gt;, &lt;span style="color: #0000DD; font-weight: bold"&gt;2&lt;/span&gt;);

	&lt;span style="color: #008800; font-weight: bold"&gt;return&lt;/span&gt; Y &lt;span style="background-color: #fff0f0"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; M &lt;span style="background-color: #fff0f0"&gt;&amp;quot;/&amp;quot;&lt;/span&gt; D &lt;span style="background-color: #fff0f0"&gt;&amp;quot; &amp;quot;&lt;/span&gt; h &lt;span style="background-color: #fff0f0"&gt;&amp;quot;:&amp;quot;&lt;/span&gt; m &lt;span style="background-color: #fff0f0"&gt;&amp;quot;:&amp;quot;&lt;/span&gt; s;
}

&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^BEGIN:VEVENT/&lt;/span&gt; {
	dtstart &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
	dtend &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
	summary &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
}

&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^DTSTART:/&lt;/span&gt; {
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/\r$/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^DTSTART:/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	dtstart &lt;span style="color: #333333"&gt;=&lt;/span&gt; parse(&lt;span style="color: #333333"&gt;$&lt;/span&gt;&lt;span style="color: #0000DD; font-weight: bold"&gt;0&lt;/span&gt;);
}

&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^DTEND:/&lt;/span&gt; {
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/\r$/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^DTEND:/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	dtend &lt;span style="color: #333333"&gt;=&lt;/span&gt; parse(&lt;span style="color: #333333"&gt;$&lt;/span&gt;&lt;span style="color: #0000DD; font-weight: bold"&gt;0&lt;/span&gt;);
}

&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^SUMMARY:/&lt;/span&gt; {
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/\r$/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	&lt;span style="color: #008800; font-weight: bold"&gt;sub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^SUMMARY:/&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;&amp;quot;&lt;/span&gt;);
	&lt;span style="color: #008800; font-weight: bold"&gt;gsub&lt;/span&gt;(&lt;span style="color: #000000; background-color: #fff0ff"&gt;/  */&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot; &amp;quot;&lt;/span&gt;);
	summary &lt;span style="color: #333333"&gt;=&lt;/span&gt; &lt;span style="color: #333333"&gt;$&lt;/span&gt;&lt;span style="color: #0000DD; font-weight: bold"&gt;0&lt;/span&gt;;
}

&lt;span style="color: #000000; background-color: #fff0ff"&gt;/^END:VEVENT/&lt;/span&gt; {
	&lt;span style="color: #008800; font-weight: bold"&gt;if&lt;/span&gt; (dtstart &lt;span style="color: #333333"&gt;&amp;amp;&amp;amp;&lt;/span&gt; dtend &lt;span style="color: #333333"&gt;&amp;amp;&amp;amp;&lt;/span&gt; summary) {
		&lt;span style="color: #008800; font-weight: bold"&gt;print&lt;/span&gt; &lt;span style="background-color: #fff0f0"&gt;&amp;quot;i &amp;quot;&lt;/span&gt; dtstart &lt;span style="background-color: #fff0f0"&gt;&amp;quot; &amp;quot;&lt;/span&gt; prefix summary;
		&lt;span style="color: #008800; font-weight: bold"&gt;print&lt;/span&gt; &lt;span style="background-color: #fff0f0"&gt;&amp;quot;o &amp;quot;&lt;/span&gt; dtend;
	}
}
&lt;/pre&gt;&lt;/div&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;Have &lt;a href="http://ledger-cli.org/"&gt;the Ledger utility&lt;/a&gt; installed:
&lt;pre&gt;sudo apt install ledger # or whatever&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
Convert the exported ICS files to timelog format:
&lt;pre&gt;awk -f ics2tc.awk *.ics &amp;gt;timelog.tc&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
Generate various reports from timelog, for example:
&lt;pre&gt;ledger -f timelog.tc b -S -T&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
Optionally specify a prefix:
&lt;pre&gt;awk -f ics2tc.awk -v prefix=Work: Work.ics &amp;gt;Work.tc&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
Or even create a Makefile like this:
&lt;p&gt;
&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #996633"&gt;TIMELOGS&lt;/span&gt; &lt;span style="color: #333333"&gt;=&lt;/span&gt; Anna.tc David.tc

&lt;span style="color: #0066BB; font-weight: bold"&gt;all&lt;/span&gt;&lt;span style="color: #333333"&gt;:&lt;/span&gt; &lt;span style="color: #6600EE; font-weight: bold"&gt;$(TIMELOGS)&lt;/span&gt;

&lt;span style="color: #0066BB; font-weight: bold"&gt;clean&lt;/span&gt;&lt;span style="color: #333333"&gt;:&lt;/span&gt;
	-rm -f &lt;span style="color: #008800; font-weight: bold"&gt;$(&lt;/span&gt;TIMELOGS&lt;span style="color: #008800; font-weight: bold"&gt;)&lt;/span&gt;

&lt;span style="color: #0066BB; font-weight: bold"&gt;.SUFFIXES&lt;/span&gt;&lt;span style="color: #333333"&gt;:&lt;/span&gt; &lt;span style="color: #6600EE; font-weight: bold"&gt;.ics .tc&lt;/span&gt;

&lt;span style="color: #0066BB; font-weight: bold"&gt;.ics.tc&lt;/span&gt;&lt;span style="color: #333333"&gt;:&lt;/span&gt;
	awk -f ics2tc.awk -v &lt;span style="color: #996633"&gt;prefix&lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #996633"&gt;$*&lt;/span&gt;: &lt;span style="color: #996633"&gt;$&amp;lt;&lt;/span&gt; &amp;gt;&lt;span style="color: #996633"&gt;$@&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;?????&lt;/li&gt;
&lt;li&gt;PROFIT!!1oneone&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=178514" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:177489</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/177489.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=177489"/>
    <title>How to Fix a Bug with Git</title>
    <published>2017-03-06T21:54:08Z</published>
    <updated>2017-03-07T01:16:33Z</updated>
    <category term="howtos"/>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">I am currently working on implementing &lt;a href="http://codedot.dreamwidth.org/177163.html"&gt;needed reduction&lt;/a&gt; for interaction nets. To do that, I first needed to refactor a lot of somewhat ugly fast-written code in &lt;code&gt;&lt;a href="https://github.com/codedot/inet-lib"&gt;inet-lib&lt;/a&gt;&lt;/code&gt;. At some point, I changed retrieving an element from an array to &lt;code&gt;.pop()&lt;/code&gt; from &lt;code&gt;.shift()&lt;/code&gt;, just because in JavaScript the former happens to be a cheaper operation than the latter.&lt;br /&gt;&lt;br /&gt;Many commits later, I decided to play with the program a little bit and compare performance between &lt;code&gt;.shift()&lt;/code&gt;ing and &lt;code&gt;.pop()&lt;/code&gt;ing. Boom! The program appeared to be broken. Even worse, invariance of the queue that is represented by that array with respect to the order in which it is processed is the whole point of interaction nets, namely the property of strong confluence also known as the one-step diamond property. I thought I fucked up hard.&lt;br /&gt;&lt;br /&gt;First, I took a look at &lt;code&gt;git-blame(1)&lt;/code&gt; for the line of code that calls &lt;code&gt;.pop()&lt;/code&gt;, and found the &lt;a href="https://github.com/codedot/inet-lib/commit/28b3bf847a0f930ab72c1f73425dab56cf831390"&gt;corresponding commit&lt;/a&gt;. Then, I marked its parent commit as good with &lt;code&gt;git-bisect(1)&lt;/code&gt;. After a few steps, &lt;code&gt;git-bisect(1)&lt;/code&gt; found the &lt;a href="https://github.com/codedot/inet-lib/commit/9242e8b901586b0b235bdda73f572122feb4a6c6"&gt;first bad commit&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Evidently, the problem had something to do with indirection applied by non-deterministic extension of interaction nets. And it did not take more than a couple of minutes to figure out a &lt;a href="https://github.com/codedot/inet-lib/commit/bad862c485c178564ef0da7dd74366b9a3479f3b"&gt;simple one-liner fix&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Overall, it took less than half an hour from finding a bug to fixing it which I first thought would take hours if not days. To me, it looks like yet another evidence that the idea of &lt;code&gt;git-bisect(1)&lt;/code&gt; is totally genius. So, thanks again, Linus!&lt;br /&gt;&lt;br /&gt;P. S. Free advice: when making commits, it is always useful to keep in mind 1) a possible need to &lt;code&gt;git-grep(1)&lt;/code&gt; some lines of code later, and 2) almost inevitable need to deal with bugs which is a lot easier when commits are suitable for &lt;code&gt;git-bisect(1)&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=177489" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:176609</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/176609.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=176609"/>
    <title>POSIX.1-2016</title>
    <published>2016-09-30T15:13:50Z</published>
    <updated>2016-09-30T15:13:50Z</updated>
    <category term="computers"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/"&gt;http://pubs.opengroup.org/onlinepubs/9699919799/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Только что опубликовали IEEE 1003.1-2008+TC1+TC2.&lt;br /&gt;&lt;br /&gt;В список участников TC2 мое имя попало в связи с багами 735-737 против TC1:&lt;br /&gt;&lt;br /&gt;&lt;a href="https://codedot.dreamwidth.org/166992.html"&gt;https://codedot.dreamwidth.org/166992.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Теперь грамматика языка Shell не содержит shift/reduce-конфликтов (можно засунуть ее в yacc(1) и убедиться, раньше было пять конфликтов), лишена двух лишних правил, а также корректно описывает произвольное количество команд в скриптах.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=176609" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:176096</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/176096.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=176096"/>
    <title>Interactive Tonnetz</title>
    <published>2016-09-03T08:52:53Z</published>
    <updated>2016-09-03T10:36:48Z</updated>
    <category term="programming"/>
    <category term="ideas"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;p&gt;The &lt;a href="https://en.wikipedia.org/wiki/Tonnetz"&gt;Tonnetz&lt;/a&gt; is a lattice diagram representing tonal space. It can be used to visualize harmonic relationships in music. Each node in the diagram corresponds to one of the twelve tones and is connected to six adjacent tones that are related to it by a major third, a minor third, or by a perfect fifth, depending on their relative position in the diagram.&lt;/p&gt;

&lt;p&gt;I &lt;a href="https://github.com/codedot/tonnetz"&gt;forked&lt;/a&gt; on GitHub the source code of &lt;a href="https://cifkao.github.io/tonnetz-viz/"&gt;TonnetzViz&lt;/a&gt; created by Ondřej Cífka and implemented the following features:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;zero configuration without any menus;&lt;/li&gt;
&lt;li&gt;Tonnetz-like keyboard layout;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Shepard_tone"&gt;Shepard tones&lt;/a&gt; using &lt;a href="https://webaudio.github.io/web-audio-api/"&gt;Web Audio&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;plug and play &lt;a href="https://webaudio.github.io/web-midi-api/"&gt;Web MIDI&lt;/a&gt; support;&lt;/li&gt;
&lt;li&gt;blue minor and red major triads;&lt;/li&gt;
&lt;li&gt;Tonnetz bent to represent halftones;&lt;/li&gt;
&lt;li&gt;Shift key to sustain notes;&lt;/li&gt;
&lt;li&gt;and arrow keys to transpose.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now the live version is available at&lt;/p&gt;
&lt;p&gt;&lt;a href="https://codedot.github.io/tonnetz/"&gt;https://codedot.github.io/tonnetz/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="https://pbs.twimg.com/media/CraoB7KWcAAYkC4.jpg"&gt;&lt;/img&gt;&lt;p&gt;&lt;/p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=176096" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:170715</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/170715.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=170715"/>
    <title>Y (K M) = M</title>
    <published>2014-08-10T19:20:48Z</published>
    <updated>2014-08-12T18:11:15Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">Encoding ω Α (K ω), where ω ≡ λx.x x, A ≡ λx.λf.f (x x f), and K ≡ λx.λy.x:&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; cat init.txt 
&lt;span style="color: #888888"&gt;term = \read_{strdup(&amp;quot;&amp;quot;)}(\print);&lt;/span&gt;

&lt;span style="color: #888888"&gt;term = \apply(\apply(omega1, a), \apply(k, omega2));&lt;/span&gt;

&lt;span style="color: #888888"&gt;omega1 = \lambda(x1, \apply(\amb(y1, \share(x1, z1), z1), y1));&lt;/span&gt;
&lt;span style="color: #888888"&gt;omega2 = \lambda(x2, \apply(\amb(y2, \share(x2, z2), z2), y2));&lt;/span&gt;

&lt;span style="color: #888888"&gt;a = \lambda(self, \lambda(func, \apply(func1, rec)));&lt;/span&gt;
&lt;span style="color: #888888"&gt;rec = \apply(\apply(self1, self2), func2);&lt;/span&gt;
&lt;span style="color: #888888"&gt;self1 = \amb(self2, \share(self, back1), back1);&lt;/span&gt;
&lt;span style="color: #888888"&gt;func1 = \amb(func2, \share(func, back2), back2);&lt;/span&gt;

&lt;span style="color: #888888"&gt;k = \lambda(x, \lambda(\erase, x));&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; make
&lt;span style="color: #888888"&gt;        printf &amp;#39;%s\n\n$$\n\n%s\n\n$$\n\n%s\n&amp;#39; &amp;gt;test.in \&lt;/span&gt;
&lt;span style="color: #888888"&gt;                &amp;quot;`cat rset.txt`&amp;quot; \&lt;/span&gt;
&lt;span style="color: #888888"&gt;                &amp;quot;`cat init.txt`&amp;quot; \&lt;/span&gt;
&lt;span style="color: #888888"&gt;                &amp;quot;`cat tail.txt`&amp;quot;&lt;/span&gt;
&lt;span style="color: #888888"&gt;        inc &amp;lt;test.in&lt;/span&gt;
&lt;span style="color: #888888"&gt;        mv in.tab.c test.c&lt;/span&gt;
&lt;span style="color: #888888"&gt;        cc    -o test test.c &lt;/span&gt;
&lt;span style="color: #888888"&gt;        valgrind ./test&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== Memcheck, a memory error detector&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== Copyright (C) 2002-2010, and GNU GPL&amp;#39;d, by Julian Seward et al.&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== Command: ./test&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== &lt;/span&gt;
&lt;span style="color: #888888"&gt;v1: (v1 (v1))&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== &lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== HEAP SUMMARY:&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346==     in use at exit: 0 bytes in 0 blocks&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346==   total heap usage: 606 allocs, 606 frees, 23,934 bytes allocated&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== &lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== All heap blocks were freed -- no leaks are possible&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== &lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== For counts of detected and suppressed errors, rerun with: -v&lt;/span&gt;
&lt;span style="color: #888888"&gt;==20346== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=170715" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:170431</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/170431.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=170431"/>
    <title>Call-by-Need Evaluation Strategy</title>
    <published>2014-08-10T13:03:11Z</published>
    <updated>2014-08-12T18:07:50Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="https://gist.github.com/codedot/24f277ef4df5828c70a8"&gt;https://gist.github.com/codedot/24f277ef4df5828c70a8&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Call-by-need evaluation strategy using non-deterministic extension in &lt;a href="https://github.com/euromake/inet"&gt;Interaction Nets Compiler&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #800080; font-weight: bold"&gt;@@ -14,10 +14,18 @@&lt;/span&gt;
 \print {
 	/* Output results of read-back. */
 	puts(RVAL);
&lt;span style="color: #A00000"&gt;-	exit(EXIT_SUCCESS);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	free(RVAL);&lt;/span&gt;
 } \atom;
 
 \read[a] {
&lt;span style="color: #00A000"&gt;+	/* Unshare variable. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \share[\copy(b, \read_{LVAL}(a)), b];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\read[a] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Initiate application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \apply[\lambda(b, \read_{LVAL}(a)), b];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\read[a] {&lt;/span&gt;
 	/* Read back abstraction. */
 } \lambda[\atom_{var(1)}, \read_{ABST(LVAL, var(0))}(a)];
 
&lt;span style="color: #800080; font-weight: bold"&gt;@@ -29,10 +37,6 @@&lt;/span&gt;
 	/* Read back an atom. */
 } \atom;
 
&lt;span style="color: #A00000"&gt;-\bind[a, \atom_{RVAL}, a] {&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-	/* Bind variable to an atom. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \atom;&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-&lt;/span&gt;
 \copy[\atom_{RVAL}, \atom_{strdup(RVAL)}] {
 	/* Copy an atom. */
 } \atom;
&lt;span style="color: #800080; font-weight: bold"&gt;@@ -47,40 +51,56 @@&lt;/span&gt;
 } \atom;
 
 \lambda[a, b] {
&lt;span style="color: #00A000"&gt;+	/* Unshare variable. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \share[\copy(c, \lambda(a, b)), c];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\lambda[a, b] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Initiate application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \apply[\lambda(c, \lambda(a, b)), c];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\lambda[a, b] {&lt;/span&gt;
 	/* Apply a closed term. */
 } \lambda[a, b];
 
&lt;span style="color: #00A000"&gt;+\copy[a, b] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Unshare variable. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \share[\copy(c, \copy(a, b)), c];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\copy[a, b] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Initiate application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \apply[\lambda(c, \copy(a, b)), c];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
 \copy[\lambda(a, b), \lambda(c, d)] {
 	/* Initiate copy of a closed term. */
 } \lambda[\dup(a, c), \dup(b, d)];
 
&lt;span style="color: #A00000"&gt;-\bind[a, \lambda(b, c), a] {&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-	/* Bind variable to a closed term. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \lambda[b, c];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\dup[\amb(a, \share(b, c), c), \amb(d, \share(e, f), f)] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Duplicate sharing. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \share[\dup(b, e), \dup(a, d)];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\dup[\apply(a, b), \apply(c, d)] {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Duplicate application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \apply[\dup(a, c), \dup(b, d)];&lt;/span&gt;
 
 \dup[\lambda(a, b), \lambda(c, d)] {
&lt;span style="color: #A00000"&gt;-	/* Duplicate abstraction or application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Duplicate abstraction. */&lt;/span&gt;
 } \lambda[\dup(a, c), \dup(b, d)];
 
&lt;span style="color: #A00000"&gt;-\dup[\copy(a, b), \copy(c, d)] {&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-	/* Duplicate copy initiator. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \copy[\dup(a, c), \dup(b, d)];&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-\dup[\bind(a, b, c), \bind(d, e, f)] {&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-	/* Duplicate variable binding. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \bind[\dup(a, d), \dup(b, e), \dup(c, f)];&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-&lt;/span&gt;
 \dup[a, b] {
 	/* Finish duplication. */
 } \dup[a, b];
 
 \erase {
&lt;span style="color: #A00000"&gt;-	/* Erase abstraction or application. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \lambda[\erase, \erase];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Erase sharing. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \share[a, a];&lt;/span&gt;
 
 \erase {
&lt;span style="color: #A00000"&gt;-	/* Erase variable binding. */&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-} \bind[\erase, \erase, \erase];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Erase application. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \apply[\erase, \erase];&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\erase {&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+	/* Erase abstraction. */&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+} \lambda[\erase, \erase];&lt;/span&gt;
 
 \erase {
 	/* Erase copy initiator. */
&lt;span style="color: #800080; font-weight: bold"&gt;@@ -96,17 +116,12 @@&lt;/span&gt;
 
 $$
 
&lt;span style="color: #A00000"&gt;-{&amp;quot;Application&amp;quot;} = result;&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-function = \lambda(argument, result);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-shared1 = \copy(first1, second1);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-shared2 = \copy(first2, second2);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-shared3 = \copy(first3, second3);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-{&amp;quot;Abstraction&amp;quot;} = bind0;&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-bv1 = \bind(bind1, fv1, bind0);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-bv2 = \bind(bind2, fv2, bind1);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-bv3 = \bind(bind3, fv3, bind2);&lt;/span&gt;
&lt;span style="color: #A00000"&gt;-bindn = \lambda(variable, body);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+{&amp;quot;Application&amp;quot;} = \apply(function, argument);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+first1 = \amb(second1, \share(shared1, back1), back1);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+first2 = \amb(second2, \share(shared2, back2), back2);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+first3 = \amb(second3, \share(shared3, back3), back3);&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+{&amp;quot;Abstraction&amp;quot;} = \lambda(variable, body);&lt;/span&gt;
 
 term = \read_{strdup(&amp;quot;&amp;quot;)}(\print);
 term = {&amp;quot;Encoding&amp;quot;};&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=170431" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:170218</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/170218.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=170218"/>
    <title>Поддержка недетерминированного расширения в INC</title>
    <published>2014-08-09T12:14:50Z</published>
    <updated>2014-08-09T12:17:54Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">В &lt;a href="https://github.com/euromake/inet/wiki"&gt;компиляторе сетей взаимодействия&lt;/a&gt; INC (Interaction Nets Compiler) теперь есть поддержка &lt;a href="http://arxiv.org/pdf/1304.1309.pdf"&gt;недетерминированного расширения&lt;/a&gt; в виде специального бинарного агента Amb с двумя главными портами. Это расширение необходимо при реализации &lt;a href="http://www.sciencedirect.com/science/article/pii/S1571066106000934"&gt;стратегии "call-by-need" для λ-исчисления&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Синтаксис для недетерминированного расширения сетей взаимодействия выбран наиболее консервативным образом (по отношению к основной части языка программирования) и отличается от того, который &lt;a href="http://www.sciencedirect.com/science/article/pii/S1571066105803639"&gt;встречается в литературе&lt;/a&gt;: при описании правил взаимодействия и начальной конфигурации агент Amb обозначается как тернарный, первый дополнительный порт которого выполняет роль второго главного. К примеру, следующее изменение не меняет поведение &lt;a href="https://github.com/euromake/inet/blob/master/example.in"&gt;тестовой программы&lt;/a&gt;: &lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt; 
 $$
 
&lt;span style="color: #A00000"&gt;-\fan_{1}(x, x) = \fan_{2}(\erase, {&amp;amp;wire1});&lt;/span&gt;
&lt;span style="color: #00A000"&gt;+\fan_{1}(x, x) = \amb({&amp;amp;wire1}, \fan_{2}(\erase, y), y);&lt;/span&gt;
 
 {&amp;amp;wire2} = \fan_{3}({&amp;amp;erase}, \erase);
 &lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=170218" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:169787</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/169787.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=169787"/>
    <title>Read-Back Extension</title>
    <published>2014-07-28T13:51:37Z</published>
    <updated>2014-08-03T09:44:39Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">Decoding extension for &lt;a href="http://codedot.dreamwidth.org/169624.html"&gt;Implementation of Closed Reduction&lt;/a&gt; using &lt;a href="https://github.com/euromake/inet"&gt;Interaction Nets Compiler&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="background-color: #fff0f0"&gt;$&lt;/span&gt;&lt;span style="color: #007020"&gt;{&lt;/span&gt;
&lt;span style="color: #007020"&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span style="color: #007020"&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&lt;span style="color: #007020"&gt;#include &amp;lt;string.h&amp;gt;&lt;/span&gt;

&lt;span style="color: #007020"&gt;char &lt;/span&gt;&lt;span style="color: #333333"&gt;*&lt;/span&gt;&lt;span style="color: #007020"&gt;var&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;int fresh&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;char &lt;/span&gt;&lt;span style="color: #333333"&gt;*&lt;/span&gt;&lt;span style="color: #007020"&gt;append&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;char &lt;/span&gt;&lt;span style="color: #333333"&gt;*&lt;/span&gt;&lt;span style="color: #007020"&gt;format, char &lt;/span&gt;&lt;span style="color: #333333"&gt;*&lt;/span&gt;&lt;span style="color: #007020"&gt;buf, char &lt;/span&gt;&lt;span style="color: #333333"&gt;*&lt;/span&gt;&lt;span style="color: #007020"&gt;str&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;

&lt;span style="color: #007020"&gt;#define ABST&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;BUF, STR&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt; append&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #888888"&gt;%s%s: &amp;quot;, (BUF), (STR))&lt;/span&gt;
&lt;span style="color: #007020"&gt;#define APPL&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;BUF, STR&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt; append&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #888888"&gt;%s%s &amp;quot;, (BUF), (STR))&lt;/span&gt;
&lt;span style="color: #007020"&gt;#define ATOM&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;BUF, STR&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt; append&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #888888"&gt;%s(%s)&amp;quot;, (BUF), (STR))&lt;/span&gt;
&lt;span style="color: #007020"&gt;}&lt;/span&gt;&lt;span style="background-color: #fff0f0"&gt;$&lt;/span&gt;

&lt;span style="color: #008800; font-weight: bold"&gt;\print&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Output results of read-back. */
	puts(RVAL);
	exit(EXIT&lt;span style="color: #007020"&gt;_&lt;/span&gt;SUCCESS);
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\read&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Read back abstraction. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\atom_{var(1)}, \read_{ABST(LVAL, var(0))}(a)]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\read_{APPL(strdup(&amp;quot;&amp;quot;), RVAL)}(a), a]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Read back application. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\read&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\atom_{ATOM(LVAL, RVAL)}]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Read back an atom. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\bind&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, \atom_{RVAL}, a]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Bind variable to an atom. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\copy&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\atom_{RVAL}, \atom_{strdup(RVAL)}]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Copy an atom. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\atom_{RVAL}, \atom_{strdup(RVAL)}]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Duplicate an atom. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Erase an atom. */
	free(RVAL);
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\atom&lt;/span&gt;;

&lt;span style="background-color: #fff0f0"&gt;$$&lt;/span&gt;&lt;span style="color: #007020"&gt;&lt;/span&gt;

&lt;span style="color: #007020"&gt;term &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\read&lt;/span&gt;&lt;span style="color: #007020"&gt;_{strdup&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;}&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #996633"&gt;\print&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;term &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; {&amp;quot;Encoding&amp;quot;};&lt;/span&gt;

&lt;span style="background-color: #fff0f0"&gt;$$&lt;/span&gt;

char *var(int fresh)
&lt;span style="color: #007020"&gt;{&lt;/span&gt;
	static int id;

	char buf[BUFSIZ];

	if (fresh)
		++id;

	sprintf(buf, &amp;quot;v&lt;span style="color: #888888"&gt;%d&amp;quot;, id);&lt;/span&gt;
	return strdup(buf);
&lt;span style="color: #007020"&gt;}&lt;/span&gt;

char *append(char *format, char *buf, char *str)
&lt;span style="color: #007020"&gt;{&lt;/span&gt;
	size&lt;span style="color: #007020"&gt;_&lt;/span&gt;t size = strlen(format) + strlen(str);
	char *result = malloc(strlen(buf) + size);

	sprintf(result, format, buf, str);

	free(buf);
	free(str);
	return result;
&lt;span style="color: #007020"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=169787" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:169624</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/169624.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=169624"/>
    <title>Implementation of Closed Reduction</title>
    <published>2014-07-27T15:33:22Z</published>
    <updated>2014-07-29T07:34:00Z</updated>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://link.springer.com/chapter/10.1007/978-3-642-24452-0_3"&gt;An Interaction Net Implementation of Closed Reduction&lt;/a&gt; by Ian Mackie using &lt;a href="https://github.com/euromake/inet"&gt;Interaction Nets Compiler&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, b]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Apply a closed term. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, b]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\copy&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\lambda(a, b), \lambda(c, d)]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Initiate copy of a closed term. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\dup(a, c), \dup(b, d)]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\bind&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, \lambda(b, c), a]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Bind variable to a closed term. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[b, c]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\lambda(a, b), \lambda(c, d)]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Duplicate abstraction or application. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\dup(a, c), \dup(b, d)]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\copy(a, b), \copy(c, d)]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Duplicate copy initiator. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\copy&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\dup(a, c), \dup(b, d)]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\bind(a, b, c), \bind(d, e, f)]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Duplicate variable binding. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\bind&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\dup(a, d), \dup(b, e), \dup(c, f)]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, b]&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Finish duplication. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[a, b]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Erase abstraction or application. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\lambda&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\erase, \erase]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Erase variable binding. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\bind&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\erase, \erase, \erase]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Erase copy initiator. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\copy&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\erase, \erase]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Erase duplicator. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\dup&lt;/span&gt;&lt;span style="color: #0000CC"&gt;[\erase, \erase]&lt;/span&gt;;

&lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt; &lt;span style="color: #007020"&gt;{&lt;/span&gt;
	/* Finish erasing. */
&lt;span style="color: #007020"&gt;}&lt;/span&gt; &lt;span style="color: #008800; font-weight: bold"&gt;\erase&lt;/span&gt;;

&lt;span style="background-color: #fff0f0"&gt;$$&lt;/span&gt;&lt;span style="color: #007020"&gt;&lt;/span&gt;

&lt;span style="color: #007020"&gt;{&amp;quot;Application&amp;quot;} &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; result;&lt;/span&gt;
&lt;span style="color: #007020"&gt;function &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\lambda&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;argument, result&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;shared&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\copy&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;first&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #007020"&gt;, second&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;shared&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\copy&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;first&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #007020"&gt;, second&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;shared&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\copy&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;first&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #007020"&gt;, second&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;

&lt;span style="color: #007020"&gt;{&amp;quot;Abstraction&amp;quot;} &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;bv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\bind&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #007020"&gt;, fv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #007020"&gt;, bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;bv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\bind&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #007020"&gt;, fv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #007020"&gt;, bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;bv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\bind&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #007020"&gt;, fv&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #007020"&gt;, bind&lt;/span&gt;&lt;span style="color: #6600EE; font-weight: bold"&gt;2&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;
&lt;span style="color: #007020"&gt;bindn &lt;/span&gt;&lt;span style="color: #333333"&gt;=&lt;/span&gt;&lt;span style="color: #007020"&gt; &lt;/span&gt;&lt;span style="color: #996633"&gt;\lambda&lt;/span&gt;&lt;span style="color: #333333"&gt;(&lt;/span&gt;&lt;span style="color: #007020"&gt;variable, body&lt;/span&gt;&lt;span style="color: #333333"&gt;)&lt;/span&gt;&lt;span style="color: #007020"&gt;;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=169624" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:169326</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/169326.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=169326"/>
    <title>Hello Interaction Nets!</title>
    <published>2014-06-26T07:37:02Z</published>
    <updated>2014-06-26T07:39:04Z</updated>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;$ cat &amp;gt;hello.in 
${
#include &amp;lt;stdio.h&amp;gt;
}$

\alpha {
        printf(&amp;quot;%s %s!\n&amp;quot;, LVAL, RVAL);
} \beta;

$$

\alpha_{&amp;quot;Hello&amp;quot;} = \beta_{&amp;quot;World&amp;quot;};

$$

#include &amp;lt;stdlib.h&amp;gt;

inagent *inaux(void *aux, void *offline)
{
        return NULL;
}

int main()
{
        interact();
        return 0;
}
$ &lt;a href="https://github.com/euromake/inet"&gt;inc&lt;/a&gt; &amp;lt;hello.in
$ c99 in.tab.c
$ ./a.out
Hello World!
$ 
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=169326" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:169130</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/169130.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=169130"/>
    <title>Поддержка начальной конфигурации в INC</title>
    <published>2014-06-18T15:14:31Z</published>
    <updated>2014-06-24T21:28:56Z</updated>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">В &lt;a href="https://github.com/euromake/inet/wiki"&gt;компиляторе сетей взаимодействия&lt;/a&gt; INC (Interaction Nets Compiler) теперь есть поддержка начальной конфигурации. Конфигурация описывается на языке, близком к &lt;a href="http://arxiv.org/pdf/1304.1309v2.pdf"&gt;исчислению взаимодействия&lt;/a&gt;. Эта функциональность должна сильно упростить проект MLC: &lt;a href="https://github.com/euromake/mlc/blob/master/example.mlc"&gt;текст на языке MLC&lt;/a&gt; (Macro Lambda Calculus) можно будет целиком транслировать в исходный код для INC, а уже оттуда - в исполняемый код на Си. Трансляцию из MLC в INC можно сделать с помощью &lt;a href="http://arxiv.org/pdf/1304.2290v5.pdf"&gt;компактного представления λ-термов в сетях взаимодействия&lt;/a&gt; и &lt;a href="http://codedot.dreamwidth.org/145152.html"&gt;механизма "readback" в виде системы взаимодействия с побочными действиями&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Ниже пример работы INC.&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; inc &amp;lt;&lt;a href="https://github.com/euromake/inet/blob/master/example.in"&gt;example.in&lt;/a&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; c99 in.tab.c
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; ./a.out
&lt;span style="color: #888888"&gt;inaux: rewired&lt;/span&gt;
&lt;span style="color: #888888"&gt;inaux: returns&lt;/span&gt;
&lt;span style="color: #888888"&gt;inaux: returns&lt;/span&gt;
&lt;span style="color: #888888"&gt;inaux: returns&lt;/span&gt;
&lt;span style="color: #888888"&gt;fan_1 &amp;gt;&amp;lt; fan_2&lt;/span&gt;
&lt;span style="color: #888888"&gt;fan_3 &amp;gt;&amp;lt; fan_3&lt;/span&gt;
&lt;span style="color: #888888"&gt;erase &amp;gt;&amp;lt; fan_3&lt;/span&gt;
&lt;span style="color: #888888"&gt;fan_3 &amp;gt;&amp;lt; fan_3&lt;/span&gt;
&lt;span style="color: #888888"&gt;erase &amp;gt;&amp;lt; erase&lt;/span&gt;
&lt;span style="color: #888888"&gt;erase &amp;gt;&amp;lt; erase&lt;/span&gt;
&lt;span style="color: #c65d09; font-weight: bold"&gt;$&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=169130" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:166992</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/166992.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=166992"/>
    <title>Aardvark 735-737 Accepted (As Marked)</title>
    <published>2013-08-30T05:33:49Z</published>
    <updated>2013-08-30T11:17:19Z</updated>
    <category term="programming"/>
    <category term="talks"/>
    <category term="computers"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;i&gt;What's your status?&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Issue &lt;a href="http://codedot.dreamwidth.org/166192.html"&gt;735&lt;/a&gt; Resolved and &lt;b&gt;Accepted&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;Issue &lt;a href="http://codedot.dreamwidth.org/166612.html"&gt;736&lt;/a&gt; Needs an Interpretation and &lt;b&gt;Accepted&lt;/b&gt; as Marked by Don Cragun:&lt;br /&gt;&lt;pre&gt;Interpretation response
------------------------
The standard is unclear on this issue, and no conformance
distinction can be made between alternative implementations
based on this.  This is being referred to the sponsor.

Rationale:
-------------
The following changes make the grammar and text reflect existing
practice.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
On page 2350, lines 74801-74808, change

%start  complete_command
%%
complete_command : list separator
                 | list
                 ;

to:

%start program
%%
program          : linebreak complete_commands linebreak
                 | linebreak
                 ;
complete_commands: complete_commands newline_list complete_command
                 |                                complete_command
                 ;
complete_command : list separator_op
                 | list
                 ;

Cross-volume change to XRAT...

At page 3700 line 126612 section C.2.10 delete:

The start symbol of the grammar (complete_command) represents
either input from the command line or a shell script.  It is
repeatedly applied by the interpreter to its input and represents
a single "chunk" of that input as seen by the interpreter.&lt;/pre&gt;&lt;br /&gt;Issue &lt;a href="http://codedot.dreamwidth.org/166707.html"&gt;737&lt;/a&gt; Resolved and &lt;b&gt;Accepted&lt;/b&gt;.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=166992" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:166707</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/166707.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=166707"/>
    <title>Aardvark 737: two of Shell Grammar Rules unnecessary</title>
    <published>2013-08-17T12:01:02Z</published>
    <updated>2013-08-17T18:02:04Z</updated>
    <category term="programming"/>
    <category term="talks"/>
    <category term="computers"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://austingroupbugs.net/view.php?id=737"&gt;http://austingroupbugs.net/view.php?id=737&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02"&gt;Shell Grammar Rules&lt;/a&gt; for &lt;code&gt;compound_list&lt;/code&gt; duplicate the definition of &lt;code&gt;linebreak&lt;/code&gt;&lt;br /&gt;&lt;pre&gt;linebreak        : newline_list
                 | /* empty */
                 ;&lt;/pre&gt;which results in four grammar rules for &lt;code&gt;compound_list&lt;/code&gt; instead of two.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Desired Action&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On page 2350, lines 74834-74838, change&lt;br /&gt;&lt;pre&gt;compound_list    :              term
                 | newline_list term
                 |              term separator
                 | newline_list term separator
                 ;&lt;/pre&gt;to&lt;br /&gt;&lt;pre&gt;compound_list    : linebreak term
                 | linebreak term separator
                 ;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=166707" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:166612</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/166612.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=166612"/>
    <title>Aardvark 736: grammatically accept zero or more Shell commands</title>
    <published>2013-08-17T10:01:32Z</published>
    <updated>2013-08-18T10:17:20Z</updated>
    <category term="programming"/>
    <category term="computers"/>
    <category term="talks"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://austingroupbugs.net/view.php?id=736"&gt;http://austingroupbugs.net/view.php?id=736&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;An empty Shell program and a program consisting of two or more commands separated with &lt;code&gt;NEWLINE&lt;/code&gt; tokens are valid Shell scripts. However, &lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02"&gt;Shell Grammar Rules&lt;/a&gt; only accept exactly one single command which results in a syntax error against zero commands and two or more commands separated with &lt;code&gt;NEWLINE&lt;/code&gt; tokens.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Desired Action&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On page 2350, lines 74801-74808, change&lt;br /&gt;&lt;pre&gt;%start  complete_command
%%
complete_command : list separator
                 | list
                 ;&lt;/pre&gt;to&lt;br /&gt;&lt;pre&gt;%start script
%%
script           : commands linebreak
                 | /* empty */
                 ;
commands         : commands newline_list complete_command
                 |                       complete_command
                 ;
complete_command : list separator_op
                 | list
                 ;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=166612" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:166192</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/166192.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=166192"/>
    <title>Aardvark 735: 5 shift/reduce conflicts in Shell Grammar Rules</title>
    <published>2013-08-15T14:19:28Z</published>
    <updated>2013-08-15T14:19:28Z</updated>
    <category term="programming"/>
    <category term="computers"/>
    <category term="talks"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://austingroupbugs.net/view.php?id=735"&gt;http://austingroupbugs.net/view.php?id=735&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;When processed by &lt;code&gt;yacc(1)&lt;/code&gt;, &lt;a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02"&gt;Shell Grammar Rules&lt;/a&gt; result in 5 shift/reduce conflicts. These conflicts are all caused by unnecessary &lt;code&gt;linebreak&lt;/code&gt; non-terminals in &lt;code&gt;case_item_ns&lt;/code&gt; rule after &lt;code&gt;compound_list&lt;/code&gt; non-terminals. The &lt;code&gt;linebreak&lt;/code&gt; non-terminal are indeed unnecessary because &lt;code&gt;compound_list&lt;/code&gt; rule&lt;br /&gt;&lt;pre&gt;compound_list    :              term
                 | newline_list term
                 |              term separator
                 | newline_list term separator
                 ;&lt;/pre&gt;where&lt;br /&gt;&lt;pre&gt;separator        : separator_op linebreak
                 | newline_list
                 ;&lt;/pre&gt;itself embeds &lt;code&gt;linebreak&lt;/code&gt; definition&lt;br /&gt;&lt;pre&gt;linebreak        : newline_list
                 | /* empty */
                 ;&lt;/pre&gt;Without the trailing &lt;code&gt;linebreak&lt;/code&gt; non-terminals following &lt;code&gt;compound_list&lt;/code&gt;, &lt;code&gt;yacc(1)&lt;/code&gt; produces no shift/reduce conflicts.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Desired Action&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;On page 2351, lines 74863-74866, change&lt;br /&gt;&lt;pre&gt;case_item_ns     :     pattern ')'               linebreak
                 |     pattern ')' compound_list linebreak
                 | '(' pattern ')'               linebreak
                 | '(' pattern ')' compound_list linebreak
                 ;&lt;/pre&gt;to&lt;br /&gt;&lt;pre&gt;case_item_ns     :     pattern ')' linebreak
                 |     pattern ')' compound_list
                 | '(' pattern ')' linebreak
                 | '(' pattern ')' compound_list
                 ;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=166192" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:165830</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/165830.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=165830"/>
    <title>How to Swap stdout and stderr</title>
    <published>2013-07-11T08:53:09Z</published>
    <updated>2013-07-11T08:53:09Z</updated>
    <category term="howtos"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;div style="background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; cat &amp;gt;c.c
&lt;span style="font-weight: bold"&gt;#&lt;/span&gt;include &amp;lt;stdio.h&amp;gt;

int main()
{
        fprintf(stdout, &amp;quot;stdout\n&amp;quot;);
        fprintf(stderr, &amp;quot;stderr\n&amp;quot;);
        return 0;
}
&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; cc c.c
&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; 3&amp;gt;&amp;amp;2 2&amp;gt;&amp;amp;1 1&amp;gt;&amp;amp;3 ./a.out | tee log
stdout
stderr
&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; cat log
stderr
&lt;span style="font-weight: bold"&gt;$&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=165830" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:165207</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/165207.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=165207"/>
    <title>Schönhage's SMM 8-bit Set Operation on Verilog</title>
    <published>2013-07-06T19:48:33Z</published>
    <updated>2013-07-07T09:58:23Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">&lt;a href="http://tinyurl.com/q9x9k4c"&gt;http://tinyurl.com/q9x9k4c&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="font-weight: bold"&gt;module&lt;/span&gt; smm(clk, dst, src, idx, val);
	&lt;span style="font-weight: bold"&gt;input&lt;/span&gt; clk;
	&lt;span style="font-weight: bold"&gt;input&lt;/span&gt; [3:0] dst;
	&lt;span style="font-weight: bold"&gt;input&lt;/span&gt; [3:0] src;
	&lt;span style="font-weight: bold"&gt;output&lt;/span&gt; [7:0] idx;
	&lt;span style="font-weight: bold"&gt;output&lt;/span&gt; [7:0] val;

	&lt;span style="font-weight: bold"&gt;reg&lt;/span&gt; [7:0] ram [0:255];

	&lt;span style="font-weight: bold"&gt;wire&lt;/span&gt; [7:0] map [0:15];

	&lt;span style="font-weight: bold"&gt;assign&lt;/span&gt; map[0] = 8&amp;#39;b0;

	&lt;span style="font-weight: bold"&gt;genvar&lt;/span&gt; i;

	&lt;span style="font-weight: bold"&gt;generate&lt;/span&gt;
		&lt;span style="font-weight: bold"&gt;for&lt;/span&gt; (i = 1; i &amp;lt; 16; i = i + 1) &lt;span style="font-weight: bold"&gt;begin&lt;/span&gt;: anl
			&lt;span style="font-weight: bold"&gt;if&lt;/span&gt; (i % 2)
				&lt;span style="font-weight: bold"&gt;assign&lt;/span&gt; map[i] = map[i / 2] + 1;
			&lt;span style="font-weight: bold"&gt;else&lt;/span&gt;
				&lt;span style="font-weight: bold"&gt;assign&lt;/span&gt; map[i] = ram[map[i / 2]];
		&lt;span style="font-weight: bold"&gt;end&lt;/span&gt;
	&lt;span style="font-weight: bold"&gt;endgenerate&lt;/span&gt;

	&lt;span style="font-weight: bold"&gt;assign&lt;/span&gt; idx = map[dst];
	&lt;span style="font-weight: bold"&gt;assign&lt;/span&gt; val = map[src];

	&lt;span style="font-weight: bold"&gt;always&lt;/span&gt; @(&lt;span style="font-weight: bold"&gt;posedge&lt;/span&gt; clk)
		ram[idx] &amp;lt;= val;
&lt;span style="font-weight: bold"&gt;endmodule&lt;/span&gt;

`ifdef SIM
&lt;span style="font-weight: bold"&gt;module&lt;/span&gt; sim;
	&lt;span style="font-weight: bold"&gt;reg&lt;/span&gt; clk = 1&amp;#39;b0;
	&lt;span style="font-weight: bold"&gt;reg&lt;/span&gt; [3:0] dst = 4&amp;#39;b1;
	&lt;span style="font-weight: bold"&gt;reg&lt;/span&gt; [3:0] src = 4&amp;#39;b1;

	&lt;span style="font-weight: bold"&gt;wire&lt;/span&gt; [7:0] idx, val;

	smm blk(clk, dst, src, idx, val);

	&lt;span style="font-weight: bold"&gt;always&lt;/span&gt; &lt;span style="font-weight: bold"&gt;begin&lt;/span&gt;
		&lt;span style="font-weight: bold"&gt;if&lt;/span&gt; ($time &amp;gt;= 20)
			$finish;

		#1 $display(val);
		#1 clk &amp;lt;= ~clk;
		#1 clk &amp;lt;= ~clk;
		#1 src &amp;lt;= 4&amp;#39;b101;
	&lt;span style="font-weight: bold"&gt;end&lt;/span&gt;
&lt;span style="font-weight: bold"&gt;endmodule&lt;/span&gt;
`endif
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=165207" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:164928</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/164928.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=164928"/>
    <title>Combinational Logic for SHA-256</title>
    <published>2013-07-02T13:24:57Z</published>
    <updated>2013-07-04T12:12:57Z</updated>
    <category term="ideas"/>
    <category term="howtos"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>2</dw:reply-count>
    <content type="html">&lt;a href="http://tinyurl.com/q7yhgjq"&gt;http://tinyurl.com/q7yhgjq&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; make
iverilog -Wall -DSIM -o comb comb.v
./comb
0381353f9 0 b2e09fd28ea2916f526a8dbb3a92235f0ddb9b0b1ccd0e7d9b5786f91b62031e
0381353fa 1 00000000627d0f02061ce63584c20662272c527d21f17dfaffb20d7de340423d
0381353fb 0 c90dd726ebe7c2770808fe574e85aba7e90ba2aea8998c70bcb24781d4010955
&lt;span style="font-weight: bold"&gt;$&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=164928" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:162528</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/162528.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=162528"/>
    <title>Мой второй кот на Verilog</title>
    <published>2013-06-13T10:23:39Z</published>
    <updated>2013-06-18T11:16:21Z</updated>
    <category term="elementary mathematics"/>
    <category term="computers"/>
    <category term="ideas"/>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <dw:security>public</dw:security>
    <dw:reply-count>7</dw:reply-count>
    <content type="html">&lt;div style="background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #008000; font-weight: bold"&gt;module&lt;/span&gt; brain (clk, sensor, effect);
	&lt;span style="color: #008000; font-weight: bold"&gt;parameter&lt;/span&gt; nbit &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;12&lt;/span&gt;;
	&lt;span style="color: #008000; font-weight: bold"&gt;parameter&lt;/span&gt; size &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;2&lt;/span&gt; &lt;span style="color: #303030"&gt;**&lt;/span&gt; nbit;
 
	&lt;span style="color: #008000; font-weight: bold"&gt;input&lt;/span&gt; clk;
	&lt;span style="color: #008000; font-weight: bold"&gt;input&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] sensor;
	&lt;span style="color: #008000; font-weight: bold"&gt;output&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] effect;
 
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; sig [&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;size &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;];
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; trace [&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;size &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;];
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; [nbit &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] ram [&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;size &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;];
 
	&lt;span style="color: #008000; font-weight: bold"&gt;assign&lt;/span&gt; effect[&lt;span style="color: #005080; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] &lt;span style="color: #303030"&gt;=&lt;/span&gt; {sig[&lt;span style="color: #005080; font-weight: bold"&gt;3&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;2&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;]};
	&lt;span style="color: #008000; font-weight: bold"&gt;assign&lt;/span&gt; effect[&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;4&lt;/span&gt;] &lt;span style="color: #303030"&gt;=&lt;/span&gt; {sig[&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;6&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;5&lt;/span&gt;], sig[&lt;span style="color: #005080; font-weight: bold"&gt;4&lt;/span&gt;]};
 
	&lt;span style="color: #008000; font-weight: bold"&gt;integer&lt;/span&gt; i;
 
	&lt;span style="color: #008000; font-weight: bold"&gt;initial&lt;/span&gt; &lt;span style="color: #008000; font-weight: bold"&gt;for&lt;/span&gt; (i &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;; i &lt;span style="color: #303030"&gt;&amp;lt;&lt;/span&gt; size; i &lt;span style="color: #303030"&gt;=&lt;/span&gt; i &lt;span style="color: #303030"&gt;+&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;) &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
		trace[i] &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
		sig[i] &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
		ram[i] &lt;span style="color: #303030"&gt;=&lt;/span&gt; i;
	&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
 
	&lt;span style="color: #008000; font-weight: bold"&gt;always&lt;/span&gt; @(&lt;span style="color: #008000; font-weight: bold"&gt;posedge&lt;/span&gt; clk) &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
		&lt;span style="color: #008000; font-weight: bold"&gt;for&lt;/span&gt; (i &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;; i &lt;span style="color: #303030"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;8&lt;/span&gt;; i &lt;span style="color: #303030"&gt;=&lt;/span&gt; i &lt;span style="color: #303030"&gt;+&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;)
			sig[ram[i]] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; sensor[i];
 
		&lt;span style="color: #008000; font-weight: bold"&gt;for&lt;/span&gt; (i &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;; i &lt;span style="color: #303030"&gt;&amp;lt;&lt;/span&gt; size; i &lt;span style="color: #303030"&gt;=&lt;/span&gt; i &lt;span style="color: #303030"&gt;+&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;) &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
			&lt;span style="color: #008000; font-weight: bold"&gt;case&lt;/span&gt; ({trace[i], sig[ram[i]]})
			&lt;span style="color: #005080; font-weight: bold"&gt;2&amp;#39;b00&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; ram[i] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; ram[i] &lt;span style="color: #303030"&gt;+&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;;
			&lt;span style="color: #005080; font-weight: bold"&gt;2&amp;#39;b01&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; sig[i] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;;
			&lt;span style="color: #005080; font-weight: bold"&gt;2&amp;#39;b10&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; sig[i] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
			&lt;span style="color: #005080; font-weight: bold"&gt;2&amp;#39;b11&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; ram[i] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; ram[i] &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;;
			&lt;span style="color: #008000; font-weight: bold"&gt;endcase&lt;/span&gt;
 
			trace[i] &lt;span style="color: #303030"&gt;&amp;lt;=&lt;/span&gt; sig[ram[i]];
		&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
	&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;endmodule&lt;/span&gt;
 
&lt;span style="color: #003060; font-weight: bold"&gt;`ifdef&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;SIM&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;module&lt;/span&gt; sim;
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] key;
	&lt;span style="color: #303090; font-weight: bold"&gt;wire&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] led;
 
	brain core(clk, key, led);
 
	&lt;span style="color: #008000; font-weight: bold"&gt;integer&lt;/span&gt; c;
 
	&lt;span style="color: #008000; font-weight: bold"&gt;always&lt;/span&gt; &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
		c &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #F00000; background-color: #F0A0A0"&gt;$&lt;/span&gt;fgetc(&lt;span style="color: #005080; font-weight: bold"&gt;32&amp;#39;h8000&lt;/span&gt;_0000);
		&lt;span style="color: #008000; font-weight: bold"&gt;if&lt;/span&gt; (&lt;span style="color: #303030"&gt;-&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt; &lt;span style="color: #303030"&gt;==&lt;/span&gt; c)
			&lt;span style="color: #007020"&gt;$finish&lt;/span&gt;;
 
		key &lt;span style="color: #303030"&gt;=&lt;/span&gt; c[&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;];
		#&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #303030"&gt;~&lt;/span&gt;clk;
		#&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #303030"&gt;~&lt;/span&gt;clk;
		&lt;span style="color: #F00000; background-color: #F0A0A0"&gt;$&lt;/span&gt;displayb(led);
	&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;endmodule&lt;/span&gt;
&lt;span style="color: #003060; font-weight: bold"&gt;`endif&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=162528" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:162238</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/162238.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=162238"/>
    <title>Мой первый кот на Verilog</title>
    <published>2013-06-10T15:41:10Z</published>
    <updated>2013-06-10T21:11:42Z</updated>
    <category term="programming"/>
    <category term="lambda calculus"/>
    <category term="computers"/>
    <category term="elementary mathematics"/>
    <dw:security>public</dw:security>
    <dw:reply-count>2</dw:reply-count>
    <content type="html">&lt;div style="background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"&gt;&lt;pre style="margin: 0; line-height: 125%"&gt;&lt;span style="color: #507090"&gt;`define OPZ 4&amp;#39;b1111&lt;/span&gt;
&lt;span style="color: #507090"&gt;`define OPA 4&amp;#39;b0001&lt;/span&gt;
&lt;span style="color: #507090"&gt;`define OPL 4&amp;#39;b0010&lt;/span&gt;
&lt;span style="color: #507090"&gt;`define OPN 4&amp;#39;b0100&lt;/span&gt;
&lt;span style="color: #507090"&gt;`define OPS 4&amp;#39;b1000&lt;/span&gt;

&lt;span style="color: #507090"&gt;`define BIT 15&lt;/span&gt;
&lt;span style="color: #507090"&gt;`define SIZE (2 ** `BIT)&lt;/span&gt;

&lt;span style="color: #008000; font-weight: bold"&gt;module&lt;/span&gt; ram0 (clk, op, led);
	&lt;span style="color: #008000; font-weight: bold"&gt;input&lt;/span&gt; clk;
	&lt;span style="color: #008000; font-weight: bold"&gt;input&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] op;
	&lt;span style="color: #008000; font-weight: bold"&gt;output&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] led;

	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; [&lt;span style="color: #003060; font-weight: bold"&gt;`BIT&lt;/span&gt; &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] ram [&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #003060; font-weight: bold"&gt;`SIZE&lt;/span&gt; &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;];
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; [&lt;span style="color: #003060; font-weight: bold"&gt;`BIT&lt;/span&gt; &lt;span style="color: #303030"&gt;-&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] n, z;

	&lt;span style="color: #008000; font-weight: bold"&gt;assign&lt;/span&gt; led &lt;span style="color: #303030"&gt;=&lt;/span&gt; z[&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;];

	&lt;span style="color: #008000; font-weight: bold"&gt;always&lt;/span&gt; @(&lt;span style="color: #008000; font-weight: bold"&gt;posedge&lt;/span&gt; clk) &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
		&lt;span style="color: #008000; font-weight: bold"&gt;case&lt;/span&gt; (op)
		&lt;span style="color: #003060; font-weight: bold"&gt;`OPZ&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; z &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
		&lt;span style="color: #003060; font-weight: bold"&gt;`OPA&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; z &lt;span style="color: #303030"&gt;=&lt;/span&gt; z &lt;span style="color: #303030"&gt;+&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;;
		&lt;span style="color: #003060; font-weight: bold"&gt;`OPL&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; z &lt;span style="color: #303030"&gt;=&lt;/span&gt; ram[z];
		&lt;span style="color: #003060; font-weight: bold"&gt;`OPN&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; n &lt;span style="color: #303030"&gt;=&lt;/span&gt; z;
		&lt;span style="color: #003060; font-weight: bold"&gt;`OPS&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; ram[n] &lt;span style="color: #303030"&gt;=&lt;/span&gt; z;
		&lt;span style="color: #008000; font-weight: bold"&gt;endcase&lt;/span&gt;
	&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;endmodule&lt;/span&gt;

&lt;span style="color: #003060; font-weight: bold"&gt;`ifdef&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;SIM&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;module&lt;/span&gt; sim;
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
	&lt;span style="color: #303090; font-weight: bold"&gt;reg&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;3&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] op;
	&lt;span style="color: #303090; font-weight: bold"&gt;wire&lt;/span&gt; [&lt;span style="color: #005080; font-weight: bold"&gt;7&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;] led;

	ram0 core(clk, op, led);

	&lt;span style="color: #008000; font-weight: bold"&gt;integer&lt;/span&gt; ch;

	&lt;span style="color: #008000; font-weight: bold"&gt;always&lt;/span&gt; &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
		ch &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #F00000; background-color: #F0A0A0"&gt;$&lt;/span&gt;fgetc(&lt;span style="color: #005080; font-weight: bold"&gt;32&amp;#39;h8000&lt;/span&gt;_0000);
		&lt;span style="color: #008000; font-weight: bold"&gt;case&lt;/span&gt; (ch)
		&lt;span style="background-color: #fff0f0"&gt;&amp;quot;z&amp;quot;&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;Z&amp;quot;&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;`OPZ&lt;/span&gt;;
		&lt;span style="background-color: #fff0f0"&gt;&amp;quot;a&amp;quot;&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;A&amp;quot;&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;`OPA&lt;/span&gt;;
		&lt;span style="background-color: #fff0f0"&gt;&amp;quot;l&amp;quot;&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;L&amp;quot;&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;`OPL&lt;/span&gt;;
		&lt;span style="background-color: #fff0f0"&gt;&amp;quot;n&amp;quot;&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;N&amp;quot;&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;`OPN&lt;/span&gt;;
		&lt;span style="background-color: #fff0f0"&gt;&amp;quot;s&amp;quot;&lt;/span&gt;, &lt;span style="background-color: #fff0f0"&gt;&amp;quot;S&amp;quot;&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #003060; font-weight: bold"&gt;`OPS&lt;/span&gt;;
		&lt;span style="color: #303030"&gt;-&lt;/span&gt;&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; &lt;span style="color: #007020"&gt;$finish&lt;/span&gt;;
		&lt;span style="color: #008000; font-weight: bold"&gt;default&lt;/span&gt;&lt;span style="color: #303030"&gt;:&lt;/span&gt; op &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #005080; font-weight: bold"&gt;0&lt;/span&gt;;
		&lt;span style="color: #008000; font-weight: bold"&gt;endcase&lt;/span&gt;

		&lt;span style="color: #008000; font-weight: bold"&gt;if&lt;/span&gt; (op) &lt;span style="color: #008000; font-weight: bold"&gt;begin&lt;/span&gt;
			#&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #303030"&gt;~&lt;/span&gt;clk;
			#&lt;span style="color: #005080; font-weight: bold"&gt;1&lt;/span&gt; clk &lt;span style="color: #303030"&gt;=&lt;/span&gt; &lt;span style="color: #303030"&gt;~&lt;/span&gt;clk;
			&lt;span style="color: #F00000; background-color: #F0A0A0"&gt;$&lt;/span&gt;displayb(led);
		&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
	&lt;span style="color: #008000; font-weight: bold"&gt;end&lt;/span&gt;
&lt;span style="color: #008000; font-weight: bold"&gt;endmodule&lt;/span&gt;
&lt;span style="color: #003060; font-weight: bold"&gt;`endif&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=162238" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2013-01-03:1881992:160328</id>
    <link rel="alternate" type="text/html" href="https://codedot.dreamwidth.org/160328.html"/>
    <link rel="self" type="text/xml" href="https://codedot.dreamwidth.org/data/atom/?itemid=160328"/>
    <title>Компиляция из MLC в RAM0</title>
    <published>2013-05-15T13:29:27Z</published>
    <updated>2013-05-15T18:16:54Z</updated>
    <category term="lambda calculus"/>
    <category term="programming"/>
    <category term="elementary mathematics"/>
    <category term="ideas"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">Программы на языке MLC (Macro Lambda Calculus) - пример &lt;a href="https://raw.github.com/euromake/mlc/master/example.mlc"&gt;доступен&lt;/a&gt; на GitHub - имеют следующий вид:&lt;br /&gt;&lt;br /&gt;N1 = M1;&lt;br /&gt;...&lt;br /&gt;Nm = Mm;&lt;br /&gt;&lt;br /&gt;M0.&lt;br /&gt;&lt;br /&gt;Выражение M0 может содержать произвольное число вхождений имен макросов N1, ... , Nm, а также свободных переменных - обозначим их x1, ... , xn. Комбинатор M, нормальную форму которого мы фактически ищем, получается из программы следующим образом:&lt;br /&gt;&lt;br /&gt;M = x1, ... , xn: (N1, ... , Nm: M0) M1 ... Mm.&lt;br /&gt;&lt;br /&gt;Комбинатор M, в свою очередь, представим в &lt;a href="http://arxiv.org/abs/1304.1309"&gt;исчислении взаимодействия&lt;/a&gt;, воспользовавшись направленной версией &lt;a href="http://arxiv.org/abs/1304.2290"&gt;компактной кодировки λ-выражений&lt;/a&gt;. Заметим, что конфигурация &amp;lt;x | Γ(M, x)&amp;gt;, как можно видеть из определения, содержит только редексы по левому разыменованию. Следовательно, чтобы инициализировать нашу &lt;a href="http://codedot.dreamwidth.org/157570.html"&gt;систему слепой перезаписи графов&lt;/a&gt;, достаточно все уравнения конфигурации положить в стек, соответствующий левому разыменованию.&lt;br /&gt;&lt;br /&gt;Полученную в результате структуру памяти можно восстановить некоторой последовательностью I инструкций Z, A, L, N и S машины &lt;a href="http://codedot.dreamwidth.org/160095.html"&gt;RAM0&lt;/a&gt;. Основной цикл работы нашей системы слепой перезаписи графов, реализующей редукцию сетей взаимодействия, также может быть представлен некоторой последовательностью R инструкций Z, A, L, N и S, которая не зависит от вычисляемого выражения. Таким образом, исходный код на языке MLC может быть скомпилирован в следующую программу RAM0:&lt;br /&gt;&lt;br /&gt;I;&lt;br /&gt;loop: R;&lt;br /&gt;goto loop;&lt;br /&gt;&lt;br /&gt;Данная программа не содержит инструкцию C для условного перехода. Такие детали, как стратегия вычисления, остановка машины, обработка дна стеков и механизм "read-back" во время стягивания конфигурации, были здесь намеренно опущены, чтобы не нагромождать и без того уже объемное изложение.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=codedot&amp;ditemid=160328" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
