Pages

sâmbătă, 21 noiembrie 2026

Lean 4 : Gordon Growth model example.

Lean 4 is an open-source programming language and interactive proof assistant where mathematics and code become the exact same thing. Unlike traditional languages like Python or C++ that simply run instructions, Lean is built on dependent type theory. This allows you to write mathematical statements as types and construct their proofs as programs. A tiny, strict verification engine checks every single logical step—if you skip a step, miss an edge case, or make a false assumption, the code simply refuses to compile. This makes Lean 4 especially valuable in modern AI research. While an AI can easily generate a plausible-sounding proof in plain English that hides a subtle flaw, Lean acts as an incorruptible referee, forcing the model to prove every deduction down to the foundational axioms. Beyond formal verification, Lean 4 also compiles to fast C code, making it a capable functional programming language for building real-world software, tools, and simulations.
In short: if your code compiles in Lean 4, your logic is 100% bulletproof. See the online tool.
-- Gordon Growth Model (Constant-Growth Dividend Discount Model) in Lean 4
-- Formula: P0 = D1 / (r - g), where D1 = D0 * (1 + g) and r > g

structure GordonParams where
  d0 : Float -- Last annual dividend per share
  g  : Float -- Constant annual dividend growth rate (e.g., 0.04 for 4%)
  r  : Float -- Required annual return / discount rate (e.g., 0.09 for 9%)
deriving Repr

-- Next year's expected dividend: D1 = D0 * (1 + g)
def expectedDividend (p : GordonParams) : Float :=
  p.d0 * (1.0 + p.g)

-- Intrinsic value P0 = D1 / (r - g) when r > g
def gordonFairValue (p : GordonParams) : Option Float :=
  let spread := p.r - p.g
  if spread > 0.0 then
    some (expectedDividend p / spread)
  else
    none

-- Implied required return r = (D1 / P0) + g for a given market price p0 > 0
def impliedReturn (d1 p0 g : Float) : Option Float :=
  if p0 > 0.0 then
    some ((d1 / p0) + g)
  else
    none

-- Formal algebraic proof:
-- (a + b) - (a + c) = b - c (useful for comparing spread changes: r2 - r1)
theorem spread_difference (a b c : Int) : (a + b) - (a + c) = b - c := by
  omega

def runGordonDemo : IO Unit := do
  -- Example: D0 = $2.00, growth g = 5% (0.05), required return r = 9% (0.09)
  -- D1 = 2.00 * 1.05 = 2.10; spread = 0.09 - 0.05 = 0.04 => Fair Value = 2.10 / 0.04 = $52.50
  let p : GordonParams := { d0 := 2.0, g := 0.05, r := 0.09 }
  let d1 := expectedDividend p
  IO.println s!"Expected Dividend D1: {d1}"
  match gordonFairValue p with
  | some fairVal =>
    IO.println s!"Gordon Fair Value P0: {fairVal}"
    match impliedReturn d1 fairVal p.g with
    | some impR => IO.println s!"Implied Return r check: {impR}"
    | none      => IO.println "Invalid price for implied return"
  | none =>
    IO.println "Invalid parameters: require r > g"

#eval runGordonDemo

News : Patch 0.7.6.0 Digital Chemistry "Brief" Explainer

News : November 2026 Update Trailer: Official Sea of Thieves

News : I let Fable 5.2 build 2 games in my game engine

News : Railguns, Heavy Cannons & Brutally Realistic Damage | In The Black

News : Anno 117: Pax Romana - Dawn of the Delta & Update 3.0 Overview

News : 5 Unreal MCP Tips: Cut Tool Calls from 46 Seconds to 1

News : How to ship an in-browser image generator in under 50 MB .

News : Demonstrating quantum contextuality at scale on the Willow processor | Google Quantum AI

News : Chasing Kaleidorider | A Romance You Can Reach Out and Touch

Tool : Spck Editor / Git Client ... android editor

• Remote Terminal: touch scrolling in full-screen apps, an Enter button for confirmations, and typing fixes.
• Remote CLI: PIN-protected connections, color-coded ping, better reconnection and status warnings.
• Premium Fast Lane: direct WebRTC connections, 2× faster than relay on average.
• Git: fix incorrect status for local projects.
• UI: fix the Translucent Background setting
Official documentation for Spck Editor — a mobile-first code editor with project management, Git integration, syntax highlighting, and a remote CLI for local development. Drive local AI coding agents (Claude Code, Codex, Gemini CLI) from your phone over the Agent Client Protocol (ACP). ...

joi, 19 noiembrie 2026

Tool : SolidCraft - the online open-source parametric 3D CAD application.

SolidCraft is an open-source parametric 3D CAD application written in pure Rust. Sketch on a plane, constrain and dimension the sketch, turn profiles into solids with features on a timeline, and change a parameter to watch the whole timeline rebuild.

News : Meet the New Docker: Built to Run on Trust