diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2021-12-21 01:02:30 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2021-12-21 01:02:30 +0900 |
| commit | a66c2989731bd7478334d241c0499bc6d0350cb2 (patch) | |
| tree | d6f61ad8216de419b0c4be1eabb0a2548dc3ba2d /README.md | |
| parent | 15d42ed7f963d47dc1d6de91ce8768c032d9a45f (diff) | |
| parent | 7663449bb9fc1f1f3967bbc2560fc94f1e19edba (diff) | |
| download | inpla-a66c2989731bd7478334d241c0499bc6d0350cb2.tar.gz inpla-a66c2989731bd7478334d241c0499bc6d0350cb2.zip | |
Merge branch 'develop'
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -280,6 +280,7 @@ Inpla is a multi-threaded parallel interpreter of interaction nets. Once you wri - [Example: Operations on unary natural numbers](#example-operations-on-unary-natural-numbers) * [Built-in Agents](#built-in-agents) * [Attributes (integers)](#attributes-integers) + - [Built-in anonymous agent for attributes](#built-in-anonymous-agent-for-attributes) - [Arithmetic expressions on attributes](#arithmetic-expressions-on-attributes) - [Interaction rules with expressions on attributes](#interaction-rules-with-expressions-on-attributes) - [Built-in rules of attributes in the anonymous agents](#built-in-rules-of-attributes-in-the-anonymous-agents) @@ -556,9 +557,9 @@ Append(r, listB) ~ listA --> r ~ (listA ++ listB) // pseudo code ## Attributes (integers) -Agents can have integers as their ports. These integers are called *attributes*. +Agents can be extended so that these can have integers as their ports. These integers are called *attributes*. -* For instance, `A(100)` is evaluated as an agent `A` that holds an attribute of an integer value 100. +* For instance, `A(100)` is evaluated as an agent `A` that holds an attribute of an integer value `100`. ``` >>> x~A(100); @@ -569,15 +570,20 @@ Agents can have integers as their ports. These integers are called *attributes*. >>> ``` -It is possible to use integers the same as agents, but these are recognised as attributes of an anonymous built-in agent in Inpla: -``` ->>> x~100; -(0 interactions, 0.00 sec) ->>> x; -100 ->>> free x; ->>> -``` + +### Built-in anonymous agent for attributes +It is possible to use integers the same as agents, but these are recognised as attributes of a built-in *anonymous agent* in Inpla. For instance, when we write just `x~100`, then the `100` is regarded as an attribute of the anonymous agent. + +* The following is another version of the above example in the case of using the anonymous agent: + + ``` + >>> x~100; // The `100' is regarded as an attribute of an anonymous agent + (0 interactions, 0.00 sec) + >>> x; + 100 + >>> free x; + >>> + ``` @@ -630,7 +636,7 @@ The symbol of addition, subtraction, multiplication, division and modulo are `+` ### Interaction rules with expressions on attributes -In interaction rules, attributes can be recognised by the modifier `int` in order to apply arithmetic expressions. **We can use the same variable with the modifier `int` many times (of course, zero times is also OK) in the connection parts of interaction rules**. +In interaction rules, attributes are recognised by a modifier `int` in order to apply arithmetic expressions. **We can use the same variable with the modifier `int` many times (of course, zero times is also OK) in the connection parts of interaction rules**. * Example: Incrementor on an attribute: ``` @@ -644,10 +650,12 @@ In interaction rules, attributes can be recognised by the modifier `int` in orde ``` -- Example: Duplicator of integer lists: +- Example: Duplicator of integer lists. -  + We note that, at the first line of the below example, the rule is allowed to have not twice occurrences of *i* (here, it is three times) because the *i* is a variable for attributes: +  + ``` >>> dup(a1,a2) >< (int i):xs => a1~(i:xs1), a2~(i:xs2), dup(xs1,xs2)~xs; @@ -659,7 +667,7 @@ In interaction rules, attributes can be recognised by the modifier `int` in orde >>> free a b; >>> ``` - + **We have to be careful for operations of two attributes on distinct agents**. For instance, we take the following rule of an `add` agent: |
