arXiv:2608.22630cs.PLAug 2026

Manuscript Offprint

arXiv:2608.22630

VeGo: Direct Deductive Formal Verification of Go Programs for Computer Science Education

Tina Massoudi, Chris Dutchyn

Abstract

Teaching formal software verification to computer science undergraduates is historically hindered by a steep cognitive barrier: students must simultaneously master formal logic (Hoare triples, loop invariants, mathematical induction) and a new, specialized verification language (such as Dafny) or abstract specification formalism (such as TLA+). The original pedagogical foundation for software specification in computer science curricula was established by R.D. Tennent in Specifying Software (2002), which advocated integrating formal specifications directly alongside imperative programs. However, Tennent's methodology lacked automated verification tool support over a modern, executable programming language.

In this paper, we present VeGo (Verified Go), a deductive formal verification system that enables direct verification of standard Go source code. VeGo incorporates Hoare-style contracts (//@ Requires, //@ Ensures, //@ Exsures), loop invariants and integer variants, well-founded recursive measures, block-level scope invariants (//@ Preserves), and equational reasoning chains with primed variables (x') directly into non-intrusive Go comments. We detail the language selection rationale justifying Go as an ideal balance over C, C++, Java, and Rust, leveraging Go's native multiple return values as a modern replacement for Pascal's input-output (VAR) parameters. We detail the tool architecture, exploiting the theoretical equivalence between Static Single Assignment (SSA) form and first-order functional programming (Pfenning, Kelsey, Appel, Rastello), desugaring of clopen interval quantifiers and Reynolds' skip statement, weakest precondition (wp) calculus, and native Hindley–Milner (HM[X]) constraint inference and verification condition resolution over SSA form. Furthermore, as Martin Kleppmann observes, formal methods are rapidly becoming accessible and practical due to AI coding agents, which assist developers and students in generating specifications while native HM[X]/SSA verifiers provide rigorous mathematical guardrails. We formalize contract precision checking (wp vs. sp) using an explicit analogy to Hindley-Milner (HM[X]) type inference. Finally, we evaluate VeGo across classroom case studies and outline a roadmap for formal concurrency specifications using epistemic temporal logic (Fagin et al., Owicki–Gries, Chandy–Misra).

1 Introduction

Formal software verification is critical for constructing high-assurance software systems. However, integrating formal methods into the core computer science undergraduate curriculum remains a persistent challenge. Historically, instructors faced a trade-off: either present formal logic abstractly using paper-and-pencil proofs without tool automation, or require students to learn a research-oriented specification language (e.g., Dafny [19], Spec#, or Coq/Isabelle) that is divorced from the mainstream imperative programming languages students use in their day-to-day software development.

Furthermore, the conceptual framework for teaching software specification as a core computing discipline was pioneered by R.D. Tennent in Specifying Software: A Curriculum Foundation for Formal Methods [25]. Tennent demonstrated that rigorous reasoning about program correctness should be integrated directly into imperative programming instruction. However, at the time of its publication, Tennent's methodology lacked automated tool support capable of executing and verifying programs written in a modern, production-grade language.

To fulfill this pedagogical vision, we developed VeGo (Verified Go). VeGo enables students and instructors to write formal specifications directly inside standard Go source files using special comment annotations (///@). Because specifications reside in comments, every VeGo file remains 100% valid Go source code that compiles and executes natively using standard Go toolchains, while simultaneously undergoing static formal verification via the vegop verification engine and Visual Studio Code Language Server Protocol (LSP) extension.