hive-view
aien-dev/hive-view
Brought by drakestapleton
hive-view / evidence / cpu-shares.lean
| 1 | import Mathlib |
| 2 | |
| 3 | /-! hive-view CPU shares, as reported in README.md and evidence/2026-11-07-v1.md. |
| 4 | |
| 5 | `gate cpu PID 60` counts CPU ticks at USER_HZ = 100 over 60 s, so one core supplies 60*100 ticks |
| 6 | and the 20-core Spark 60*100*20. The measured tick counts (182, 76, 171) are MEASURED inputs; this |
| 7 | file proves only the arithmetic from them to the percentages shown, and the rounding. |
| 8 | |
| 9 | Checked with Lean 4 v4.35.0 and Mathlib 56a005855ea17e0b0958f73ec801ae140b0a1679: |
| 10 | `lake env lean evidence/cpu-shares.lean` in a project with that toolchain and Mathlib. -/ |
| 11 | |
| 12 | theorem run1_core : (182:ℚ) / (60*100) * 100 = 91/30 := by norm_num |
| 13 | theorem run2_core : (76:ℚ) / (60*100) * 100 = 19/15 := by norm_num |
| 14 | theorem run3_core : (171:ℚ) / (60*100) * 100 = 57/20 := by norm_num |
| 15 | theorem run1_machine : (182:ℚ) / (60*100*20) * 100 = 91/600 := by norm_num |
| 16 | theorem run2_machine : (76:ℚ) / (60*100*20) * 100 = 19/300 := by norm_num |
| 17 | theorem run3_machine : (171:ℚ) / (60*100*20) * 100 = 57/400 := by norm_num |
| 18 | |
| 19 | /-- The shown values 3.03, 1.27, 2.85 (% of one core) and 0.15, 0.063, 0.1425 (% of the machine) |
| 20 | are each within half a unit of their last shown digit of the exact value. -/ |
| 21 | theorem shown_values_round : |
| 22 | |(91/30:ℚ) - 303/100| < 1/200 ∧ |(19/15:ℚ) - 127/100| < 1/200 ∧ (57/20:ℚ) = 285/100 ∧ |
| 23 | |(91/600:ℚ) - 15/100| < 1/200 ∧ |(19/300:ℚ) - 63/1000| < 1/2000 ∧ (57/400:ℚ) = 1425/10000 := by |
| 24 | norm_num [abs_lt] |