-- Generated by EML-lang Luau backend -- Source module: aerospace_actuator_guard_band -- Kernel digest: sha256:0b0ef5a5baecb59acc7d28dc64bc959d9f3378cfbc278204c737cef5bc755aaa -- Functions: 1 -- Constants: 0 local M = {} local function eml_builtin_max(a: number, b: number): number if a ~= a then return a end if b ~= b then return b end if a < b then return b end if b < a then return a end -- a == b is the SIGNED ZERO case: IEEE 754-2019 maximum returns the POSITIVE zero, where -- math.max returns its FIRST argument on a tie (max(-0.0, 0.0) was -0.0, measured -- by bits). (-0)+(+0) is +0 and (-0)+(-0) is -0, so a + b IS the maximum of two zeros. if a == 0 then return a + b end return a end local function eml_builtin_min(a: number, b: number): number if a ~= a then return a end if b ~= b then return b end if a < b then return a end if b < a then return b end -- a == b is the SIGNED ZERO case: IEEE 754-2019 minimum returns the NEGATIVE zero, where -- math.min returns its FIRST argument on a tie (min(0.0, -0.0) was 0.0, measured -- by bits). -((-a) + (-b)) is -0.0 unless both are +0.0. if a == 0 then return -((-a) + (-b)) end return a end -- actuator_command_within_band -- Pfaffian profile: pfaffian_r=0, cost_class=p0-d4-w0-c0, drift_risk=LOW. -- forge.requires: (u_min <= u_max) -- forge.ensures: (u_min <= result) -- forge.ensures: (result <= u_max) -- source obligations for actuator_command_within_band: {O1, O2} -- O1 [43d7c3ff9568] -> PRESERVED (equivalent) error() before return; no Luau build flag removes it -- build: unconditional -- error(); no Luau build flag removes it -- O2 [ca2e303109b7] -> PRESERVED (equivalent) error() before return; no Luau build flag removes it -- build: unconditional -- error(); no Luau build flag removes it -- forge.verify: lean theorem=actuator_command_within_band function M.actuator_command_within_band(error_: number, integral: number, deriv: number, kp: number, ki: number, kd: number, u_min: number, u_max: number): number assert((u_min <= u_max), "actuator_command_within_band: requires (u_min <= u_max)") local result = eml_builtin_max(u_min, eml_builtin_min((((kp * error_) + (ki * integral)) + (kd * deriv)), u_max)) if not ((u_min <= result)) then error("actuator_command_within_band: ensures violated: (u_min <= result)") end if not ((result <= u_max)) then error("actuator_command_within_band: ensures violated: (result <= u_max)") end return result end return M