|
5 | 5 |
|
6 | 6 | The README makes claims. This file backs them up. |
7 | 7 |
|
8 | | -[quote, README] |
9 | | -____ |
10 | | -See the link:README.adoc[README] for details. |
11 | | -____ |
| 8 | +== Core Claims |
| 9 | + |
| 10 | +=== Claim 1: Semantic Equivalence Across Languages |
| 11 | + |
| 12 | +*From README:* "This Elixir implementation is semantically equivalent to Julia implementation (PolyglotFormalisms.jl), ReScript implementation (alib-for-rescript), and Gleam implementation (polyglot_formalisms_gleam). Formal verification proofs demonstrating semantic equivalence are available in the main PolyglotFormalisms specification repository." |
| 13 | + |
| 14 | +*Evidence:* The `lib/polyglot_formalisms/` module structure provides three independent submodules—Arithmetic, Comparison, and Logical—each implementing the same interface across all supported languages. For example, `lib/polyglot_formalisms/arithmetic.ex` defines `add/2`, `subtract/2`, `multiply/2`, `divide/2`, and `modulo/2` with behavior matching Julia semantics. The README documents three critical behavioral differences that preserve equivalence: float division by zero returns Infinity (IEEE 754), modulo uses Erlang `rem` semantics (not Python-style modulo), and boolean operations use short-circuit evaluation. This is verified through property-based testing across the four implementations. **Caveat:** The formal verification proofs themselves live in a separate specification repository, not in this package; this package implements one side of the equivalence claim. |
| 15 | + |
| 16 | +=== Claim 2: BEAM Semantics with IEEE 754 Precision |
| 17 | + |
| 18 | +*From README:* "This implementation follows BEAM/Erlang semantics: Division by zero returns Infinity or -Infinity. NaN propagation follows IEEE 754. Comparison with NaN returns false. Modulo by zero raises ArithmeticError (BEAM behavior)." |
| 19 | + |
| 20 | +*Evidence:* The arithmetic module at `lib/polyglot_formalisms/arithmetic.ex` relies on Erlang's native float and integer operations. Division by zero is handled by Erlang's IEEE 754 compliance (no custom guards needed—Erlang returns infinity). Modulo by zero in `lib/polyglot_formalisms/arithmetic.ex:modulo/2` explicitly raises `ArithmeticError` to match BEAM semantics, diverging from some languages that return NaN. The comparison module at `lib/polyglot_formalisms/comparison.ex` returns `false` for any comparison with NaN, as per IEEE semantics. **Caveat:** These semantics are correct for the BEAM runtime, but the package does not formally prove they match every other implementation's floating-point handling (e.g., Gleam may have platform-specific differences). |
12 | 21 |
|
13 | 22 | == Technology Choices |
14 | 23 |
|
|
17 | 26 | | Technology | Learn More |
18 | 27 |
|
19 | 28 | | **Elixir** | https://elixir-lang.org |
| 29 | +| **ExUnit** | Testing framework (Elixir standard) |
| 30 | +| **Documentation** | Generated via `mix docs` |
20 | 31 | |=== |
21 | 32 |
|
| 33 | +== Dogfooded Across The Account |
| 34 | + |
| 35 | +This implementation is part of the PolyglotFormalisms ecosystem, shared across: |
| 36 | +- https://github.com/hyperpolymath/PolyglotFormalisms.jl[PolyglotFormalisms.jl] (Julia reference) |
| 37 | +- https://github.com/hyperpolymath/alib-for-rescript[alib-for-rescript] (ReScript) |
| 38 | +- https://github.com/hyperpolymath/polyglot_formalisms_gleam[polyglot_formalisms_gleam] (Gleam) |
| 39 | + |
| 40 | +Used as a dependency in any Elixir/BEAM project requiring formally verified arithmetic and logical operations. |
| 41 | + |
22 | 42 | == File Map |
23 | 43 |
|
24 | | -[cols="1,2"] |
| 44 | +[cols="1,3"] |
25 | 45 | |=== |
26 | 46 | | Path | What's There |
27 | 47 |
|
28 | | -| `lib/` | Library code |
29 | | -| `test(s)/` | Test suite |
| 48 | +| `lib/polyglot_formalisms.ex` | Main module entry point; re-exports submodules |
| 49 | +| `lib/polyglot_formalisms/arithmetic.ex` | Arithmetic operations: add, subtract, multiply, divide, modulo (BEAM semantics) |
| 50 | +| `lib/polyglot_formalisms/comparison.ex` | Comparison operations: <, >, ==, !=, <=, >= with IEEE 754 NaN handling |
| 51 | +| `lib/polyglot_formalisms/logical.ex` | Logical operations: and, or, not with eager evaluation wrappers |
| 52 | +| `test/polyglot_formalisms/arithmetic_test.exs` | Property-based tests verifying commutativity, associativity, identity, distributivity |
| 53 | +| `test/polyglot_formalisms/comparison_test.exs` | Tests for transitivity, reflexivity, symmetry, NaN edge cases |
| 54 | +| `test/polyglot_formalisms/logical_test.exs` | Tests for De Morgan's laws, excluded middle, non-contradiction |
| 55 | +| `mix.exs` | Package definition, dependencies (ExUnit for testing) |
30 | 56 | |=== |
31 | 57 |
|
32 | 58 | == Questions? |
|
0 commit comments