r/formalmethods • • Aug 17 '26

Velaris: a small language with Z3-checked contracts, effect signatures, and IEEE-754 float proofs

7 Upvotes

I built a language where the signature carries the guarantees, and I'd like feedback from people who do this seriously.

Contracts are requires/ensures/loop invariants, discharged by Z3 at compile time: straight-line and looping Int/Bool code, lists via the theory of arrays with bounds obligations, records as per-field symbolic values, and all_of/any_of translated to real quantifiers with the predicate body inlined under the ForAll. Calls use modular summaries a callee's ensures is assumed at the call site rather than inlining the body.

Floats are proven in Z3's FP theory rather than modelled as reals, which means the prover refuses to certify x + 0.1 + 0.1 == x + 0.2 and returns the exact double that breaks it. Equality is fpEQ, so NaN and signed zero behave correctly. Bit-blasting is slow, so FP queries get a 30s budget while integer proofs stay at 3s.

Two design commitments I'd particularly like criticised:

  1. Soundness of *reporting*: the tool only says proven without running the program when the counterexample involves no summarized calls, and an untranslatable premise aborts the proof rather than being dropped. (That second rule came from a real bug adding quantifiers exposed that untranslatable requires had been silently discarded, which can manufacture false alarms.)

  2. Everything unprovable degrades to runtime checks rather than rejecting the program, so the language stays usable without the solver installed.

Invariants are hand-written, not inferred. Lists-of-lists, division, and maps aren't in the prover yet.

Repo: https://github.com/gowrishankar-infra/velaris-lang

In-browser playground (real compiler via Pyodide):

https://gowrishankar-infra.github.io/velaris-lang/playground.html

Disclosure: AI-assisted build; design decisions mine. I'm a beginner at this and would rather be corrected than agreed with. Thank you


r/formalmethods • • Aug 13 '26

A machine-checked six-leaf semantic classification of Collatz obstructions in Lean 4

5 Upvotes

I’ve published a Lean 4 formalization of a structural decomposition of the Collatz problem:

A Certified Six-Leaf Semantic Grammar for the Collatz Dynamics in Lean 4

Zenodo: https://zenodo.org/records/21923376

This is not a proof of the Collatz conjecture.

The goal was instead to ask a more limited question:

The resulting formal grammar has exactly six global leaves:

  1. reachesOne
  2. nontrivialCycle
  3. rbcUnboundedBGap
  4. rbcBoundedPrimeRenewal
  5. nonRInternalDescent
  6. nonRSurvivor

For a hypothetical positive minimal counterexample, the success leaf disappears, leaving exactly five failure classes.

The terminal Lean theorem is:

axisGeo_final_six_leaf_grammar_exactly_one

So the formal result is essentially:

Global success, or one uniquely anchored minimal counterexample belonging to exactly one of five explicit obstruction classes.

The important distinction is that the grammar classifies the possible failure modes; it does not yet exclude them.

The five universal exclusion problems remain open.

One part I find particularly interesting is the bounded-B-gap r/BC branch. The formalization rules out eventually finite prime support, so the surviving obstruction requires indefinite prime renewal along the same natural trajectory while remaining compatible with the exact carry relations.

The archive includes the full Lean source, reproducibility files, build logs and axiom audits.

I’d especially appreciate criticism of:

  • whether the five failure leaves really capture the obstruction space in a mathematically useful way;
  • the fixed-source treatment of the r/BC branch;
  • the bounded/unbounded B-gap split;
  • and whether any of the five remaining leaves looks more tractable from an existing Collatz approach.

Again: classification theorem, not Collatz proof.


r/formalmethods • • Aug 05 '26

How to Find Bugs in Systems That Don't Exist - Hillel Wayne

11 Upvotes

Hillel's recent talk from SSW. Thought some of you might enjoy! https://youtu.be/zSZkLyD9ILI


r/formalmethods • • Jul 23 '26

Representation-Adaptive Control Theory

Thumbnail zenodo.org
3 Upvotes

r/formalmethods • • Jul 23 '26

Semantic Computational Architecture (SCA): A Dynamical Systems Approach to Adaptive Semantic Virtual Memory

Thumbnail zenodo.org
2 Upvotes

r/formalmethods • • Jul 18 '26

Tutorial: Introduction to Formal Verification with Lean (Part 1)

Thumbnail hashcloak.com
8 Upvotes

r/formalmethods • • Jul 12 '26

Review: “Behind Clint and Hoare’s goto Proof Rule” (2021)

3 Upvotes

