@turing-machine-js/library-binary-numbers-bare 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.0.2] - 2026-05-04
8
+
9
+ Released in lockstep with `@turing-machine-js/machine` 3.0.2. No source or behavior changes in this package.
10
+
11
+ ## [3.0.1] - 2026-04-30
12
+
13
+ Released in lockstep with `@turing-machine-js/machine` 3.0.1. No source or behavior changes in this package.
14
+
7
15
  ## [3.0.0] - 2026-04-30
8
16
 
9
17
  Initial release. Companion library to [`@turing-machine-js/library-binary-numbers`](../library-binary-numbers) with the same operations on a 3-symbol alphabet (no `^`/`$` markers, single number per tape, much smaller state graphs).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turing-machine-js/library-binary-numbers-bare",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Single-number binary arithmetic on a 3-symbol alphabet (blank, 0, 1) — same operations as @turing-machine-js/library-binary-numbers but without ^/$ markers. Side-by-side with the marker-based library for learning the trade-off.",
5
5
  "engines": {
6
6
  "npm": ">=7.0.0"
@@ -41,5 +41,5 @@
41
41
  "default": "./dist/index.mjs"
42
42
  }
43
43
  },
44
- "gitHead": "98decf323129d528febafac1bec581a9ee3800ff"
44
+ "gitHead": "0a78b4d0d40bbdbf79e3c53694adf930f0567b0a"
45
45
  }
package/dist/index.js DELETED
@@ -1,139 +0,0 @@
1
- import { Alphabet, haltState, movements, State, symbolCommands, TapeBlock, } from '@turing-machine-js/machine';
2
- // 3-symbol alphabet: blank (' '), '0', '1'.
3
- // A number is a contiguous run of '0'/'1' cells; blanks surround it on both sides.
4
- // All algorithms below assume the head starts at the leftmost digit of the number.
5
- //
6
- // Compared with @turing-machine-js/library-binary-numbers (which uses ' ^$01' and
7
- // supports multi-number tapes), this library has only single-number arithmetic but
8
- // each algorithm is much smaller in state count — see ../states.md for the diagrams.
9
- const alphabet = new Alphabet([' ', '0', '1']);
10
- const tapeBlock = TapeBlock.fromAlphabets([alphabet]);
11
- const { symbol } = tapeBlock;
12
- // plusOne — 3 nodes (vs 5 in the marker-based library)
13
- //
14
- // Walk to the trailing blank, step back to the LSB, then carry from the LSB:
15
- // 1 → 0 (carry continues left)
16
- // 0 → 1, halt (carry consumed)
17
- // blank → 1, halt (overflow extends the number leftward)
18
- const plusOneCarry = new State({
19
- [symbol('1')]: {
20
- command: {
21
- symbol: '0',
22
- movement: movements.left,
23
- },
24
- },
25
- [symbol('0')]: {
26
- command: {
27
- symbol: '1',
28
- },
29
- nextState: haltState,
30
- },
31
- [symbol(alphabet.blankSymbol)]: {
32
- command: {
33
- symbol: '1',
34
- },
35
- nextState: haltState,
36
- },
37
- }, 'plusOneCarry');
38
- const plusOne = new State({
39
- [symbol('01')]: {
40
- command: {
41
- movement: movements.right,
42
- },
43
- },
44
- [symbol(alphabet.blankSymbol)]: {
45
- command: {
46
- movement: movements.left,
47
- },
48
- nextState: plusOneCarry,
49
- },
50
- }, 'plusOne');
51
- // minusOne — 3 nodes (vs 17 / 10 in the marker-based library)
52
- //
53
- // Walk to the trailing blank, step back to the LSB, then borrow from the LSB:
54
- // 0 → 1 (borrow continues left)
55
- // 1 → 0, halt (borrow consumed)
56
- // blank → halt (underflow — input was zero or empty)
57
- const minusOneBorrow = new State({
58
- [symbol('0')]: {
59
- command: {
60
- symbol: '1',
61
- movement: movements.left,
62
- },
63
- },
64
- [symbol('1')]: {
65
- command: {
66
- symbol: '0',
67
- },
68
- nextState: haltState,
69
- },
70
- [symbol(alphabet.blankSymbol)]: {
71
- nextState: haltState,
72
- },
73
- }, 'minusOneBorrow');
74
- const minusOne = new State({
75
- [symbol('01')]: {
76
- command: {
77
- movement: movements.right,
78
- },
79
- },
80
- [symbol(alphabet.blankSymbol)]: {
81
- command: {
82
- movement: movements.left,
83
- },
84
- nextState: minusOneBorrow,
85
- },
86
- }, 'minusOne');
87
- // invertNumber — 2 nodes (vs 5)
88
- //
89
- // Sweep right, flipping each bit; halt at the trailing blank.
90
- const invertNumber = new State({
91
- [symbol('0')]: {
92
- command: {
93
- symbol: '1',
94
- movement: movements.right,
95
- },
96
- },
97
- [symbol('1')]: {
98
- command: {
99
- symbol: '0',
100
- movement: movements.right,
101
- },
102
- },
103
- [symbol(alphabet.blankSymbol)]: {
104
- nextState: haltState,
105
- },
106
- }, 'invertNumber');
107
- // normalizeNumber — 2 nodes (vs 7)
108
- //
109
- // Erase leading zeros until we hit a '1'. If the entire number was zeros, restore
110
- // a single '0' so 0 keeps its representation.
111
- const normalizeNumber = new State({
112
- [symbol('0')]: {
113
- command: {
114
- symbol: symbolCommands.erase,
115
- movement: movements.right,
116
- },
117
- },
118
- [symbol('1')]: {
119
- nextState: haltState,
120
- },
121
- [symbol(alphabet.blankSymbol)]: {
122
- command: {
123
- symbol: '0',
124
- },
125
- nextState: haltState,
126
- },
127
- }, 'normalizeNumber');
128
- function getTapeBlock() {
129
- return tapeBlock.clone();
130
- }
131
- export default {
132
- getTapeBlock,
133
- states: {
134
- plusOne,
135
- minusOne,
136
- invertNumber,
137
- normalizeNumber,
138
- },
139
- };