Stanley Ngugi

Independent AI Researcher in RL Environments and Formal Methods

Research Focus

I’m a 20-year-old self-taught independent researcher working on AI. I’m interested in reinforcement learning post-training methods for language models, especially those which make use of formal reasoning and executable verification to improve abilities at math and code. I left college to focus on independent research.

Recently I developed and released a C verification environment that uses Frama-C to check C programs against their formal specifications, and a bounded integer math environment which checks answers in Lean, where the model supplies an integer answer rather than a proof. I also worked on grammar-constrained generation of proof tactics in Lean. I typically release code, task suites, and experimental evidence for the tasks I work on.

Research Experience

Independent AI Researcher 2024 – present
  • Build RL environments for mathematical reasoning and code generation where rewards come from executable checks and formal verification.
  • Build isolated, fail-closed judges and test them against malformed outputs, timeouts, crashes, inconsistent verifier reports, and attempts to exploit the reward.

Selected Projects & Technical Writing

Formally Verified C RL environment · formal verification
  • Built an RL environment where models write C functions and reward comes from Frama-C proving that the implementation satisfies a fixed specification, including runtime safety.
  • Released 64 tasks, an isolated Frama-C judge, adversarial tests, and reproducible proof records. The published source passed 57/57 tests.
  • Article: An RL Environment Where C Code Has to Be Proved, Not Just Tested.
MathCheck RL math RL environment
  • Built a math RL environment for bounded integer problems that does not store expected answers. Models submit integers or complete finite certificates, and reward comes from checking each submission against the full encoded problem rather than requiring a model-written proof.
  • Article: Grading Mathematical Answers Without Answer Keys.

Selected Projects & Technical Writing, continued

MathCheck Engine Lean verification engine
  • Built the reusable verification engine behind MathCheck RL. It generates executable Lean checks for bounded integer problems, evaluates the entire finite domain, and returns definitive results for the encoded problem without asking models to produce proofs.
  • Article: Building a Lean-Backed Verifier for Bounded Mathematical Answers.
  • Studied how training choices shape feature entanglement in overcomplete toy networks, using sparse autoencoders to compare learned representations across configurations and random seeds (code).

Preprints

  • Solo author. arXiv:2508.07075. An early Phi-3-mini experiment that locates one factual association, suppresses it, and trains a counterfactual replacement; the full localization, training, and evaluation pipeline is public (code).
  • Solo author. arXiv:2506.15415. An early experiment using small adapters to strengthen Swahili–English word alignment already present inside Lugha-Llama, evaluated on 623 training pairs and 63 unseen controls (code).

Research Capabilities

RL environments
Environment and task design, reward construction, rollout design, GRPO experiment setup, training analysis, and ablations
Formal verification
Lean 4, Frama-C and ACSL, bounded computational verification, executable specifications, verifier-backed rewards, and fail-closed judge design
Post-training
Reinforcement-learning algorithms, GRPO experiment design, rollout analysis, parameter-efficient training, PyTorch, and Transformers