// SPDX-License-Identifier: MIT // Generated by EML-lang Solidity backend // Source module: vibration_rms // Source file: /home/monogate/monogate/forge/examples/vibration_rms.eml // Functions: 1 (1 @verify-annotated) // Constants: 2 // Transcendental stubs: sqrt -- override in a derived contract (see PRBMath SD59x18) // WARNING: 1 fractional Real literal(s) were rounded to int256 (e.g. 0.6108 -> 1). // For fixed-point semantics, scale your EML constants // by WAD (1e18) and override the transcendental stubs // with PRBMath SD59x18 in a derived contract. pragma solidity ^0.8.20; contract VibrationRms { int256 constant NOISE_FLOOR = 0 /* 0.25 rounded; see header re fixed-point */; int256 constant RMS_MAX = 50; /// @notice Formal proof: vibration_rms_within_range (MachLib). Compiled from EML-lang. /// @dev Pfaffian profile: chain_order=1, cost_class=p1-d5-w1-c0, drift_risk=MEDIUM. /// @dev Gas estimate: ~1,300 gas (PRBMath SD59x18 overrides assumed; run forge gas-bench for the canonical signal). /// @param ax ax (int256) /// @param ay ay (int256) /// @dev ensures: (result >= 0) /// @dev ensures: (result <= RMS_MAX) function vibrationRms(int256 ax, int256 ay) external pure returns (int256) { require(((ax < 0 ? -ax : ax) <= 30), "vibration_rms: refinement violated on ax: ((ax < 0 ? -ax : ax) <= 30)"); require(((ay < 0 ? -ay : ay) <= 30), "vibration_rms: refinement violated on ay: ((ay < 0 ? -ay : ay) <= 30)"); int256 mag = _sqrt((((ax * ax) + (ay * ay)) + NOISE_FLOOR)); return _clamp(mag, 0, RMS_MAX); } /// @dev clamp helper -- min(max(x, lo), hi). function _clamp(int256 x, int256 lo, int256 hi) internal pure returns (int256) { if (x < lo) return lo; if (x > hi) return hi; return x; } /// @dev sqrt stub — override with a fixed-point implementation. function _sqrt(int256 x) internal pure virtual returns (int256) { x; // silence unused-param warning revert("_sqrt: stub — override in a derived contract (see PRBMath SD59x18.sqrt)"); } }