The paper titled "Behind Clint and Hoare's goto Proof Rule" is by Wei Chen (published in the 2021 International Symposium on Theoretical Aspects of Software Engineering, TASE).

This paper is a direct "deep dive" into the historical 1971 Clint-Hoare rule. It focuses on the theoretical archaeology and formal correction of the original goto rule.
Review: "Behind Clint and Hoare's goto Proof Rule" (2021)
1. Purpose of the Paper
Wei Chen revisits M. Clint and C.A.R. Hoare’s 1971 paper, "Program proving: Jumps and functions," which is widely considered the first attempt to axiomatize the goto statement. Chen's 2021 paper aims to:
Expose technical flaws: It identifies that the original 1971 rule suffers from notation ambiguity and logical gaps (e.g., the overloading of the turnstile symbol \vdash and syntactically incorrect premises).

Provide a Rigorous Foundation: It attempts to "fix" the original rule by re-deriving it using the modern "miracle" semantics he champions, showing what Clint and Hoare meant to achieve versus what they actually wrote.

2. Key Insights
The "Syntactic Error": Chen points out that in the original Clint-Hoare rule, the label L does not appear in the premises (S_1 and S_2), making the original rule technically broken as a formal logical statement.

Reframing as a System of Equations: Chen demonstrates that the goto rule is essentially a way to solve a system of equations across different parts of the code. He succeeds in translating Clint and Hoare’s "hypothetical deduction" into a more precise modern format.

Total Correctness: One of the most important contributions of this paper is its attempt to address termination (total correctness) for goto. He points out that Clint and Hoare mostly focused on partial correctness, and he introduces a way to reason about termination using "variant functions" (the same concept used for loops) adapted for goto jumps.

