Skip to content

Commit

Permalink
FIXUP: Got the order of probability tables wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoric committed May 13, 2019
1 parent eb78b06 commit 425d73c
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions format.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ ProbabilityTable ::= ProbabilityTableUnreachable # Compression artifact. A t
| ProbabilityTableIndexedSymbols # Used for enums, booleans, sums of interfaces.
```

The order of probability tables is meaningful.
The probability tables are written down in an order extracted from the grammar and define a model
`table: (parent type, my type) -> [(value, probabilities)]`.

FIXME: Specify how the order is extracted from the grammar.

```
ProbabilityTableUnreachable ::= 0x02
Expand Down Expand Up @@ -127,12 +130,4 @@ ListPength(parent) ::= Value((parent, 'list-length')) # List lengths are u32 val
Primitive(parent) ::= bit*
```

To determine how many bits need to be read to decode a `Primitive(parent)`, it is sufficient for a decoder to know the distribution of probabilities for `(parent, expected type)`.

For this purpose, the decoder maintains a mapping `models: (parent, expected type) |-> distribution`.

Initially, this mapping is empty. Whenever we encounter a `Primitive(parent)` for an expected type:

- if `models(parent expected type)` is empty, read the next table in `ProbabilityPrelude`, and this becomes the value
result of `models(parent expected type)`;
- otherwise, use `models(parent expected type)`.
To determine how many bits need to be read to decode a `Primitive(parent)`, it is sufficient for a decoder to know the distribution of probabilities for `(parent, expected type)`, as stored in the `ProbabilityPrelude`.

0 comments on commit 425d73c

Please sign in to comment.