Skip to content

Instantly share code, notes, and snippets.

@jcreedcmu
jcreedcmu / foo.md
Last active January 27, 2026 15:07
foo.md

This cost $5.43 This cost $3

This cost $5.43 This cost $

@jcreedcmu
jcreedcmu / graph_theoretic_geometry.lean
Created January 19, 2026 22:56
Graph-Theoretic Geometry
import Mathlib
class Grph (G : Type) where
edge : G → G → Prop
open Grph
variable {G H : Type} [Grph G] [Grph H]
structure Hom (G H : Type) [Grph G] [Grph H] where
obj : G → H
@jcreedcmu
jcreedcmu / Collatz.lean
Last active September 27, 2025 18:20
Collatz.lean
import Mathlib
/--
Do one collatz iteration
-/
def collatz (n : Nat) :=
if n % 2 == 0 then n / 2 else 3 * n + 1
/-
Algorithmic collatz termination
@jcreedcmu
jcreedcmu / Braids1.agda
Last active August 23, 2025 16:13
Braids1.agda
{-# OPTIONS --cubical #-}
open import Cubical.Foundations.Prelude
open import Cubical.HITs.S1
module Braids1 where
{-
Conjecture:
@jcreedcmu
jcreedcmu / parametricity.txt
Last active August 10, 2025 22:41
parametricity.txt
Let's say a function
j : ∏(X : 𝒰). (S¹ → X) → (X → X)
is (binary relationally) parametric just in case we have
∏(X₁ : 𝒰). ∏(X₂ : 𝒰). ∏(R : X₁ → X₂ → U).
∏(η₁ : S¹ → X₁). ∏(η₂ : S¹ → X₂). (∏(s : S¹). R (η₁ s) (η₂ s)) →
∏(x₁ : X₁). ∏(x₂ : X₂). R x₁ x₂ →
R (j X₁ η₁ x₁) (j X₂ η₂ x₂)
Then we can pick an arbitrary function x : X₁ → X₂ and let R be f's graph
R x₁ x₂ ⇔ f x₁ ≡ x₂
and we obtain
@jcreedcmu
jcreedcmu / query.qepcad
Created May 31, 2025 14:40
query.qepcad
cat <<"EOF" >input.txt
[ Rupert ]
(a1,b1,c1,a2,b2,c2)
0
(E a1)(E b1)(E c1) (E a2)(E b2)(E c2) [
8 a1^3 a2 b2 c1 + 8 a1 a2 b1^2 b2 c1 + 8 a1^3 b2^2 c1 + 8 a1 b1^2 b2^2 c1 + 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i + y * j + z * k) * qs
return Matrix([[m[i+1].coefficient(v) for v in [x,y,z]] for i in range(3)])
@jcreedcmu
jcreedcmu / good_enough.lean
Created April 19, 2025 18:38
good_enough.lean
import Mathlib
theorem good_enough (f : ℝ → ℝ) (c : Continuous f)
(onRats : (y : ℚ) → f y ≥ 0) : (x : ℝ) → f x ≥ 0 :=
by
by_contra px; push_neg at px;
let ⟨x, hx⟩ := px
let openset := {y : ℝ | y < 0}
have hin : f x ∈ openset := hx
have hio : IsOpen (f ⁻¹' openset) := c.isOpen_preimage openset (isOpen_gt' 0)