Skip to content

Commit

Permalink
semantics doc start
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Feb 2, 2024
1 parent a332665 commit 4839676
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions tree_inputs/semantics.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
# Semantics of Tree Encoding with Inputs

;; current schema:
(Let id1 some_input
(Add (Get (Arg id1) 0) (Get (Arg id1) 1)))
## Comparison to previous "unique id" schemas

=>
In previous schemas, we might write
shared computation like this:
```
(Let id1 some_impure_computation
(Add (Get (Arg id1) 0) (Get (Arg id1) 1)))
```

;; input appears twice but evaluated only once
;; "dag semantics for inputs"
(Let
(Add (Get (Input some_input) 0) (Get (Input some_input) 1)))
The reason for `id` is to give a context-specific equality relation
to this `Let`, allowing us to assume
the argument is equal to `some_impure_computation`.

`Input`s allow us to avoid this id by
allowing us to refer to the impure computation directly:

```
(Let
(Add (Get (Input inner) 0) (Get (Input inner) 1)))

(Add (Get (Input some_impure_computation) 0) (Get (Input some_impure_computation) 1)))
```

(Loop
(Add (Input some_loop_inputs) (Input some_loop_inputs)))
The semantics of an `Input` is that it is evaluated only once in its enclosing `Let`.
Each `Let` can only have one `Input`.

Now, no ids are necessary because the
context is baked into the `Input` itself.

0 comments on commit 4839676

Please sign in to comment.