aboutsummaryrefslogtreecommitdiff
path: root/nn.in~
diff options
context:
space:
mode:
authorericmarin <maarin.eric@gmail.com>2026-03-09 18:18:34 +0100
committerericmarin <maarin.eric@gmail.com>2026-03-09 20:00:47 +0100
commit51cd389b4e322313671dd0e53513ce84b72a1652 (patch)
tree55d6ec8e8ad89ab1b754525171fbcd0cd177430b /nn.in~
parent2152db1e181609a3c8e686ce647079c6a04c6740 (diff)
downloadvein-51cd389b4e322313671dd0e53513ce84b72a1652.tar.gz
vein-51cd389b4e322313671dd0e53513ce84b72a1652.zip
linear folding
Diffstat (limited to '')
-rw-r--r--nn.in~71
1 files changed, 0 insertions, 71 deletions
diff --git a/nn.in~ b/nn.in~
deleted file mode 100644
index dd89d03..0000000
--- a/nn.in~
+++ /dev/null
@@ -1,71 +0,0 @@
-// Agents
-
-Any >< Optimize(out) =>
- out ~ Any;
-
-// Rules
-
-// Optimizer interacts with Const
-Const(k) >< Optimize(out) =>
- out ~ Const(k);
-
-
-// Optimizer interacts with Add
-Add(a, b) >< Optimize(out) =>
- a ~ Optimize(a_opt),
- a_opt ~ Add_CheckLeft(out, b);
-
-// CHECK LEFT
-Const(int k) >< Add_CheckLeft(out, b)
- | k == 0 => b ~ Optimize(b_opt), out ~ b_opt
- | _ => b ~ Optimize(b_opt), b_opt ~ Add_CheckRight_WithConst(out, k);
-a_opt >< Add_CheckLeft(out, b) =>
- b ~ Optimize(b_opt),
- b_opt ~ Add_CheckRight_WithAny(out, (*L)a_opt);
-
-// CHECK RIGHT
-Const(int j) >< Add_CheckRight_WithConst(out, int k) =>
- out ~ Const(k + j);
-b_opt >< Add_CheckRight_WithConst(out, int k) =>
- out ~ Add(Const(k), (*L)b_opt);
-Const(int j) >< Add_CheckRight_WithAny(out, a_opt)
- | j == 0 => out ~ a_opt
- | _ => out ~ Add(a_opt, Const(j));
-b_opt >< Add_CheckRight_WithAny(out, a_opt) =>
- out ~ Add(a_opt, (*L)b_opt);
-
-
-// Optimizer interacts with Mul
-Mul(a, b) >< Optimize(out) =>
- a ~ Optimize(a_opt),
- a_opt ~ Mul_CheckLeft(out, b);
-
-// Check LEFT
-Const(int k) >< Mul_CheckLeft(out, b)
- | k == 0 => b ~ Eraser, out ~ Const(0)
- | k == 1 => b ~ Optimize(b_opt), out ~ b_opt
- | _ => b ~ Optimize(b_opt), b_opt ~ Mul_CheckRight_WithConst(out, k);
-a_opt >< Mul_CheckLeft(out, b) =>
- b ~ Optimize(b_opt),
- b_opt ~ Mul_CheckRight_WithAny(out, (*L)a_opt);
-
-// Check RIGHT
-Const(int j) >< Mul_CheckRight_WithConst(out, int k) =>
- out ~ Const(k * j);
-b_opt >< Mul_CheckRight_WithConst(out, int k) =>
- out ~ Mul(Const(k), (*L)b_opt);
-Const(int j) >< Mul_CheckRight_WithAny(out, a_opt)
- | j == 0 => Eraser ~ a_opt, out ~ Const(0)
- | j == 1 => out ~ a_opt
- | _ => out ~ Mul(a_opt, Const(j));
-b_opt >< Mul_CheckRight_WithAny(out, a_opt) =>
- out ~ Mul(a_opt, (*L)b_opt);
-
-
-// Net
-Mul(Const(1), Add(Any, Mul(Const(0), Add(Any, Any)))) ~ Optimize(out);
-out;
-
-free out;
-Mul(Const(0), Add(Any, Any)) ~ Optimize(out);
-out;