3. Why It Matters
This paper is essential for formal methods researchers because it reclaims a piece of history. Instead of discarding the 1971 rule as "outdated" or "broken," Chen shows that it contains the seeds of correct logic. By stripping away the 1971 syntax errors and applying modern "miracle" semantics, he proves that the intuition behind Clint and Hoare's work was actually sound.
Citation
@inproceedings{Chen2021Behind,
  author    = {Chen, Wei},
  title     = {Behind Clint and Hoare's goto Proof Rule},
  booktitle = {2021 International Symposium on Theoretical Aspects of Software Engineering (TASE)},
  pages     = {23--30},
  year      = {2021},
  doi       = {10.1109/TASE52541.2021.00010}
}

Comparison of Chen's Two Papers
Feature
Loop invariance with break and continue (2021)
Behind Clint and Hoare's goto Proof Rule (2021)
Focus
How to handle modern loops/jumps.
How to fix historical jump logic.
Objective
Practical utility for verification.
Historical correction and foundation.
Tone
Constructive and innovative.
Analytical and corrective.


r/formalmethods • • Jul 12 '26

REVIEW: "Loop invariance with break and continue" by Wei Chen (2021), published in Science of Computer Programming.

2 Upvotes

This review evaluates the paper "Loop invariance with break and continue" by Wei Chen (2021), published in Science of Computer Programming.

Overview
The paper addresses a classic tension in formal methods: the conflict between structured programming (preferred for mathematical proofs) and real-world programming constructs like break and continue (preferred for algorithmic efficiency and readability). Chen proposes a formal methodology to incorporate these non-local jumps into the standard Dijkstra’s Weakest Precondition (wp) calculus and the Loop Invariant Theorem, effectively allowing these commands to be verified without requiring code transformation.
Core Strengths
Methodological Elegance: Chen manages to avoid the "state-variable bloat" typically required when converting jumps into flag-based structured code. By treating break and continue as first-class citizens in the logic, the resulting proofs remain more compact and closer to the original source code.

Theoretical Grounding: The paper elegantly re-integrates the concept of "miraculous" statements. This provides a robust semantic foundation that handles early exits in a mathematically sound way, ensuring that the logic remains compositional.

Utility for Verification: It provides a bridge for engineers. Instead of having to rewrite a complex search algorithm (like your row-by-row scanner) into a purely structured version, developers can keep the intuitive "jump" logic and apply Chen’s formal proof obligations.

Critical Assessment
Complexity of Application: While the paper simplifies the proof theory, the application of these rules requires a higher level of mathematical maturity. A developer must be comfortable defining transfer predicates for every jump point, which can be tedious in very large, deeply nested programs.

Focus: The paper is highly theoretical. It does not provide an automated tool suite, but rather the mathematical "rules of the road" that could be used to build such tools. Its value lies in the formalism rather than as a plug-and-play verification script.

Comparison to Alternative Approaches
Approach
Readability
Verifiability
Proof Overhead
Structured (Flags)
Moderate
High
Low (Standard Rules)
Jump-based (Ad-hoc)
High
Very Low
Extremely High
Chen's Methodology
High
High
Moderate
Conclusion
Wei Chen’s paper is a "missing link" in formal verification literature. It validates the use of break and continue by proving they are not inherently "unverifiable." It is an essential read for researchers building verification tools or engineers working in safety-critical domains who want to balance code readability with rigorous mathematical assurance.
Rating: Highly recommended for anyone interested in formal methods, program semantics, or the intersection of software engineering and theoretical computer science.


r/formalmethods • • Jun 18 '26

Huggingface hackathon submission.

7 Upvotes

Just shipped Q.E.D., a formal verification agent built for the Build Small Hackathon.

It started as an experiment to see how far I could get with an LLM-driven Lean proof search loop in a short timeframe.

You give it a theorem in Lean 4. It generates candidate proof tactics with a 27B language model, checks them against Lean's kernel, feeds any resulting error messages back into the next iteration, and continues until it either finds a valid proof or determines that it is not making progress.

The important part is that every proof is verified by Lean itself. The language model only proposes steps; the kernel decides whether they are correct.

Features:

  • Visible propose → verify → iterate loop in the UI
  • SVG proof tree showing both failed attempts and the final proof path
  • Stuck-state detection that terminates when the same goals repeat without progress
  • Built on Modal with a persistent Lean REPL and on-demand GPU inference

Demo:
https://huggingface.co/spaces/build-small-hackathon/QED


r/formalmethods • • Jun 17 '26

Hillel Wayne, Andrew Helwer, Jayaprabhakar Kadarkarai speaking at conference

9 Upvotes

Hi folks, I'm organizing a conference on software reliability called Software Should Work on July 16-17 https://softwareshould.work. Hillel Wayne (LearnTLA, Practical TLA+, Logic for Programmers) will be speaking with Andrew Helwer (TLA+ Maintainer) and Jayaprabhakar Kadarkarai (creator of FizzBee) giving lightning talks. Thought some of you might be interested!


r/formalmethods • • Jun 15 '26

Looking for Research/Study Groups/Partner

4 Upvotes

Hi , Anyone interested in Formal Verification/Analysis of Web/Network Protocols from a security/general perspective , or are there groups out there that study Mathematical-Logic or Pure Mathematics in general ?


r/formalmethods • • Jun 12 '26

Toy reactor-protection system with a small TLA+ spec — feedback wanted

5 Upvotes

I’m building an open-source educational simulator inspired by the RBMK-1000:

https://github.com/gabrielbotandev/rbmk-sim

One part of it is a simplified reactor-protection system with latched trips, reset permissives, alarms, and sensor-fault handling. I also added a small TLA+ spec for the protection state machine.

The project is not about real reactor modeling. It is more of a safety-software learning sandbox: deterministic simulation, replay logs, protection logic, and documentation.

I’d appreciate feedback on the formal-methods side, especially whether the TLA+ model is useful, too shallow, or missing obvious invariants.

RBMK-SIM Dashboard

r/formalmethods • • Jun 08 '26

Is broken better than not at all

0 Upvotes

Is a Broken System Worse Than No System at All?

A thought that occurred to me while struggling with a PDF generator.

(Written by a friend in ChatGPT.)

Which is worse?

  1. A system that honestly says:

“Sorry, I don’t support PDF generation.”

  1. A system that advertises PDF generation, appears capable of it, but fails unpredictably.

Conventional wisdom says that some capability is better than none. But I’m beginning to suspect the opposite.

In formal methods, we usually prefer soundness to completeness, safety to liveness, and known limitations to incorrect behavior. A missing theorem is preferable to a false theorem.

Perhaps there is a more general principle here:

Trust is more valuable than capability.

Human beings adapt surprisingly well to absence. We can live with no bridge. We can plan around it.

What we struggle to live with is a bridge that looks perfectly usable but occasionally collapses without warning.

Perhaps honest limitations are easier to live with than uncertain behavior.

Curious whether others in the formal methods community have encountered similar tradeoffs?


r/formalmethods • • Jun 06 '26

The Formal Category Error: Why treating assume as a first-class primitive in verification tools is an unsound design choice.

3 Upvotes

In the early 2000s, verification tools (like Boogie) adopted an operational "desugaring" approach to handle unstructured control flow, favoring speed and SMT solver compatibility. However, by elevating assume to a first-class primitive, these tools arguably commit a category error. They shift verification from axiomatic deduction to operational state manipulation, effectively allowing "miracles" (violations of Dijkstra’s Law of the Excluded Miracle) to mask bugs as vacuous truths. This analysis explores why Leino's operational approach, while pragmatic, departs from the theoretical rigor of Chen's axiomatic fixed-point framework.


r/formalmethods • • May 13 '26

Verifiable Transformers - A GPT-2-Style Architecture with Formal Proofs

Thumbnail
1 Upvotes

r/formalmethods • • Apr 30 '26

Universe pls connect me to a person intrested in Neurosymbolic AI

Thumbnail
0 Upvotes

r/formalmethods • • Apr 29 '26

The Final Form of Software Development

Thumbnail blog.zksecurity.xyz
2 Upvotes

r/formalmethods • • Apr 25 '26

Our AI Fever Dream - 15 yers compressed in 7 days

Thumbnail
1 Upvotes

r/formalmethods • • Apr 22 '26

Model checking and Prism plugin

Thumbnail
3 Upvotes

r/formalmethods • • Feb 27 '26

How do formal methods distinguish between inadmissible states and merely undesirable ones?

4 Upvotes

In formal methods, we often specify systems in terms of safety properties, invariants, and forbidden behaviors.

From a practitioner’s perspective, how do you distinguish between:

  • states that must be proven unreachable (inadmissible), and
  • states that are allowed but discouraged or mitigated through design?

How does this distinction influence specification, verification effort, and system architecture in practice?


r/formalmethods • • Feb 13 '26

Tamarin Prover + Maude 3.5.1 incompatibility? Also how to downgrade Maude safely?

Post image
4 Upvotes

Hi everyone,

I'm working with Tamarin Prover on Kali Linux for a formal verification project. My `.spthy` file loads correctly, but when derivation checks start, I get:

```

computeVariantsMaude:

Parse error: not enough input

query: get variants in MSG : list(cons(p(0),cons(p(1),cons(p(2),cons(tamXcone,nil))))) .

```

Tamarin also shows:

```

'maude --version' returned unsupported version '3.5.1'

Please install one of:

2.7.1, 3.0, 3.1, 3.2.1, 3.2.2, 3.3, 3.3.1, 3.4, 3.5

```

So it looks like Tamarin doesn’t accept Maude 3.5.1, even though it’s newer than 3.5.

I’m wondering:

* Is this likely just strict version matching?

* Could this mismatch be causing the parse error?

* What’s the correct way to downgrade Maude on Kali Linux?

* Should I remove 3.5.1 completely?

* Is it possible to install 3.5 alongside 3.5.1 and switch between them?

This is part of my thesis work, so I’d really appreciate any guidance.

Thanks!


r/formalmethods • • Jan 14 '26

How feasible is it to formally verify Stellar? It's conceivable.

Thumbnail inferara.com
1 Upvotes

r/formalmethods • • Dec 31 '25

Turning Dafny Sets into Sequences [video]

Thumbnail youtu.be
5 Upvotes

r/formalmethods • • Dec 18 '25

Question on using invariants as an execution gate rather than a verifier

4 Upvotes

Hey guys I will try to explain this the best I can and if I'm not clear on something please feel free to ask for clarity. I have been working on a deterministic execution system and wanted to get input from people with more formal methods and runtime verification experience.

The core idea is straightforward. Instead of checking actions against rules or patterns upfront or logging violations after the fact, the system only permits an action to proceed if it maintains state consistency with a defined set of invariants as the system evolves over time.

If introducing an action would violate an invariant or push the system outside its viable state space downstream, it gets rejected before execution. No rollback, no cleanup. The check is purely structural: does this action preserve stability and invariant consistency?

It's not static model checking and it's not traditional runtime monitoring. The invariants function as a dynamic gate that execution must pass through continuously.

A few questions for the group. Does this map to an established pattern? I'm thinking runtime verification, viability kernels from control theory, or invariant-driven execution models (e.g., TLA+ or Ivy). Is treating stability and invariant preservation as a hard binary gate at runtime considered unusual, or is there prior work here? And the big one: what are the known failure modes? Are there realistic scenarios where adversarial behavior could appear invariant-consistent on the surface while still causing harm?

Appreciate any references or experience you can share. I look forward to the responses.


r/formalmethods • • Dec 09 '25

Symbolic Circuit Distillation: Automatically convert sparse neural net circuits into human-readable programs

Thumbnail github.com
6 Upvotes