cpp-to-dafny-translator

Translate C/C++ programs into verifiable Dafny code with specifications.

142|14|Updated Feb 14, 2026
One-click install
npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill cpp-to-dafny-translator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cpp-to-dafny-translator
Source: https://github.com/ArabelaTso/Skills-4-SE/tree/main/skills/cpp-to-dafny-translator
Command: npx skills add https://github.com/ArabelaTso/Skills-4-SE --skill cpp-to-dafny-translator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of migrating or verifying C/C++ code by translating it into Dafny, a language designed for formal verification, ensuring semantic equivalence and enabling rigorous proof of correctness.

Core Features & Use Cases

  • Semantic Preservation: Translates C/C++ constructs (functions, structs, pointers, arrays) to Dafny equivalents while maintaining original program semantics.
  • Verification Enablement: Generates Dafny code that is well-typed, executable, verifiable, and includes necessary specifications (preconditions, postconditions, invariants).
  • Use Case: A critical C algorithm needs to be formally proven correct. This Skill translates the C code into Dafny, allowing engineers to use Dafny's verifier to prove its safety and functional correctness.

Quick Start

Use the cpp-to-dafny-translator skill to convert the provided C code snippet into Dafny.

Frequently Asked Questions about cpp-to-dafny-translator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I translate C++ code to Dafny for formal verification?

To translate C++ code to Dafny for formal verification, this Skill converts functions, structs, pointers, and arrays into equivalent, well-typed Dafny code while preserving original program semantics and ensuring memory safety.

How does translating C pointers and arrays to Dafny work?

Translating C pointers and arrays to Dafny involves mapping these memory constructs to equivalent Dafny representations that maintain original semantics, enabling the program synthesis process to generate executable, verifiable code with appropriate memory safety specifications.

Can I formally verify existing C algorithms without rewriting them manually?

You can formally verify existing C algorithms by translating them into Dafny using this Skill, which generates verifiable code complete with necessary preconditions, postconditions, and invariants, allowing Dafny's verifier to rigorously prove functional correctness.

Does the generated Dafny code include specifications like preconditions and invariants?

The generated Dafny code includes necessary specifications such as preconditions, postconditions, and invariants, ensuring the translated output is well-typed, executable, and immediately ready for rigorous formal verification.

What are the limitations of converting C memory management to Dafny?

When converting C memory management to Dafny, limitations arise from the complexity of mapping manual memory allocation and pointers to Dafny's memory-safe constructs, requiring careful semantic preservation to ensure the translated code remains verifiable.