diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-22 19:02:54 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-10-22 19:02:54 +0900 |
| commit | 3e0322c49c113a7e8590c79b39b839cbedab8805 (patch) | |
| tree | 9e58b85a910f48dcca5bd239781252536953f029 | |
| parent | 57a168cb4af26a287c9fa51f428ae24bf7716e36 (diff) | |
| download | inpla-3e0322c49c113a7e8590c79b39b839cbedab8805.tar.gz inpla-3e0322c49c113a7e8590c79b39b839cbedab8805.zip | |
Update README.md
| -rw-r--r-- | README.md | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -340,8 +340,8 @@ Something complicated? No problem! Let's us learn how to define the rules with s Unary natural numbers are built by Z and S. For instance, 0, 1, 2, 3 are expressed as Z, S(Z), S(S(Z)), S(S(S(Z))). Here, let's think about an increment operation `inc` such that inc(n) = S(n). This is written as rules for Z and S(x) as follows: ``` ->>> inc(result) >< Z => result~S(Z); ->>> inc(result) >< S(x) => result~S(S(x)); +inc(ret) >< Z => ret~S(Z); +inc(ret) >< S(x) => ret~S(S(x)); ``` In the first rule, the name `result` occurs in its `<connection>` part once, so it satisfies the rule proviso. The second rule also satisfies because the `result` and `x` are distinct names and occur once in its `<connections>` part. @@ -382,13 +382,16 @@ Let's clean the result in case it could be used anywhere: - add(x, Z) = x, - add(x, S(y)) = add(S(x), y). - This is written in interaction nets as follows: + This is written in interaction nets and Inpla as follows:  ``` - >>> add(ret, x) >< Z => ret~x; - >>> add(ret, x) >< S(y) => add(ret, S(x))~y; +add(ret, x) >< Z => ret~x; +add(ret, x) >< S(y) => add(ret, S(x))~y; + ``` + The following is an execution example: + ``` >>> add(r,S(Z))~S(S(Z)); (3 interactions, 0.00 sec) >>> r; @@ -399,19 +402,19 @@ Let's clean the result in case it could be used anywhere: >>> ``` -- **Exricise**: Another version of the addition. +- **Exercise**: Another version of the addition. There is another version defined as follows in term rewriting system: - add(x,Z) = x, - add(x, S(y)) = S(add(x,y)). - This is written in interaction nets as follows: + This is written in interaction nets and Inpla as follows:  ``` - >>> add(ret,x) >< Z => ret~x; - >>> add(ret,x) >< S(y) => ret~S(cnt), add(cnt, x)~y; + add(ret,x) >< Z => ret~x; + add(ret,x) >< S(y) => ret~S(cnt), add(cnt, x)~y; ``` |
