Cross-Language Formal Verification in Julia
Julia reference implementation of aggregate-library with formal verification, designed for cross (programming) language verification.
PolyglotFormalisms.jl is a Julia-based framework for building and verifying formal specifications across multiple programming languages. It enables:
-
Cross-language formal verification: Prove properties about code written in different languages.
-
Aggregate library design: Reuse verified components across Julia, Idris2, Zig, and more.
-
ABI/FFI standards compliance: Seamless integration with foreign function interfaces.
-
Mathematical guarantees: Compile-time proofs for memory safety, type correctness, and interface compliance.
using PolyglotFormalisms
# Define a verified interface
@formal interface SafeDOM
function mount(element::String, content::String) :: Bool
@ensure element ≠ "" && content ≠ ""
@prove ∀x. mount(x, "") == false
end
end
# Generate bindings for other languages
generate_bindings(SafeDOM, languages=[:zig, :idris])Verify properties across language boundaries:
@formal contract SafeMemory
function allocate(size::Int) :: Ptr
@ensure size > 0
@prove ∀s. s > 0 ⇒ allocate(s) ≠ C_NULL
end
end
# Generate Idris2 and Zig bindings
generate_abi(SafeMemory, "memory_abi.h")All foreign function interfaces follow the Hyperpolymath Universal Standard:
-
Idris2: Type definitions with dependent type proofs.
-
Zig: C-compatible, memory-safe implementations.
-
Auto-generated C headers: Bridge between Idris2 and Zig.
project/
├── src/abi/ # Idris2 ABI definitions
├── ffi/zig/ # Zig FFI implementation
├── generated/abi/ # Auto-generated C headers
└── bindings/ # Language-specific wrappersCross-language projects often suffer from: - Undetected memory errors - Type mismatches at runtime - Unverified foreign function interfaces
PolyglotFormalisms.jl provides: | Issue | Traditional FFI | PolyglotFormalisms.jl | |----------------------|-----------------|-----------------------| | Memory safety | Runtime crashes | Compile-time proofs | | Type correctness | Manual checks | Dependent types | | Interface compliance | Ad-hoc testing | Formal verification |
PolyglotFormalisms.jl/
├── src/ # Julia source
│ ├── abi/ # ABI definitions
│ ├── ffi/ # FFI implementations
│ └── verification/ # Proof system
├── generated/ # Auto-generated headers
└── bindings/ # Language wrappers-
✅ v0.1: Core framework, Idris2/Zig integration
-
⬜ v0.2: Expanded language support (Rust, ReScript)
-
⬜ v0.3: Advanced proof automation
-
⬜ v1.0: Industry-ready certification