monogate-forge 0.2.0__tar.gz

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.
Files changed (198) hide show
  1. monogate_forge-0.2.0/LICENSE +32 -0
  2. monogate_forge-0.2.0/PKG-INFO +240 -0
  3. monogate_forge-0.2.0/README.md +194 -0
  4. monogate_forge-0.2.0/examples/README.md +49 -0
  5. monogate_forge-0.2.0/examples/__init__.py +17 -0
  6. monogate_forge-0.2.0/examples/clamp_bounded.eml +20 -0
  7. monogate_forge-0.2.0/examples/damped_wave.eml +20 -0
  8. monogate_forge-0.2.0/examples/exponential_decay.eml +18 -0
  9. monogate_forge-0.2.0/examples/gaussian.eml +18 -0
  10. monogate_forge-0.2.0/examples/hello.eml +17 -0
  11. monogate_forge-0.2.0/examples/lerp.eml +14 -0
  12. monogate_forge-0.2.0/examples/pid_controller.eml +30 -0
  13. monogate_forge-0.2.0/examples/quadratic.eml +16 -0
  14. monogate_forge-0.2.0/examples/sigmoid.eml +21 -0
  15. monogate_forge-0.2.0/examples/sine_oscillator.eml +21 -0
  16. monogate_forge-0.2.0/examples/smoothstep.eml +24 -0
  17. monogate_forge-0.2.0/examples/verified_add.eml +19 -0
  18. monogate_forge-0.2.0/hardware/allocator/__init__.py +25 -0
  19. monogate_forge-0.2.0/hardware/allocator/allocator.py +361 -0
  20. monogate_forge-0.2.0/hardware/allocator/precision_selector.py +27 -0
  21. monogate_forge-0.2.0/hardware/hdl_gen/__init__.py +11 -0
  22. monogate_forge-0.2.0/hardware/hdl_gen/chisel_backend.py +384 -0
  23. monogate_forge-0.2.0/hardware/hdl_gen/qformat.py +131 -0
  24. monogate_forge-0.2.0/hardware/hdl_gen/systemverilog_backend.py +265 -0
  25. monogate_forge-0.2.0/hardware/hdl_gen/verilog_backend.py +453 -0
  26. monogate_forge-0.2.0/hardware/hdl_gen/vhdl_backend.py +424 -0
  27. monogate_forge-0.2.0/hardware/modules/README.md +68 -0
  28. monogate_forge-0.2.0/hardware/modules/__init__.py +0 -0
  29. monogate_forge-0.2.0/hardware/modules/eml_operators/eml_node.v +77 -0
  30. monogate_forge-0.2.0/hardware/modules/transcendental/eml_acos.v +71 -0
  31. monogate_forge-0.2.0/hardware/modules/transcendental/eml_asin.v +71 -0
  32. monogate_forge-0.2.0/hardware/modules/transcendental/eml_atan.v +70 -0
  33. monogate_forge-0.2.0/hardware/modules/transcendental/eml_cos.v +66 -0
  34. monogate_forge-0.2.0/hardware/modules/transcendental/eml_cosh.v +66 -0
  35. monogate_forge-0.2.0/hardware/modules/transcendental/eml_exp.v +89 -0
  36. monogate_forge-0.2.0/hardware/modules/transcendental/eml_ln.v +69 -0
  37. monogate_forge-0.2.0/hardware/modules/transcendental/eml_sin.v +65 -0
  38. monogate_forge-0.2.0/hardware/modules/transcendental/eml_sinh.v +65 -0
  39. monogate_forge-0.2.0/hardware/modules/transcendental/eml_sqrt.v +80 -0
  40. monogate_forge-0.2.0/hardware/modules/transcendental/eml_tan.v +70 -0
  41. monogate_forge-0.2.0/hardware/modules/transcendental/eml_tanh.v +69 -0
  42. monogate_forge-0.2.0/hardware/simulation/verilator_sim.py +298 -0
  43. monogate_forge-0.2.0/hardware/targets/asic/sky130.py +79 -0
  44. monogate_forge-0.2.0/hardware/targets/intel/cyclone10.py +64 -0
  45. monogate_forge-0.2.0/hardware/targets/lattice/ecp5.py +64 -0
  46. monogate_forge-0.2.0/hardware/targets/lattice/ice40.py +77 -0
  47. monogate_forge-0.2.0/hardware/targets/xilinx/artix7.py +76 -0
  48. monogate_forge-0.2.0/lang/fingerprint/__init__.py +69 -0
  49. monogate_forge-0.2.0/lang/fingerprint/compute.py +348 -0
  50. monogate_forge-0.2.0/lang/fingerprint/embed.py +165 -0
  51. monogate_forge-0.2.0/lang/fingerprint/fingerprint.schema.json +126 -0
  52. monogate_forge-0.2.0/lang/fingerprint/shape_class.py +91 -0
  53. monogate_forge-0.2.0/lang/fingerprint/shape_classes_v1.json +78 -0
  54. monogate_forge-0.2.0/lang/loader/__init__.py +26 -0
  55. monogate_forge-0.2.0/lang/loader/resolver.py +285 -0
  56. monogate_forge-0.2.0/lang/optimizer/__init__.py +119 -0
  57. monogate_forge-0.2.0/lang/optimizer/constant_folding.py +301 -0
  58. monogate_forge-0.2.0/lang/optimizer/cse.py +249 -0
  59. monogate_forge-0.2.0/lang/optimizer/fusion.py +18 -0
  60. monogate_forge-0.2.0/lang/optimizer/inliner.py +176 -0
  61. monogate_forge-0.2.0/lang/optimizer/ml_routing.py +182 -0
  62. monogate_forge-0.2.0/lang/optimizer/superbest.py +198 -0
  63. monogate_forge-0.2.0/lang/optimizer/tree_shaker.py +88 -0
  64. monogate_forge-0.2.0/lang/parser/__init__.py +53 -0
  65. monogate_forge-0.2.0/lang/parser/ast_nodes.py +232 -0
  66. monogate_forge-0.2.0/lang/parser/errors.py +37 -0
  67. monogate_forge-0.2.0/lang/parser/lexer.py +195 -0
  68. monogate_forge-0.2.0/lang/parser/parser.py +706 -0
  69. monogate_forge-0.2.0/lang/parser/type_checker.py +71 -0
  70. monogate_forge-0.2.0/lang/profiler/__init__.py +14 -0
  71. monogate_forge-0.2.0/lang/profiler/ast_to_sympy.py +254 -0
  72. monogate_forge-0.2.0/lang/profiler/dynamics.py +36 -0
  73. monogate_forge-0.2.0/lang/profiler/eml_interpreter.py +254 -0
  74. monogate_forge-0.2.0/lang/profiler/profiler.py +218 -0
  75. monogate_forge-0.2.0/lang/profiler/sympy_to_ast.py +152 -0
  76. monogate_forge-0.2.0/lang/spec/EML_LANG_DESIGN.md +698 -0
  77. monogate_forge-0.2.0/lang/spec/SPEC.md +213 -0
  78. monogate_forge-0.2.0/lang/spec/__init__.py +0 -0
  79. monogate_forge-0.2.0/lang/spec/grammar/__init__.py +0 -0
  80. monogate_forge-0.2.0/lang/spec/grammar/eml_lang.g4 +123 -0
  81. monogate_forge-0.2.0/lang/spec/grammar/examples/arrhenius.eml +12 -0
  82. monogate_forge-0.2.0/lang/spec/grammar/examples/bessel_fm.eml +18 -0
  83. monogate_forge-0.2.0/lang/spec/grammar/examples/hello.eml +9 -0
  84. monogate_forge-0.2.0/lang/spec/grammar/examples/kalman.eml +19 -0
  85. monogate_forge-0.2.0/lang/spec/grammar/examples/motor_control.eml +84 -0
  86. monogate_forge-0.2.0/lang/spec/grammar/examples/motor_foc.eml +16 -0
  87. monogate_forge-0.2.0/lang/spec/grammar/examples/orbit.eml +23 -0
  88. monogate_forge-0.2.0/lang/spec/grammar/examples/pid_basic.eml +13 -0
  89. monogate_forge-0.2.0/lang/spec/grammar/examples/pid_nonlinear.eml +22 -0
  90. monogate_forge-0.2.0/lang/spec/grammar/examples/sigmoid.eml +18 -0
  91. monogate_forge-0.2.0/lang/spec/grammar/examples/trajectory.eml +16 -0
  92. monogate_forge-0.2.0/lang/spec/grammar/lexer_rules.g4 +58 -0
  93. monogate_forge-0.2.0/lang/spec/stdlib/STDLIB.md +127 -0
  94. monogate_forge-0.2.0/lang/spec/stdlib/__init__.py +0 -0
  95. monogate_forge-0.2.0/lang/spec/stdlib/constants.eml +23 -0
  96. monogate_forge-0.2.0/lang/spec/stdlib/control.eml +134 -0
  97. monogate_forge-0.2.0/lang/spec/stdlib/linalg.eml +135 -0
  98. monogate_forge-0.2.0/lang/spec/stdlib/math.eml +149 -0
  99. monogate_forge-0.2.0/lang/spec/stdlib/ml.eml +143 -0
  100. monogate_forge-0.2.0/lang/spec/stdlib/signal.eml +118 -0
  101. monogate_forge-0.2.0/lang/spec/types/TYPES.md +58 -0
  102. monogate_forge-0.2.0/lang/spec/types/__init__.py +0 -0
  103. monogate_forge-0.2.0/lang/spec/types/chain_order_types.md +91 -0
  104. monogate_forge-0.2.0/lang/spec/types/domain_types.md +33 -0
  105. monogate_forge-0.2.0/lang/spec/types/precision_types.md +48 -0
  106. monogate_forge-0.2.0/lang/zkproof/__init__.py +65 -0
  107. monogate_forge-0.2.0/lang/zkproof/circuit.py +421 -0
  108. monogate_forge-0.2.0/lang/zkproof/plonky2_runner.py +234 -0
  109. monogate_forge-0.2.0/lang/zkproof/prover.py +496 -0
  110. monogate_forge-0.2.0/monogate_forge.egg-info/PKG-INFO +240 -0
  111. monogate_forge-0.2.0/monogate_forge.egg-info/SOURCES.txt +196 -0
  112. monogate_forge-0.2.0/monogate_forge.egg-info/dependency_links.txt +1 -0
  113. monogate_forge-0.2.0/monogate_forge.egg-info/entry_points.txt +4 -0
  114. monogate_forge-0.2.0/monogate_forge.egg-info/requires.txt +12 -0
  115. monogate_forge-0.2.0/monogate_forge.egg-info/top_level.txt +5 -0
  116. monogate_forge-0.2.0/pyproject.toml +207 -0
  117. monogate_forge-0.2.0/setup.cfg +4 -0
  118. monogate_forge-0.2.0/software/backends/__init__.py +14 -0
  119. monogate_forge-0.2.0/software/backends/aadl_backend.py +251 -0
  120. monogate_forge-0.2.0/software/backends/ada_backend.py +545 -0
  121. monogate_forge-0.2.0/software/backends/autosar_backend.py +316 -0
  122. monogate_forge-0.2.0/software/backends/c_backend.py +422 -0
  123. monogate_forge-0.2.0/software/backends/cpp_backend.py +404 -0
  124. monogate_forge-0.2.0/software/backends/csharp_backend.py +556 -0
  125. monogate_forge-0.2.0/software/backends/gdscript_backend.py +290 -0
  126. monogate_forge-0.2.0/software/backends/glsl_backend.py +619 -0
  127. monogate_forge-0.2.0/software/backends/go_backend.py +369 -0
  128. monogate_forge-0.2.0/software/backends/hlsl_backend.py +651 -0
  129. monogate_forge-0.2.0/software/backends/java_backend.py +398 -0
  130. monogate_forge-0.2.0/software/backends/javascript_backend.py +405 -0
  131. monogate_forge-0.2.0/software/backends/kotlin_backend.py +440 -0
  132. monogate_forge-0.2.0/software/backends/llvm_backend.py +526 -0
  133. monogate_forge-0.2.0/software/backends/luau_backend.py +420 -0
  134. monogate_forge-0.2.0/software/backends/matlab_backend.py +384 -0
  135. monogate_forge-0.2.0/software/backends/metal_backend.py +586 -0
  136. monogate_forge-0.2.0/software/backends/python_backend.py +307 -0
  137. monogate_forge-0.2.0/software/backends/ros2_backend.py +304 -0
  138. monogate_forge-0.2.0/software/backends/rust_backend.py +379 -0
  139. monogate_forge-0.2.0/software/backends/solidity_audit.py +432 -0
  140. monogate_forge-0.2.0/software/backends/solidity_backend.py +594 -0
  141. monogate_forge-0.2.0/software/backends/solidity_foundry.py +334 -0
  142. monogate_forge-0.2.0/software/backends/solidity_gas.py +210 -0
  143. monogate_forge-0.2.0/software/backends/solidity_prbmath.py +247 -0
  144. monogate_forge-0.2.0/software/backends/solidity_spec.py +236 -0
  145. monogate_forge-0.2.0/software/backends/solidity_trig.py +291 -0
  146. monogate_forge-0.2.0/software/backends/swift_backend.py +583 -0
  147. monogate_forge-0.2.0/software/backends/wasm_backend.py +102 -0
  148. monogate_forge-0.2.0/software/backends/wgsl_backend.py +565 -0
  149. monogate_forge-0.2.0/software/verification/__init__.py +0 -0
  150. monogate_forge-0.2.0/software/verification/coq/__init__.py +5 -0
  151. monogate_forge-0.2.0/software/verification/coq/coq_backend.py +433 -0
  152. monogate_forge-0.2.0/software/verification/isabelle/__init__.py +8 -0
  153. monogate_forge-0.2.0/software/verification/isabelle/isabelle_backend.py +431 -0
  154. monogate_forge-0.2.0/software/verification/lean/LeanBackend.py +562 -0
  155. monogate_forge-0.2.0/software/verification/lean/discovered_emit.py +114 -0
  156. monogate_forge-0.2.0/tools/benchmarks/__init__.py +29 -0
  157. monogate_forge-0.2.0/tools/benchmarks/dashboard.py +147 -0
  158. monogate_forge-0.2.0/tools/benchmarks/regen_baselines.py +100 -0
  159. monogate_forge-0.2.0/tools/benchmarks/snapshot.py +137 -0
  160. monogate_forge-0.2.0/tools/cli/_ed25519_verify.py +129 -0
  161. monogate_forge-0.2.0/tools/cli/audit.py +449 -0
  162. monogate_forge-0.2.0/tools/cli/cost_aware.py +308 -0
  163. monogate_forge-0.2.0/tools/cli/explain.py +506 -0
  164. monogate_forge-0.2.0/tools/cli/fingerprint_corpus.py +150 -0
  165. monogate_forge-0.2.0/tools/cli/fingerprint_publish.py +125 -0
  166. monogate_forge-0.2.0/tools/cli/generate_tests.py +197 -0
  167. monogate_forge-0.2.0/tools/cli/grow_room_demo.py +150 -0
  168. monogate_forge-0.2.0/tools/cli/init_cmd.py +162 -0
  169. monogate_forge-0.2.0/tools/cli/live_counts.py +389 -0
  170. monogate_forge-0.2.0/tools/cli/log_witness.py +422 -0
  171. monogate_forge-0.2.0/tools/cli/main.py +1824 -0
  172. monogate_forge-0.2.0/tools/cli/manpage.py +189 -0
  173. monogate_forge-0.2.0/tools/cli/repl.py +328 -0
  174. monogate_forge-0.2.0/tools/cli/zk_log_verify.py +260 -0
  175. monogate_forge-0.2.0/tools/cli/zk_prove.py +120 -0
  176. monogate_forge-0.2.0/tools/cli/zk_verify.py +105 -0
  177. monogate_forge-0.2.0/tools/equivalence/__init__.py +23 -0
  178. monogate_forge-0.2.0/tools/equivalence/c_runner.py +217 -0
  179. monogate_forge-0.2.0/tools/equivalence/harness.py +286 -0
  180. monogate_forge-0.2.0/tools/equivalence/lean_runner.py +246 -0
  181. monogate_forge-0.2.0/tools/equivalence/python_runner.py +177 -0
  182. monogate_forge-0.2.0/tools/equivalence/rust_runner.py +314 -0
  183. monogate_forge-0.2.0/tools/external_lint/__init__.py +26 -0
  184. monogate_forge-0.2.0/tools/external_lint/base.py +166 -0
  185. monogate_forge-0.2.0/tools/external_lint/verilog.py +101 -0
  186. monogate_forge-0.2.0/tools/fmt/__init__.py +28 -0
  187. monogate_forge-0.2.0/tools/fmt/formatter.py +364 -0
  188. monogate_forge-0.2.0/tools/forge_graph.py +464 -0
  189. monogate_forge-0.2.0/tools/ide/lsp/__init__.py +7 -0
  190. monogate_forge-0.2.0/tools/ide/lsp/server.py +938 -0
  191. monogate_forge-0.2.0/tools/ide/lsp/workspace.py +251 -0
  192. monogate_forge-0.2.0/tools/license/__init__.py +28 -0
  193. monogate_forge-0.2.0/tools/license/issuer.py +87 -0
  194. monogate_forge-0.2.0/tools/license/verifier.py +203 -0
  195. monogate_forge-0.2.0/tools/scripts/audit_sweep.py +353 -0
  196. monogate_forge-0.2.0/tools/scripts/auto_prove.py +568 -0
  197. monogate_forge-0.2.0/tools/scripts/build_free_wheel.py +223 -0
  198. monogate_forge-0.2.0/tools/scripts/regen_discovered.py +133 -0
