CtrlK
BlogDocsLog inGet started
Tessl Logo

jpc0/provably-correct-software

Build provably correct software using formal methods like Hoare Logic, Weakest Preconditions, and Design-by-Contract.

99

1.45x

Quality

100%

Does it follow best practices?

Impact

99%

1.45x

Average score across 5 eval scenarios

Overview
Skills
Evals
Files

task.mdevals/scenario-5/

Verified Greatest Common Denominator Logic

Problem Description

The following algorithm calculates the Greatest Common Divisor (GCD) for two positive integers:

def calculate_gcd(a, b):
    x = a
    y = b
    while x != y:
        if x > y:
            x = x - y
        else:
            y = y - x
    return x

Requirements:

  • You must provide a comprehensive formal proof that this algorithm correctly calculates the GCD for all positive inputs.
  • Your proof must also include a rigorous mathematical argument that the algorithm is guaranteed to terminate.
  • Annotate the implementation with the formal logical steps that demonstrate its correctness throughout its execution.
  • Your documentation should be structured to show exactly how the algorithm transforms its state toward the final result.

Output Specification

Produce a Python file gcd_verified.py with the provided algorithm and the full formal verification documented in the comments.

Install with Tessl CLI

npx tessl i jpc0/provably-correct-software@0.1.0

evals

SKILL.md

tile.json