// SPDX-License-Identifier: MIT // Generated by EML-lang Solidity backend // Source module: soft_actuator // Source file: /home/monogate/monogate/forge/examples/soft_actuator.eml // Functions: 1 (1 @verify-annotated) // Constants: 2 // Transcendental stubs: tanh -- override in a derived contract (see PRBMath SD59x18) pragma solidity ^0.8.20; contract SoftActuator { int256 constant OUT_MIN = (-1); int256 constant OUT_MAX = 1; /// @notice Formal proof: soft_actuator_within_band (MachLib). Compiled from EML-lang. /// @dev Pfaffian profile: chain_order=1, cost_class=p1-d4-w1-c0, drift_risk=MEDIUM. /// @dev Gas estimate: ~7,300 gas (PRBMath SD59x18 overrides assumed; run forge gas-bench for the canonical signal). /// @param error error (int256) /// @param gain gain (int256) /// @dev ensures: (result >= OUT_MIN) /// @dev ensures: (result <= OUT_MAX) function softActuator(int256 error, int256 gain) external pure returns (int256) { require(((error < 0 ? -error : error) <= 100), "soft_actuator: refinement violated on error: ((error < 0 ? -error : error) <= 100)"); require(((gain < 0 ? -gain : gain) <= 10), "soft_actuator: refinement violated on gain: ((gain < 0 ? -gain : gain) <= 10)"); int256 raw = _tanh((gain * error)); return _clamp(raw, OUT_MIN, OUT_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 tanh stub — override with a fixed-point implementation. function _tanh(int256 x) internal pure virtual returns (int256) { x; // silence unused-param warning revert("_tanh: stub — override in a derived contract (see PRBMath SD59x18.tanh)"); } }