@@ -0,0 +1,32 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Monogate Research
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Note: While this implementation is licensed under MIT, specific algorithmic
26
+ methods used by Monogate Forge are covered by patents held by Monogate Research
27
+ (see `patents/index.md`). The MIT license grants you the right to use, modify,
28
+ and distribute THIS implementation. Independent re-implementations of patented
29
+ methods may require licensing — contact the project maintainers for details.
30
+
31
+ This is the same model used by GCC + the x86 instruction set: the compiler
32
+ is open, but specific microarchitectural techniques may be patented.
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: monogate-forge
3
+ Version: 0.2.0
4
+ Summary: EML language and compiler for verified mathematical computation. 31 backends spanning software, GPU shaders, hardware (FPGA/ASIC), formal verification, and safety-critical systems.
5
+ Author: Mosa Creates LLC
6
+ Author-email: "Arturo R. Almaguer" <almaguer1986@gmail.com>
7
+ Maintainer-email: "Arturo R. Almaguer" <almaguer1986@gmail.com>
8
+ License: MIT
9
+ Project-URL: Homepage, https://monogateforge.com
10
+ Project-URL: Documentation, https://monogate.dev/learn/eml/intro
11
+ Project-URL: Repository, https://github.com/agent-maestro/forge
12
+ Project-URL: Issues, https://github.com/agent-maestro/forge/issues
13
+ Project-URL: Changelog, https://github.com/agent-maestro/forge/blob/master/CHANGELOG.md
14
+ Project-URL: VS Code Extension, https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang
15
+ Project-URL: Research, https://monogate.org
16
+ Project-URL: MachLib, https://machlib.org
17
+ Keywords: compiler,programming-language,formal-verification,lean,fpga,hdl,verilog,vhdl,safety-critical,embedded,math,shader,hlsl,metal,wgsl,eml
18
+ Classifier: Development Status :: 4 - Beta
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Science/Research
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Programming Language :: Python :: 3
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Topic :: Scientific/Engineering
27
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
28
+ Classifier: Topic :: Software Development :: Compilers
29
+ Classifier: Topic :: Software Development :: Code Generators
30
+ Classifier: Topic :: Software Development :: Embedded Systems
31
+ Classifier: Typing :: Typed
32
+ Requires-Python: >=3.11
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: eml-cost>=0.19.0
36
+ Requires-Dist: cryptography>=42
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=8; extra == "dev"
39
+ Requires-Dist: pytest-cov>=5; extra == "dev"
40
+ Requires-Dist: ruff>=0.5; extra == "dev"
41
+ Requires-Dist: mypy>=1.10; extra == "dev"
42
+ Provides-Extra: lsp
43
+ Requires-Dist: pygls>=2.0; extra == "lsp"
44
+ Requires-Dist: lsprotocol>=2024.0.0b1; extra == "lsp"
45
+ Dynamic: license-file
46
+
47
+ # Monogate Forge
48
+
49
+ [![CI](https://github.com/agent-maestro/forge/actions/workflows/ci.yml/badge.svg)](https://github.com/agent-maestro/forge/actions/workflows/ci.yml)
50
+ [![PyPI](https://img.shields.io/pypi/v/monogate-forge.svg)](https://pypi.org/project/monogate-forge/)
51
+ [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/monogate.eml-lang?label=VS%20Code)](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang)
52
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
53
+ [![Python](https://img.shields.io/pypi/pyversions/monogate-forge.svg)](https://pypi.org/project/monogate-forge/)
54
+
55
+ **Forge is the EML language and compiler. Write a math kernel once, compile it to 32 different targets — software, GPU shaders, FPGA RTL, formal-verification proofs, and safety-critical avionics — with chain-order analysis and Lean-checkable contracts on every function.**
56
+
57
+ ---
58
+
59
+ ## Quick start
60
+
61
+ ```bash
62
+ pip install monogate-forge
63
+ ```
64
+
65
+ Create `hello.eml`:
66
+
67
+ ```eml
68
+ module hello;
69
+
70
+ fn pid(error: Real, integral: Real, derivative: Real) -> Real
71
+ where chain_order <= 0
72
+ requires (-1.0 <= error && error <= 1.0)
73
+ ensures (-1.5 * 1.0 <= result && result <= 1.5 * 1.0)
74
+ {
75
+ let kp = 1.0;
76
+ let ki = 0.2;
77
+ let kd = 0.3;
78
+ kp * error + ki * integral + kd * derivative
79
+ }
80
+ ```
81
+
82
+ Compile to every target at once:
83
+
84
+ ```bash
85
+ eml-compile hello.eml --target all -o build/
86
+ ```
87
+
88
+ You now have `build/hello.c`, `build/hello.rs`, `build/hello.py`, `build/hello.lean`, `build/hello.v`, `build/hello.hlsl`, `build/hello.metal`, `build/hello.swift`, … one file per target. Pick a single target instead:
89
+
90
+ ```bash
91
+ eml-compile hello.eml --target rust -o hello.rs
92
+ eml-compile hello.eml --target c -o hello.c
93
+ eml-compile hello.eml --target lean -o Hello.lean
94
+ ```
95
+
96
+ A snippet of `hello.rs`:
97
+
98
+ ```rust
99
+ #[inline(always)]
100
+ pub fn pid(error: f64, integral: f64, derivative: f64) -> f64 {
101
+ debug_assert!((-1.0_f64) <= error && error <= 1.0_f64);
102
+ let kp: f64 = 1.0;
103
+ let ki: f64 = 0.2;
104
+ let kd: f64 = 0.3;
105
+ kp * error + ki * integral + kd * derivative
106
+ }
107
+ ```
108
+
109
+ Five-minute tour: [`docs/quickstart.md`](docs/quickstart.md). Full tutorial: [monogate.dev/learn/eml/intro](https://monogate.dev/learn/eml/intro).
110
+
111
+ ---
112
+
113
+ ## What you get
114
+
115
+ **32 backends.** Every kernel compiles to all of these from the same source.
116
+
117
+ ### Software (general-purpose)
118
+ | Target | Flag | Tier |
119
+ |---|---|---|
120
+ | C99 | `--target c` | Free |
121
+ | C++17 | `--target cpp` | Free |
122
+ | Rust | `--target rust` | Free |
123
+ | Python 3 | `--target python` | Free |
124
+ | Go | `--target go` | Free |
125
+ | Java | `--target java` | Free |
126
+ | Kotlin | `--target kotlin` | Free |
127
+ | C# | `--target csharp` | Free |
128
+ | JavaScript | `--target javascript` | Free |
129
+ | MATLAB | `--target matlab` | Free |
130
+ | Swift | `--target swift` | Pro |
131
+
132
+ ### Compiler IRs
133
+ | Target | Flag | Tier |
134
+ |---|---|---|
135
+ | WebAssembly | `--target wasm` | Free |
136
+ | LLVM IR | `--target llvm` | Pro |
137
+
138
+ ### GPU shaders
139
+ | Target | Flag | Tier |
140
+ |---|---|---|
141
+ | HLSL (DirectX) | `--target hlsl` | Pro |
142
+ | GLSL (desktop) | `--target glsl` | Pro |
143
+ | GLSL ES | `--target glsles` | Pro |
144
+ | WGSL (WebGPU) | `--target wgsl` | Pro |
145
+ | Metal (Apple) | `--target metal` | Pro |
146
+
147
+ ### Hardware (FPGA / ASIC)
148
+ | Target | Flag | Tier |
149
+ |---|---|---|
150
+ | Verilog | `--target verilog` | Pro |
151
+ | SystemVerilog | `--target systemverilog` | Pro |
152
+ | VHDL | `--target vhdl` | Pro |
153
+ | Chisel / FIRRTL | `--target chisel` | Pro |
154
+
155
+ ### Formal verification
156
+ | Target | Flag | Tier |
157
+ |---|---|---|
158
+ | Lean 4 | `--target lean` | Free |
159
+ | Coq | `--target coq` | Pro |
160
+ | Isabelle/HOL | `--target isabelle` | Pro |
161
+
162
+ ### Safety-critical
163
+ | Target | Flag | Tier |
164
+ |---|---|---|
165
+ | Ada/SPARK | `--target ada` | Pro |
166
+ | AUTOSAR C | `--target autosar` | Pro |
167
+ | AADL | `--target aadl` | Pro |
168
+ | ROS 2 / C++ | `--target ros2` | Pro |
169
+
170
+ ### Gaming
171
+ | Target | Flag | Tier |
172
+ |---|---|---|
173
+ | Luau (Roblox) | `--target luau` | Pro |
174
+ | GDScript (Godot) | `--target gdscript` | Pro |
175
+
176
+ ### Blockchain
177
+ | Target | Flag | Tier |
178
+ |---|---|---|
179
+ | Solidity (PRBMath SD59x18) | `--target solidity` | Pro |
180
+
181
+ The Free tier — 12 targets covering general-purpose software (C, C++, Rust, Python, Go, Java, Kotlin, C#, JavaScript), web/edge runtimes (WebAssembly), MATLAB, and Lean 4 proofs — is enough to take any EML kernel from your laptop to the browser to a formal proof without a license. A Pro license unlocks the remaining 20: hardware (Verilog, VHDL, SystemVerilog, Chisel, LLVM IR), GPU shaders (HLSL, GLSL, GLSL ES, WGSL, Metal), Apple Swift, safety-critical (Ada, AUTOSAR, AADL, ROS 2), Coq, Isabelle/HOL, Solidity, and gaming (Luau, GDScript). Get a license at [monogateforge.com/get-started](https://monogateforge.com/get-started).
182
+
183
+ ---
184
+
185
+ ## VS Code extension
186
+
187
+ [![Install](https://img.shields.io/visual-studio-marketplace/d/monogate.eml-lang?label=installs)](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang)
188
+
189
+ ```
190
+ ext install monogate.eml-lang
191
+ ```
192
+
193
+ LSP features:
194
+
195
+ - **Chain-order on hover** — every function shows its profiled chain order, cost class, and node count.
196
+ - **Completions** — keywords (`fn`, `let`, `where`, `requires`, `ensures`, `module`, `use`), builtins (`exp`, `ln`, `sin`, `cos`, `sqrt`, `tanh`, `pow`, `clamp`, `eml`, …), stdlib modules.
197
+ - **Diagnostics** — type errors, unbound identifiers, chain-order violations, contract failures.
198
+ - **FPGA status bar** — for any function annotated `@target(fpga)`, the status bar shows estimated LUT / DSP / latency for the selected device.
199
+ - **Format on save** — canonical layout via `eml-fmt`.
200
+
201
+ Marketplace listing: [monogate.eml-lang](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang).
202
+
203
+ ---
204
+
205
+ ## Why Forge
206
+
207
+ Industrial automation today is stuck on ladder logic — Boolean rungs from the 1960s that can't express transcendental functions, can't prove correctness, can't optimize node count, and treat PID loops as black boxes. Structured Text is marginally better but still opaque. MATLAB/Simulink + HDL Coder will get you to FPGA, but the math hides inside vendor library calls and you have no formal proof of precision.
208
+
209
+ **EML makes every mathematical operation visible, measurable, optimizable, and formally verifiable.** Every expression is an EML tree, every function carries a chain order, every contract becomes a Lean theorem. The same source compiles to your laptop, your microcontroller, your FPGA, your Solidity contract, and your formal proof — and the cross-target equivalence harness verifies they agree to the bit.
210
+
211
+ ---
212
+
213
+ ## Documentation
214
+
215
+ - [Quickstart](docs/quickstart.md) — pip install to first compile in 5 minutes.
216
+ - [Language reference](docs/language-reference.md) — every keyword, builtin, type, and annotation.
217
+ - [Backends](docs/backends.md) — every compilation target with its CLI flag, file extension, and tier.
218
+ - [Verify guide](docs/verify-guide.md) — `@verify`, `requires`/`ensures`, Lean output, MachLib integration.
219
+ - [FPGA guide](docs/fpga-guide.md) — `@target(fpga)`, LUT/DSP estimates, precision selection, vendor support.
220
+
221
+ External:
222
+
223
+ - [monogate.dev/learn/eml/intro](https://monogate.dev/learn/eml/intro) — guided beginner tutorial.
224
+ - [monogate.dev/learn/eml/engineering](https://monogate.dev/learn/eml/engineering) — intermediate engineering course (chain orders, contracts, FPGA targeting, Lean verification).
225
+ - [monogateforge.com/get-started](https://monogateforge.com/get-started) — install the CLI and pick a tier.
226
+ - [monogate.org](https://monogate.org) — research papers and theory.
227
+ - [machlib.org](https://machlib.org) — formal library of mathematical kernels with Lean proofs.
228
+ - [arXiv preprint](https://arxiv.org/) — the EML cost conjecture and Pfaffian profile.
229
+
230
+ ---
231
+
232
+ ## Contributing
233
+
234
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md). Bug reports and feature requests via GitHub issues.
235
+
236
+ ## License
237
+
238
+ Compiler is MIT (see [`LICENSE`](LICENSE)). Specific algorithmic methods covered by patents — open implementation, but commercial re-implementations may need a license. See `patents/index.md`.
239
+
240
+ Built by [Mosa Creates LLC](https://monogateforge.com).
@@ -0,0 +1,194 @@
1
+ # Monogate Forge
2
+
3
+ [![CI](https://github.com/agent-maestro/forge/actions/workflows/ci.yml/badge.svg)](https://github.com/agent-maestro/forge/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/monogate-forge.svg)](https://pypi.org/project/monogate-forge/)
5
+ [![VS Code Marketplace](https://img.shields.io/visual-studio-marketplace/v/monogate.eml-lang?label=VS%20Code)](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![Python](https://img.shields.io/pypi/pyversions/monogate-forge.svg)](https://pypi.org/project/monogate-forge/)
8
+
9
+ **Forge is the EML language and compiler. Write a math kernel once, compile it to 32 different targets — software, GPU shaders, FPGA RTL, formal-verification proofs, and safety-critical avionics — with chain-order analysis and Lean-checkable contracts on every function.**
10
+
11
+ ---
12
+
13
+ ## Quick start
14
+
15
+ ```bash
16
+ pip install monogate-forge
17
+ ```
18
+
19
+ Create `hello.eml`:
20
+
21
+ ```eml
22
+ module hello;
23
+
24
+ fn pid(error: Real, integral: Real, derivative: Real) -> Real
25
+ where chain_order <= 0
26
+ requires (-1.0 <= error && error <= 1.0)
27
+ ensures (-1.5 * 1.0 <= result && result <= 1.5 * 1.0)
28
+ {
29
+ let kp = 1.0;
30
+ let ki = 0.2;
31
+ let kd = 0.3;
32
+ kp * error + ki * integral + kd * derivative
33
+ }
34
+ ```
35
+
36
+ Compile to every target at once:
37
+
38
+ ```bash
39
+ eml-compile hello.eml --target all -o build/
40
+ ```
41
+
42
+ You now have `build/hello.c`, `build/hello.rs`, `build/hello.py`, `build/hello.lean`, `build/hello.v`, `build/hello.hlsl`, `build/hello.metal`, `build/hello.swift`, … one file per target. Pick a single target instead:
43
+
44
+ ```bash
45
+ eml-compile hello.eml --target rust -o hello.rs
46
+ eml-compile hello.eml --target c -o hello.c
47
+ eml-compile hello.eml --target lean -o Hello.lean
48
+ ```
49
+
50
+ A snippet of `hello.rs`:
51
+
52
+ ```rust
53
+ #[inline(always)]
54
+ pub fn pid(error: f64, integral: f64, derivative: f64) -> f64 {
55
+ debug_assert!((-1.0_f64) <= error && error <= 1.0_f64);
56
+ let kp: f64 = 1.0;
57
+ let ki: f64 = 0.2;
58
+ let kd: f64 = 0.3;
59
+ kp * error + ki * integral + kd * derivative
60
+ }
61
+ ```
62
+
63
+ Five-minute tour: [`docs/quickstart.md`](docs/quickstart.md). Full tutorial: [monogate.dev/learn/eml/intro](https://monogate.dev/learn/eml/intro).
64
+
65
+ ---
66
+
67
+ ## What you get
68
+
69
+ **32 backends.** Every kernel compiles to all of these from the same source.
70
+
71
+ ### Software (general-purpose)
72
+ | Target | Flag | Tier |
73
+ |---|---|---|
74
+ | C99 | `--target c` | Free |
75
+ | C++17 | `--target cpp` | Free |
76
+ | Rust | `--target rust` | Free |
77
+ | Python 3 | `--target python` | Free |
78
+ | Go | `--target go` | Free |
79
+ | Java | `--target java` | Free |
80
+ | Kotlin | `--target kotlin` | Free |
81
+ | C# | `--target csharp` | Free |
82
+ | JavaScript | `--target javascript` | Free |
83
+ | MATLAB | `--target matlab` | Free |
84
+ | Swift | `--target swift` | Pro |
85
+
86
+ ### Compiler IRs
87
+ | Target | Flag | Tier |
88
+ |---|---|---|
89
+ | WebAssembly | `--target wasm` | Free |
90
+ | LLVM IR | `--target llvm` | Pro |
91
+
92
+ ### GPU shaders
93
+ | Target | Flag | Tier |
94
+ |---|---|---|
95
+ | HLSL (DirectX) | `--target hlsl` | Pro |
96
+ | GLSL (desktop) | `--target glsl` | Pro |
97
+ | GLSL ES | `--target glsles` | Pro |
98
+ | WGSL (WebGPU) | `--target wgsl` | Pro |
99
+ | Metal (Apple) | `--target metal` | Pro |
100
+
101
+ ### Hardware (FPGA / ASIC)
102
+ | Target | Flag | Tier |
103
+ |---|---|---|
104
+ | Verilog | `--target verilog` | Pro |
105
+ | SystemVerilog | `--target systemverilog` | Pro |
106
+ | VHDL | `--target vhdl` | Pro |
107
+ | Chisel / FIRRTL | `--target chisel` | Pro |
108
+
109
+ ### Formal verification
110
+ | Target | Flag | Tier |
111
+ |---|---|---|
112
+ | Lean 4 | `--target lean` | Free |
113
+ | Coq | `--target coq` | Pro |
114
+ | Isabelle/HOL | `--target isabelle` | Pro |
115
+
116
+ ### Safety-critical
117
+ | Target | Flag | Tier |
118
+ |---|---|---|
119
+ | Ada/SPARK | `--target ada` | Pro |
120
+ | AUTOSAR C | `--target autosar` | Pro |
121
+ | AADL | `--target aadl` | Pro |
122
+ | ROS 2 / C++ | `--target ros2` | Pro |
123
+
124
+ ### Gaming
125
+ | Target | Flag | Tier |
126
+ |---|---|---|
127
+ | Luau (Roblox) | `--target luau` | Pro |
128
+ | GDScript (Godot) | `--target gdscript` | Pro |
129
+
130
+ ### Blockchain
131
+ | Target | Flag | Tier |
132
+ |---|---|---|
133
+ | Solidity (PRBMath SD59x18) | `--target solidity` | Pro |
134
+
135
+ The Free tier — 12 targets covering general-purpose software (C, C++, Rust, Python, Go, Java, Kotlin, C#, JavaScript), web/edge runtimes (WebAssembly), MATLAB, and Lean 4 proofs — is enough to take any EML kernel from your laptop to the browser to a formal proof without a license. A Pro license unlocks the remaining 20: hardware (Verilog, VHDL, SystemVerilog, Chisel, LLVM IR), GPU shaders (HLSL, GLSL, GLSL ES, WGSL, Metal), Apple Swift, safety-critical (Ada, AUTOSAR, AADL, ROS 2), Coq, Isabelle/HOL, Solidity, and gaming (Luau, GDScript). Get a license at [monogateforge.com/get-started](https://monogateforge.com/get-started).
136
+
137
+ ---
138
+
139
+ ## VS Code extension
140
+
141
+ [![Install](https://img.shields.io/visual-studio-marketplace/d/monogate.eml-lang?label=installs)](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang)
142
+
143
+ ```
144
+ ext install monogate.eml-lang
145
+ ```
146
+
147
+ LSP features:
148
+
149
+ - **Chain-order on hover** — every function shows its profiled chain order, cost class, and node count.
150
+ - **Completions** — keywords (`fn`, `let`, `where`, `requires`, `ensures`, `module`, `use`), builtins (`exp`, `ln`, `sin`, `cos`, `sqrt`, `tanh`, `pow`, `clamp`, `eml`, …), stdlib modules.
151
+ - **Diagnostics** — type errors, unbound identifiers, chain-order violations, contract failures.
152
+ - **FPGA status bar** — for any function annotated `@target(fpga)`, the status bar shows estimated LUT / DSP / latency for the selected device.
153
+ - **Format on save** — canonical layout via `eml-fmt`.
154
+
155
+ Marketplace listing: [monogate.eml-lang](https://marketplace.visualstudio.com/items?itemName=monogate.eml-lang).
156
+
157
+ ---
158
+
159
+ ## Why Forge
160
+
161
+ Industrial automation today is stuck on ladder logic — Boolean rungs from the 1960s that can't express transcendental functions, can't prove correctness, can't optimize node count, and treat PID loops as black boxes. Structured Text is marginally better but still opaque. MATLAB/Simulink + HDL Coder will get you to FPGA, but the math hides inside vendor library calls and you have no formal proof of precision.
162
+
163
+ **EML makes every mathematical operation visible, measurable, optimizable, and formally verifiable.** Every expression is an EML tree, every function carries a chain order, every contract becomes a Lean theorem. The same source compiles to your laptop, your microcontroller, your FPGA, your Solidity contract, and your formal proof — and the cross-target equivalence harness verifies they agree to the bit.
164
+
165
+ ---
166
+
167
+ ## Documentation
168
+
169
+ - [Quickstart](docs/quickstart.md) — pip install to first compile in 5 minutes.
170
+ - [Language reference](docs/language-reference.md) — every keyword, builtin, type, and annotation.
171
+ - [Backends](docs/backends.md) — every compilation target with its CLI flag, file extension, and tier.
172
+ - [Verify guide](docs/verify-guide.md) — `@verify`, `requires`/`ensures`, Lean output, MachLib integration.
173
+ - [FPGA guide](docs/fpga-guide.md) — `@target(fpga)`, LUT/DSP estimates, precision selection, vendor support.
174
+
175
+ External:
176
+
177
+ - [monogate.dev/learn/eml/intro](https://monogate.dev/learn/eml/intro) — guided beginner tutorial.
178
+ - [monogate.dev/learn/eml/engineering](https://monogate.dev/learn/eml/engineering) — intermediate engineering course (chain orders, contracts, FPGA targeting, Lean verification).
179
+ - [monogateforge.com/get-started](https://monogateforge.com/get-started) — install the CLI and pick a tier.
180
+ - [monogate.org](https://monogate.org) — research papers and theory.
181
+ - [machlib.org](https://machlib.org) — formal library of mathematical kernels with Lean proofs.
182
+ - [arXiv preprint](https://arxiv.org/) — the EML cost conjecture and Pfaffian profile.
183
+
184
+ ---
185
+
186
+ ## Contributing
187
+
188
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md). Bug reports and feature requests via GitHub issues.
189
+
190
+ ## License
191
+
192
+ Compiler is MIT (see [`LICENSE`](LICENSE)). Specific algorithmic methods covered by patents — open implementation, but commercial re-implementations may need a license. See `patents/index.md`.
193
+
194
+ Built by [Mosa Creates LLC](https://monogateforge.com).
@@ -0,0 +1,49 @@
1
+ # Forge examples
2
+
3
+ Small, public `.eml` files that demonstrate language features
4
+ without revealing proprietary kernel content. Ship with the
5
+ PyPI wheel; reference these from the README, docs, and live
6
+ demo gallery.
7
+
8
+ ## Quick tour
9
+
10
+ | File | Chain order | Teaches |
11
+ |---|---:|---|
12
+ | `hello.eml` | 0 | Module declaration, function, literal return |
13
+ | `lerp.eml` | 0 | Polynomial body, multiple inputs |
14
+ | `quadratic.eml` | 0 | `a*x^2 + b*x + c` — the canonical chain-0 polynomial |
15
+ | `pid_controller.eml` | 0 | `requires` / `ensures` clamp contract |
16
+ | `clamp_bounded.eml` | 0 | `clamp` builtin + `@verify` postcondition |
17
+ | `verified_add.eml` | 0 | The smallest `@verify` shape (two `requires`, one `ensures`) |
18
+ | `smoothstep.eml` | 0 | Polynomial smoothing curve with `@verify` |
19
+ | `exponential_decay.eml` | 1 | `exp(-k*t)` — the chain-1 archetype |
20
+ | `sine_oscillator.eml` | 1 | `sin(omega*t)` with amplitude `@verify` |
21
+ | `gaussian.eml` | 1 | `exp(-(x-mu)^2/...)` — the bell curve |
22
+ | `sigmoid.eml` | 2 | `1 / (1 + exp(-x))` — the chain-2 ML activation |
23
+ | `damped_wave.eml` | 2 | `exp(-zeta*t) * sin(omega*t)` — the chain-2 archetype |
24
+
25
+ ## Running
26
+
27
+ Every file compiles to every backend in your tier:
28
+
29
+ ```bash
30
+ # Free tier — 12 backends
31
+ eml-compile examples/hello.eml --target python
32
+ eml-compile examples/pid_controller.eml --target rust
33
+ eml-compile examples/sigmoid.eml --target lean
34
+
35
+ # Compile all Free targets at once
36
+ eml-compile examples/damped_wave.eml --target all
37
+ ```
38
+
39
+ ## What's not here
40
+
41
+ The full kernel library — aerospace flight control, automotive
42
+ powertrain, medical infusion, robotics, crypto, gaming, and a
43
+ dozen more domains — is the proprietary product. It ships with
44
+ Forge Pro plans at <https://monogateforge.com/get-started>.
45
+
46
+ The compiler is open. The kernels are the product. Anyone can
47
+ write their own `.eml`, profile it with `eml-cost`, and compile
48
+ to any of the 32 backends. The pre-verified domain library is
49
+ what's gated.
@@ -0,0 +1,17 @@
1
+ """Forge example .eml files (bundled with the PyPI wheel).
2
+
3
+ This package exists only so setuptools.find can pick up the
4
+ examples/ directory and ship its .eml content alongside the
5
+ compiler. There is no Python code here -- treat the .eml
6
+ files as data, accessible via importlib.resources:
7
+
8
+ from importlib.resources import files
9
+ eml_text = files("examples").joinpath("hello.eml").read_text()
10
+
11
+ For interactive use, just:
12
+
13
+ eml-compile examples/hello.eml --target python
14
+
15
+ from a Forge checkout, or copy the files out of the wheel
16
+ install path.
17
+ """
@@ -0,0 +1,20 @@
1
+ // clamp_bounded.eml -- clamp a real to a fixed interval and
2
+ // prove the output lives there. The simplest non-trivial
3
+ // `@verify` example: a precondition-free contract whose
4
+ // postcondition follows from the body's structure.
5
+ //
6
+ // Chain order 0 -- `clamp` is a builtin rational primitive.
7
+
8
+ module clamp_bounded;
9
+
10
+ const LO: Real = -1.0
11
+ const HI: Real = 1.0
12
+
13
+ @verify(lean, theorem = "clamp_in_unit_interval")
14
+ fn clamp_unit(x: Real) -> Real
15
+ where chain_order <= 0
16
+ ensures (result >= LO)
17
+ ensures (result <= HI)
18
+ {
19
+ clamp(x, LO, HI)
20
+ }
@@ -0,0 +1,20 @@
1
+ // damped_wave.eml -- exp * sin, the chain-2 archetype.
2
+ //
3
+ // y(t) = exp(-zeta * t) * sin(omega * t)
4
+ //
5
+ // The bedrock damped oscillation. Two transcendentals nested
6
+ // over polynomial arguments -- chain order 2. This shape
7
+ // describes a settling spring, a reverb tail, a relaxation
8
+ // curve, and the impulse response of a second-order linear
9
+ // system.
10
+
11
+ module damped_wave;
12
+
13
+ fn damped_wave(zeta: Real, omega: Real, t: Real) -> Real
14
+ where chain_order <= 2
15
+ requires (zeta >= 0.0)
16
+ requires (omega >= 0.0)
17
+ requires (t >= 0.0)
18
+ {
19
+ exp(-zeta * t) * sin(omega * t)
20
+ }
@@ -0,0 +1,18 @@
1
+ // exponential_decay.eml -- the canonical chain-1 example.
2
+ //
3
+ // y(t) = exp(-k * t)
4
+ //
5
+ // One transcendental (exp) wrapped around a polynomial argument:
6
+ // chain order 1. The same shape governs RC discharge, radioactive
7
+ // decay, lossy reverb tails, and Adam's first-moment bias term --
8
+ // the structural class is the same across every domain.
9
+
10
+ module exponential_decay;
11
+
12
+ fn decay(k: Real, t: Real) -> Real
13
+ where chain_order <= 1
14
+ requires (k >= 0.0)
15
+ requires (t >= 0.0)
16
+ {
17
+ exp(-k * t)
18
+ }
@@ -0,0 +1,18 @@
1
+ // gaussian.eml -- the bell curve.
2
+ //
3
+ // p(x; mu, sigma) = (1/sigma) * exp(-((x-mu)^2 / (2*sigma^2)))
4
+ //
5
+ // Chain order 1 in EML's structural sense: one transcendental
6
+ // (exp) wrapping a polynomial argument. Shows up in statistics,
7
+ // ML loss landscapes, image filters, antenna patterns, and
8
+ // quantum harmonic oscillators -- the same EML genome each time.
9
+
10
+ module gaussian;
11
+
12
+ fn gaussian(mu: Real, sigma: Real, x: Real) -> Real
13
+ where chain_order <= 1
14
+ requires (sigma > 0.0)
15
+ {
16
+ let dx = x - mu;
17
+ exp(-dx * dx / (2.0 * sigma * sigma)) / sigma
18
+ }
@@ -0,0 +1,17 @@
1
+ // hello.eml -- the smallest possible Forge program.
2
+ //
3
+ // One module, one function, no inputs, returns a constant.
4
+ // Chain order 0 because the body is a literal.
5
+ //
6
+ // Compile this to anything:
7
+ // eml-compile examples/hello.eml --target python
8
+ // eml-compile examples/hello.eml --target rust
9
+ // eml-compile examples/hello.eml --target verilog
10
+
11
+ module hello;
12
+
13
+ fn answer() -> Real
14
+ where chain_order <= 0
15
+ {
16
+ 42.0
17
+ }
@@ -0,0 +1,14 @@
1
+ // lerp.eml -- linear interpolation. The "hello world" of math
2
+ // in graphics, animation, and signal processing.
3
+ //
4
+ // lerp(a, b, t) = a + t * (b - a)
5
+ //
6
+ // Chain order 0: the body is a polynomial in the inputs.
7
+
8
+ module lerp;
9
+
10
+ fn lerp(a: Real, b: Real, t: Real) -> Real
11
+ where chain_order <= 0
12
+ {
13
+ a + t * (b - a)
14
+ }
@@ -0,0 +1,30 @@
1
+ // pid_controller.eml -- the textbook PID controller.
2
+ //
3
+ // output = Kp * error + Ki * integral + Kd * derivative
4
+ //
5
+ // Universal control loop: heating, motors, robots, drones,
6
+ // rockets. Chain order 0 (a linear combination of the inputs).
7
+ // The interesting part is the @verify contract: the output is
8
+ // always clamped to the actuator's physical range.
9
+
10
+ module pid_controller;
11
+
12
+ const Kp: Real = 1.5
13
+ const Ki: Real = 0.4
14
+ const Kd: Real = 0.05
15
+
16
+ const OUT_MIN: Real = -1.0
17
+ const OUT_MAX: Real = 1.0
18
+
19
+ @verify(lean, theorem = "pid_output_clamped")
20
+ fn pid(error: Real, integral: Real, derivative: Real) -> Real
21
+ where chain_order <= 0
22
+ requires (abs(error) <= 100.0)
23
+ requires (abs(integral) <= 100.0)
24
+ requires (abs(derivative) <= 100.0)
25
+ ensures (result >= OUT_MIN)
26
+ ensures (result <= OUT_MAX)
27
+ {
28
+ let raw = Kp * error + Ki * integral + Kd * derivative;
29
+ clamp(raw, OUT_MIN, OUT_MAX)
30
+ }