Text Generation
Transformers
entropy
hallucination
logits-processor
lean4
formal-verification
cuda-q
temperature-scheduling
audit-log
harness
guardrails
snapkitty
agda
python
cuda
Instructions to use Snapkitty/sovereign-entropy-theorem with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Snapkitty/sovereign-entropy-theorem with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Snapkitty/sovereign-entropy-theorem")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Snapkitty/sovereign-entropy-theorem", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Snapkitty/sovereign-entropy-theorem with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Snapkitty/sovereign-entropy-theorem" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Snapkitty/sovereign-entropy-theorem", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Snapkitty/sovereign-entropy-theorem
- SGLang
How to use Snapkitty/sovereign-entropy-theorem with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Snapkitty/sovereign-entropy-theorem" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Snapkitty/sovereign-entropy-theorem", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Snapkitty/sovereign-entropy-theorem" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Snapkitty/sovereign-entropy-theorem", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Snapkitty/sovereign-entropy-theorem with Docker Model Runner:
docker model run hf.co/Snapkitty/sovereign-entropy-theorem
Download lean/EntropyBound.lean from Snapkitty/sovereign-entropy-theorem: direct link, hf CLI and curl.
- Browser
- Download file 28.5 kB
-
https://huggingface.co/Snapkitty/sovereign-entropy-theorem/resolve/main/lean/EntropyBound.lean
- Command line
-
hf download hf://Snapkitty/sovereign-entropy-theorem/lean/EntropyBound.lean
-
curl -L -o EntropyBound.lean https://huggingface.co/Snapkitty/sovereign-entropy-theorem/resolve/main/lean/EntropyBound.lean
28.5 kB
| /-! | |
| # Sovereign Entropy Theorem β Lean 4 Formalization (Complete) | |
| Formal statement of the entropy bound guaranteed by discrete minimization. | |
| The ASP case is one instance. The general theorem covers any system with: | |
| - Integer-valued energy function F β₯ 0 | |
| - Temperature schedule T = Tβ + (1-Tβ)Β·exp(-Ξ±Β·F) | |
| - K ground states | |
| - Minimum logit difference d β₯ 1 | |
| Author: Ahmad Ali Parr | |
| Trust: Bel Esprit D'Accord Irrevocable Trust Β· EIN 42-697643 | |
| ΞΈ = 89/2462 | |
| -/ | |
| import Mathlib.Analysis.SpecialFunctions.ExpDeriv | |
| import Mathlib.Analysis.SpecialFunctions.Log.Basic | |
| import Mathlib.Analysis.Calculus.MeanValue | |
| import Mathlib.Analysis.SpecialFunctions.Pow.Real | |
| import Mathlib.Tactic | |
| namespace SovereignEntropy | |
| open Real | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- TYPES | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- Frustration count β non-negative integer energy function -/ | |
| def FrustrationCount := β | |
| /-- Temperature schedule from Ahmad's ICP engine -/ | |
| noncomputable def temperature (F : FrustrationCount) : β := | |
| max 0.1 (0.1 + 0.9 * Real.exp (-2.0 * F)) | |
| /-- Softmax ratio for two experts with logit difference d -/ | |
| noncomputable def softmax_ratio (d T : β) : β := | |
| Real.exp (d / T) | |
| /-- Binary entropy as function of softmax ratio s -/ | |
| noncomputable def binary_entropy (s : β) : β := | |
| Real.log (s + 1) - s * Real.log s / (s + 1) | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- AUXILIARY LEMMAS | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| lemma exp_neg_two_lt : Real.exp (-2 : β) < 0.1354 := by | |
| have := Real.exp_one_lt_d9 | |
| have hβ : Real.exp (-2 : β) = 1 / Real.exp 2 := by | |
| rw [Real.exp_neg] | |
| <;> field_simp [Real.exp_ne_zero] | |
| rw [hβ] | |
| have hβ : Real.exp 2 > 7.389 := by | |
| have := Real.exp_one_gt_d9 | |
| have hβ : Real.exp 2 = Real.exp 1 * Real.exp 1 := by | |
| rw [β Real.exp_add] <;> ring_nf | |
| rw [hβ] | |
| norm_num [Real.exp_pos] at * | |
| <;> nlinarith [Real.exp_pos 1] | |
| have hβ : (1 : β) / Real.exp 2 < 0.1354 := by | |
| rw [div_lt_iff (by positivity)] | |
| norm_num at hβ β’ | |
| <;> nlinarith | |
| linarith | |
| lemma exp_neg_two_gt : Real.exp (-2 : β) > 0.1353 := by | |
| have hβ : Real.exp (-2 : β) = 1 / Real.exp 2 := by | |
| rw [Real.exp_neg] | |
| <;> field_simp [Real.exp_ne_zero] | |
| rw [hβ] | |
| have hβ : Real.exp 2 < 7.390 := by | |
| have := Real.exp_one_lt_d9 | |
| have hβ : Real.exp 2 = Real.exp 1 * Real.exp 1 := by | |
| rw [β Real.exp_add] <;> ring_nf | |
| rw [hβ] | |
| norm_num [Real.exp_pos] at * | |
| <;> nlinarith [Real.exp_pos 1] | |
| have hβ : (1 : β) / Real.exp 2 > 0.1353 := by | |
| rw [gt_iff_lt] | |
| rw [lt_div_iff (by positivity)] | |
| norm_num at hβ β’ | |
| <;> nlinarith | |
| linarith | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- LEMMA 1: Temperature bound when F β₯ 1 | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- When frustration F β₯ 1, temperature T β€ 0.2218 -/ | |
| lemma temperature_bound_when_active (F : FrustrationCount) (hF : F β₯ 1) : | |
| temperature F β€ 0.2218 := by | |
| unfold temperature | |
| have hβ : (F : β) β₯ 1 := by exact_mod_cast hF | |
| have hβ : Real.exp (-2.0 * (F : β)) β€ Real.exp (-2.0 : β) := by | |
| apply Real.exp_le_exp.mpr | |
| have hβ : (-2.0 : β) * (F : β) β€ (-2.0 : β) := by | |
| have hβ : (F : β) β₯ 1 := by exact_mod_cast hF | |
| nlinarith | |
| exact_mod_cast hβ | |
| have hβ : (0.1 : β) + 0.9 * Real.exp (-2.0 : β) β€ 0.2218 := by | |
| have hβ : Real.exp (-2.0 : β) < 0.1354 := by | |
| simpa [Real.exp_neg] using exp_neg_two_lt | |
| norm_num at hβ β’ | |
| <;> nlinarith | |
| have hβ : max (0.1 : β) (0.1 + 0.9 * Real.exp (-2.0 * (F : β))) β€ 0.2218 := by | |
| apply max_le_iff.mpr | |
| constructor <;> norm_num at hβ hβ β’ <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith [Real.exp_pos (-2.0 * (F : β)), Real.exp_pos (-2.0 : β)]) | |
| exact hβ | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- LEMMA 2: Softmax ratio lower bound | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- When T β€ 0.2218 and d β₯ 1, softmax ratio s β₯ 90.75 -/ | |
| lemma softmax_ratio_lower_bound (T d : β) (hT : 0 < T) (hT2 : T β€ 0.2218) (hd : d β₯ 1) : | |
| softmax_ratio d T β₯ 90.75 := by | |
| unfold softmax_ratio | |
| have hβ : d / T β₯ 1 / 0.2218 := by | |
| have hβ : 0 < T := hT | |
| have hβ : T β€ 0.2218 := hT2 | |
| have hβ : d β₯ 1 := hd | |
| have hβ : 0 < (0.2218 : β) := by norm_num | |
| have hβ : 0 < (1 : β) / 0.2218 := by positivity | |
| have hβ : d / T β₯ 1 / T := by | |
| apply (div_le_div_iff (by positivity) (by positivity)).mpr | |
| nlinarith | |
| have hβ : (1 : β) / T β₯ 1 / 0.2218 := by | |
| apply one_div_le_one_div_of_le | |
| Β· positivity | |
| Β· linarith | |
| linarith | |
| have hβ : Real.exp (d / T) β₯ Real.exp (1 / 0.2218) := Real.exp_le_exp.mpr hβ | |
| have hβ : Real.exp (1 / 0.2218 : β) β₯ 90.75 := by | |
| have := Real.add_one_le_exp (1 / 0.2218 : β) | |
| norm_num at this β’ | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith [Real.exp_pos (1 / 0.2218 : β)]) | |
| linarith | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- LEMMA 3: Binary entropy is decreasing for s β₯ 1 | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- Derivative of binary entropy: H'(s) = -log(s) / (s+1)Β² < 0 for s > 1 -/ | |
| lemma binary_entropy_deriv_neg {s : β} (hs : s > 1) : | |
| deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) s < 0 := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (-Real.log s / (s + 1) ^ 2) s := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1)) (1 / (s + 1)) s := by | |
| have hβ : HasDerivAt (fun x : β => x + 1) 1 s := by simpa using (hasDerivAt_id s).add_const 1 | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1)) (1 / (s + 1)) s := by | |
| have hβ : HasDerivAt (fun x : β => x + 1) 1 s := hβ | |
| have hβ : (s + 1 : β) > 0 := by linarith | |
| convert HasDerivAt.log hβ (by positivity) using by field_simp <;> ring | |
| exact hβ | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log s + 1) * (s + 1) - s * Real.log s) / (s + 1) ^ 2 s := by | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x) (Real.log s + 1) s := by | |
| have hβ : HasDerivAt (fun x : β => x) 1 s := hasDerivAt_id s | |
| have hβ : HasDerivAt (fun x : β => Real.log x) (1 / s) s := by | |
| have hβ : HasDerivAt (fun x : β => Real.log x) (1 / s) s := by | |
| convert Real.hasDerivAt_log (by linarith) using by field_simp | |
| exact hβ | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x) (1 * Real.log s + s * (1 / s)) s := | |
| HasDerivAt.mul hβ hβ | |
| convert hβ using by | |
| have hβ : s β 0 := by linarith | |
| field_simp [hβ] | |
| <;> ring_nf | |
| <;> field_simp [hβ] | |
| <;> nlinarith | |
| have hβ : HasDerivAt (fun x : β => (x : β) + 1) 1 s := by | |
| simpa using (hasDerivAt_id s).add_const 1 | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log s + 1) * (s + 1) - s * Real.log s) / (s + 1) ^ 2 s := by | |
| convert HasDerivAt.div hβ hβ (by linarith) using by | |
| field_simp [add_assoc] | |
| <;> ring_nf | |
| <;> field_simp [add_assoc] | |
| <;> nlinarith | |
| exact hβ | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (1 / (s + 1) - ((Real.log s + 1) * (s + 1) - s * Real.log s) / (s + 1) ^ 2) s := by | |
| convert hβ.sub hβ using by ring | |
| have hβ : (1 / (s + 1) - ((Real.log s + 1) * (s + 1) - s * Real.log s) / (s + 1) ^ 2 : β) = -Real.log s / (s + 1) ^ 2 := by | |
| have hβ : s > 0 := by linarith | |
| have hββ : s + 1 β 0 := by linarith | |
| field_simp [hββ] | |
| <;> ring_nf | |
| <;> field_simp [hββ] | |
| <;> nlinarith [Real.log_pos (by norm_num : (1 : β) < 2)] | |
| <;> | |
| (try | |
| { | |
| nlinarith [Real.log_le_sub_one_of_pos (by linarith : (0 : β) < s)] | |
| }) | |
| rw [hβ] at hβ | |
| exact hβ | |
| have hβ : deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) s = -Real.log s / (s + 1) ^ 2 := by | |
| apply HasDerivAt.deriv | |
| exact hβ | |
| rw [hβ] | |
| have hβ : Real.log s > 0 := Real.log_pos (by linarith) | |
| have hβ : (s + 1 : β) ^ 2 > 0 := by positivity | |
| have hβ : -Real.log s / (s + 1) ^ 2 < 0 := by | |
| apply div_neg_of_neg_of_pos | |
| Β· linarith | |
| Β· positivity | |
| exact hβ | |
| /-- binary_entropy is strictly decreasing for s > 1 -/ | |
| lemma binary_entropy_decreasing {sβ sβ : β} (hsβ : sβ > 1) (hsβ : sβ > sβ) : | |
| binary_entropy sβ < binary_entropy sβ := by | |
| have hβ : ContinuousOn (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) (Set.Icc sβ sβ) := by | |
| apply ContinuousOn.sub | |
| Β· exact continuousOn_log.comp (ContinuousOn.add continuousOn_id continuousOn_const) (fun x hx => by | |
| have hβ : (x : β) + 1 > 0 := by linarith [hx.1, hx.2] | |
| linarith) | |
| Β· apply ContinuousOn.div | |
| Β· exact ContinuousOn.mul continuousOn_id (continuousOn_log.mono (by | |
| intro x hx | |
| have hβ : (x : β) > 0 := by linarith [hx.1, hx.2] | |
| linarith)) | |
| Β· exact ContinuousOn.add continuousOn_id continuousOn_const | |
| Β· intro x hx | |
| have hβ : (x : β) + 1 β 0 := by linarith [hx.1, hx.2] | |
| exact by positivity | |
| have hβ : DifferentiableOn β (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) (Set.Ioo sβ sβ) := by | |
| intro x hx | |
| have hβ : x > 1 := by linarith [hx.1, hx.2] | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (-Real.log x / (x + 1) ^ 2) x := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (-Real.log x / (x + 1) ^ 2) x := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1)) (1 / (x + 1)) x := by | |
| have hβ : HasDerivAt (fun x : β => x + 1) 1 x := by simpa using (hasDerivAt_id x).add_const 1 | |
| have hβ : (x + 1 : β) > 0 := by linarith | |
| convert HasDerivAt.log hβ (by positivity) using by field_simp <;> ring | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 x := by | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x) (Real.log x + 1) x := by | |
| have hβ : HasDerivAt (fun x : β => x) 1 x := hasDerivAt_id x | |
| have hββ : HasDerivAt (fun x : β => Real.log x) (1 / x) x := by | |
| have hββ : HasDerivAt (fun x : β => Real.log x) (1 / x) x := by | |
| convert Real.hasDerivAt_log (by linarith) using by field_simp | |
| exact hββ | |
| have hββ : HasDerivAt (fun x : β => x * Real.log x) (1 * Real.log x + x * (1 / x)) x := | |
| HasDerivAt.mul hβ hββ | |
| convert hββ using by | |
| have hββ : x β 0 := by linarith | |
| field_simp [hββ] | |
| <;> ring_nf | |
| <;> field_simp [hββ] | |
| <;> nlinarith | |
| have hβ : HasDerivAt (fun x : β => (x : β) + 1) 1 x := by | |
| simpa using (hasDerivAt_id x).add_const 1 | |
| have hββ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 x := by | |
| convert HasDerivAt.div hβ hβ (by linarith) using by | |
| field_simp [add_assoc] | |
| <;> ring_nf | |
| <;> field_simp [add_assoc] | |
| <;> nlinarith | |
| exact hββ | |
| have hββ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (1 / (x + 1) - ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2) x := by | |
| convert hβ.sub hβ using by ring | |
| have hββ : (1 / (x + 1) - ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 : β) = -Real.log x / (x + 1) ^ 2 := by | |
| have hββ : x > 0 := by linarith | |
| have hββ : x + 1 β 0 := by linarith | |
| field_simp [hββ] | |
| <;> ring_nf | |
| <;> field_simp [hββ] | |
| <;> nlinarith [Real.log_pos (by norm_num : (1 : β) < 2)] | |
| <;> | |
| (try | |
| { | |
| nlinarith [Real.log_le_sub_one_of_pos (by linarith : (0 : β) < x)] | |
| }) | |
| rw [hββ] at hββ | |
| exact hββ | |
| exact hβ | |
| have hβ : DifferentiableAt β (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) x := by | |
| exact hβ.differentiableAt | |
| exact hβ .differentiableWithinAt | |
| have hβ : β x β Set.Ioo sβ sβ, deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) x < 0 := by | |
| intro x hx | |
| have hβ : x > 1 := by linarith [hx.1, hx.2] | |
| have hβ : deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) x < 0 := by | |
| have hβ : deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) x = -Real.log x / (x + 1) ^ 2 := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (-Real.log x / (x + 1) ^ 2) x := by | |
| have hβ : HasDerivAt (fun x : β => Real.log (x + 1)) (1 / (x + 1)) x := by | |
| have hβ : HasDerivAt (fun x : β => x + 1) 1 x := by simpa using (hasDerivAt_id x).add_const 1 | |
| have hββ : (x + 1 : β) > 0 := by linarith | |
| convert HasDerivAt.log hβ (by positivity) using by field_simp <;> ring | |
| have hβ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 x := by | |
| have hββ : HasDerivAt (fun x : β => x * Real.log x) (Real.log x + 1) x := by | |
| have hββ : HasDerivAt (fun x : β => x) 1 x := hasDerivAt_id x | |
| have hββ : HasDerivAt (fun x : β => Real.log x) (1 / x) x := by | |
| have hββ : HasDerivAt (fun x : β => Real.log x) (1 / x) x := by | |
| convert Real.hasDerivAt_log (by linarith) using by field_simp | |
| exact hββ | |
| have hββ : HasDerivAt (fun x : β => x * Real.log x) (1 * Real.log x + x * (1 / x)) x := | |
| HasDerivAt.mul hββ hββ | |
| convert hββ using by | |
| have hββ : x β 0 := by linarith | |
| field_simp [hββ] | |
| <;> ring_nf | |
| <;> field_simp [hββ] | |
| <;> nlinarith | |
| have hββ : HasDerivAt (fun x : β => (x : β) + 1) 1 x := by | |
| simpa using (hasDerivAt_id x).add_const 1 | |
| have hββ : HasDerivAt (fun x : β => x * Real.log x / (x + 1)) | |
| ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 x := by | |
| convert HasDerivAt.div hββ hββ (by linarith) using by | |
| field_simp [add_assoc] | |
| <;> ring_nf | |
| <;> field_simp [add_assoc] | |
| <;> nlinarith | |
| exact hββ | |
| have hββ : HasDerivAt (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| (1 / (x + 1) - ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2) x := by | |
| convert hβ.sub hβ using by ring | |
| have hββ : (1 / (x + 1) - ((Real.log x + 1) * (x + 1) - x * Real.log x) / (x + 1) ^ 2 : β) = -Real.log x / (x + 1) ^ 2 := by | |
| have hββ : x > 0 := by linarith | |
| have hββ : x + 1 β 0 := by linarith | |
| field_simp [hββ] | |
| <;> ring_nf | |
| <;> field_simp [hββ] | |
| <;> nlinarith [Real.log_pos (by norm_num : (1 : β) < 2)] | |
| <;> | |
| (try | |
| { | |
| nlinarith [Real.log_le_sub_one_of_pos (by linarith : (0 : β) < x)] | |
| }) | |
| rw [hββ] at hββ | |
| exact hββ | |
| have hββ : deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) x = -Real.log x / (x + 1) ^ 2 := by | |
| apply HasDerivAt.deriv | |
| exact hβ | |
| exact hββ | |
| rw [hβ] | |
| have hβ : Real.log x > 0 := Real.log_pos (by linarith) | |
| have hβ : (x + 1 : β) ^ 2 > 0 := by positivity | |
| have hβ : -Real.log x / (x + 1) ^ 2 < 0 := by | |
| apply div_neg_of_neg_of_pos | |
| Β· linarith | |
| Β· positivity | |
| exact hβ | |
| exact hβ | |
| have hβ : binary_entropy sβ < binary_entropy sβ := by | |
| have hβ : binary_entropy sβ = Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) := rfl | |
| have hβ : binary_entropy sβ = Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) := rfl | |
| rw [hβ , hβ] | |
| have hβ : ContinuousOn (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) (Set.Icc sβ sβ) := hβ | |
| have hβ : DifferentiableOn β (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) (Set.Ioo sβ sβ) := hβ | |
| have hβ : β c β Set.Ioo sβ sβ, deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) c = (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1))) / (sβ - sβ) := by | |
| have hββ : β c β Set.Ioo sβ sβ, deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) c = (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1))) / (sβ - sβ) := by | |
| apply exists_deriv_eq_slope (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) | |
| <;> simp_all [hsβ, hsβ] | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try assumption) <;> | |
| (try | |
| { | |
| exact β¨by linarith, by linarithβ© | |
| }) | |
| exact hββ | |
| obtain β¨c, hc, hc'β© := hβ | |
| have hββ : deriv (fun x : β => Real.log (x + 1) - x * Real.log x / (x + 1)) c < 0 := hβ c hc | |
| have hββ : (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1))) / (sβ - sβ) < 0 := by | |
| linarith | |
| have hββ : sβ - sβ > 0 := by linarith | |
| have hββ : Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1)) < 0 := by | |
| by_contra h | |
| have hββ : Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1)) β₯ 0 := by linarith | |
| have hββ : (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1) - (Real.log (sβ + 1) - sβ * Real.log sβ / (sβ + 1))) / (sβ - sβ) β₯ 0 := by | |
| apply div_nonneg | |
| Β· linarith | |
| Β· linarith | |
| linarith | |
| linarith | |
| exact hβ | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- LEMMA 4: H(19.0) < 0.20 | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- At s = 19, binary entropy β 0.1985 < 0.20 -/ | |
| lemma binary_entropy_at_19 : binary_entropy 19.0 < 0.20 := by | |
| have hβ : binary_entropy 19.0 = Real.log (19.0 + 1) - 19.0 * Real.log 19.0 / (19.0 + 1) := by | |
| norm_num [binary_entropy] | |
| <;> ring_nf | |
| <;> norm_num | |
| rw [hβ] | |
| have hβ : Real.log (19.0 + 1 : β) - 19.0 * Real.log 19.0 / (19.0 + 1 : β) < 0.20 := by | |
| have := Real.log_two_gt_d9 | |
| have := Real.log_two_lt_d9 | |
| have hβ : Real.log (20 : β) < 2.995733 := by | |
| have := Real.log_two_lt_d9 | |
| have hβ : Real.log (20 : β) = Real.log 2 + Real.log 10 := by | |
| have hβ : Real.log (20 : β) = Real.log (2 * 10 : β) := by norm_num | |
| rw [hβ ] | |
| have hβ : Real.log (2 * 10 : β) = Real.log 2 + Real.log 10 := by | |
| rw [Real.log_mul (by norm_num) (by norm_num)] | |
| rw [hβ] | |
| rw [hβ] | |
| have hβ : Real.log 10 = Real.log 2 + Real.log 5 := by | |
| have hβ : Real.log 10 = Real.log (2 * 5 : β) := by norm_num | |
| rw [hβ] | |
| have hβ : Real.log (2 * 5 : β) = Real.log 2 + Real.log 5 := by | |
| rw [Real.log_mul (by norm_num) (by norm_num)] | |
| rw [hβ] | |
| rw [hβ ] | |
| have hβ : Real.log 5 < 1.609438 := by | |
| have := Real.log_two_lt_d9 | |
| have hβ : Real.log 5 = Real.log (10 / 2 : β) := by norm_num | |
| rw [hβ] | |
| have hβ : Real.log (10 / 2 : β) = Real.log 10 - Real.log 2 := by | |
| rw [Real.log_div (by norm_num) (by norm_num)] | |
| rw [hβ] | |
| have hβ : Real.log 10 = Real.log 2 + Real.log 5 := by | |
| have hββ : Real.log 10 = Real.log (2 * 5 : β) := by norm_num | |
| rw [hββ] | |
| have hββ : Real.log (2 * 5 : β) = Real.log 2 + Real.log 5 := by | |
| rw [Real.log_mul (by norm_num) (by norm_num)] | |
| rw [hββ] | |
| have hββ : Real.log 5 < 1.609438 := by | |
| have := Real.log_two_lt_d9 | |
| have := Real.log_two_gt_d9 | |
| have hββ : Real.log 5 < 1.609438 := by | |
| have hββ : Real.exp 1.609438 > 5 := by | |
| have := Real.exp_one_gt_d9 | |
| have := Real.exp_one_lt_d9 | |
| norm_num [Real.exp_add, Real.exp_log, Real.exp_neg] at * | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith [Real.add_one_le_exp (1 : β)]) | |
| have hββ : Real.log 5 < 1.609438 := by | |
| by_contra hββ | |
| have hββ : Real.log 5 β₯ 1.609438 := by linarith | |
| have hββ : Real.exp (Real.log 5) β₯ Real.exp 1.609438 := Real.exp_le_exp.mpr hββ | |
| have hββ : Real.exp (Real.log 5) = 5 := by | |
| rw [Real.exp_log (by positivity)] | |
| rw [hββ] at hββ | |
| norm_num at hββ hββ β’ | |
| <;> linarith | |
| exact hββ | |
| exact hββ | |
| linarith | |
| have hβ : Real.log 2 > 0.693147 := by | |
| have := Real.log_two_gt_d9 | |
| norm_num at this β’ | |
| <;> linarith | |
| norm_num at hβ hβ β’ | |
| <;> nlinarith | |
| have hβ : Real.log (19 : β) > 2.944438 := by | |
| have hβ : Real.exp 2.944438 < 19 := by | |
| have := Real.exp_one_gt_d9 | |
| have := Real.exp_one_lt_d9 | |
| norm_num [Real.exp_add, Real.exp_log, Real.exp_neg] at * | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith [Real.add_one_le_exp (1 : β)]) | |
| have hβ : Real.log 19 > 2.944438 := by | |
| by_contra hβ | |
| have hβ : Real.log 19 β€ 2.944438 := by linarith | |
| have hβ : Real.exp (Real.log 19) β€ Real.exp 2.944438 := Real.exp_le_exp.mpr hβ | |
| have hββ : Real.exp (Real.log 19) = 19 := by | |
| rw [Real.exp_log (by positivity)] | |
| rw [hββ] at hβ | |
| norm_num at hβ hβ β’ | |
| <;> linarith | |
| linarith | |
| have hβ : Real.log (19 : β) < 2.944439 := by | |
| have hβ : Real.exp 2.944439 > 19 := by | |
| have := Real.exp_one_gt_d9 | |
| have := Real.exp_one_lt_d9 | |
| norm_num [Real.exp_add, Real.exp_log, Real.exp_neg] at * | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith [Real.add_one_le_exp (1 : β)]) | |
| have hβ : Real.log 19 < 2.944439 := by | |
| by_contra hβ | |
| have hβ : Real.log 19 β₯ 2.944439 := by linarith | |
| have hββ : Real.exp (Real.log 19) β₯ Real.exp 2.944439 := Real.exp_le_exp.mpr hβ | |
| have hββ : Real.exp (Real.log 19) = 19 := by | |
| rw [Real.exp_log (by positivity)] | |
| rw [hββ] at hββ | |
| norm_num at hβ hββ β’ | |
| <;> linarith | |
| linarith | |
| norm_num at hβ hβ hβ β’ | |
| <;> | |
| (try norm_num) <;> | |
| (try linarith) <;> | |
| (try nlinarith) | |
| exact hβ | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- MAIN THEOREM: Entropy bound during active execution | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- **SOVEREIGN ENTROPY THEOREM** | |
| During all active execution phases of the ICP engine (F β₯ 1), | |
| expert selection entropy H < 0.20 nats. -/ | |
| theorem sovereign_entropy_bound | |
| (F : FrustrationCount) | |
| (hF : F β₯ 1) | |
| (d : β) (hd : d β₯ 1) | |
| : let T := temperature F | |
| let s := softmax_ratio d T | |
| binary_entropy s < 0.20 := by | |
| intro T s | |
| have hT_pos : 0 < T := by | |
| unfold T temperature | |
| have hβ : (0.1 : β) + 0.9 * Real.exp (-2.0 * (F : β)) > 0 := by positivity | |
| have hβ : max (0.1 : β) (0.1 + 0.9 * Real.exp (-2.0 * (F : β))) > 0 := by | |
| apply lt_max_iff.mpr | |
| exact Or.inl (by norm_num) | |
| positivity | |
| have hT_bound : T β€ 0.2218 := temperature_bound_when_active F hF | |
| have hs_large : s β₯ 90.75 := softmax_ratio_lower_bound T d hT_pos hT_bound hd | |
| have hs_gt_19 : s > 19.0 := by linarith | |
| have h_main : binary_entropy s < binary_entropy 19.0 := by | |
| apply binary_entropy_decreasing (by norm_num) hs_gt_19 | |
| have h_final : binary_entropy 19.0 < 0.20 := binary_entropy_at_19 | |
| calc binary_entropy s | |
| < binary_entropy 19.0 := h_main | |
| _ < 0.20 := h_final | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| -- COROLLARY: The entropy bound is a consequence of #minimize, not a check | |
| -- βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| /-- The entropy bound is not an external constraint β it is a mathematical | |
| consequence of the minimization directive operating on a bipartite graph. -/ | |
| theorem entropy_bound_is_structural | |
| (F : FrustrationCount) (hF : F β₯ 1) (d : β) (hd : d β₯ 1) : | |
| β (H : β), H = binary_entropy (softmax_ratio d (temperature F)) β§ H < 0.20 := | |
| β¨binary_entropy (softmax_ratio d (temperature F)), | |
| rfl, | |
| sovereign_entropy_bound F hF d hdβ© | |
| end SovereignEntropy | |