// Generated by EML-lang Kotlin backend // Source module: aerospace_actuator_guard_band // Kernel digest: sha256:0b0ef5a5baecb59acc7d28dc64bc959d9f3378cfbc278204c737cef5bc755aaa // Functions: 1 // Constants: 0 package forge.aerospace_actuator_guard_band import kotlin.math.* /** * 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) throw before return; NOT Kotlin `assert`, which needs java -ea and is off by default * build: unconditional -- an explicit throw, NOT Kotlin `assert`, which needs java -ea and is off by default * O2 [ca2e303109b7] -> PRESERVED (equivalent) throw before return; NOT Kotlin `assert`, which needs java -ea and is off by default * build: unconditional -- an explicit throw, NOT Kotlin `assert`, which needs java -ea and is off by default * @forge.verify lean theorem=actuator_command_within_band */ fun actuator_command_within_band(error: Double, integral: Double, deriv: Double, kp: Double, ki: Double, kd: Double, u_min: Double, u_max: Double): Double { require((u_min <= u_max)) { "actuator_command_within_band: requires (u_min <= u_max)" } val result = kotlin.math.max(u_min, kotlin.math.min((((kp * error) + (ki * integral)) + (kd * deriv)), u_max)) if (!((u_min <= result))) throw IllegalStateException("actuator_command_within_band: ensures violated: (u_min <= result)") if (!((result <= u_max))) throw IllegalStateException("actuator_command_within_band: ensures violated: (result <= u_max)") return result }