Hybrid Argument Demonstration using Deep Embedding #
This file demonstrates how the deep embedding of CatCrypt enables cleaner and more structured hybrid argument proofs in cryptography.
Overview #
A hybrid argument is a proof technique where we show two games are equivalent by constructing a sequence of intermediate games:
Game0 ~ Game1 ~ Game2 ~ ... ~ GameN
where each adjacent pair differs in a small, analyzable way. The deep embedding provides several advantages for such proofs:
Structural Induction: We can analyze games by their syntactic structure using
RawCode.inductionOn, rather than semantic simulation.Separation Reasoning: The location set structure provides automatic reasoning about disjoint state through
DeepPackage.sep.Compositional Reasoning: Package composition (
link,par) preserves separation properties.
Comparison with Shallow Embedding #
In the shallow embedding (standard CatCrypt), games are represented as Lean functions. Proving equivalence requires manual tracking of state invariants, explicit coupling constructions, and complex simulation arguments.
In the deep embedding, games are syntax trees that allow structural induction on syntax, automatic support/disjointness reasoning, and compositional separation properties.
References #
- Larsen and Schürmann, Nominal State-Separating Proofs
- Haselwarter et al., SSProve: A Foundational Framework for Modular Cryptographic Proofs in Coq
- SSProve Rocq:
theories/Crypt/examples/PRF_example.v
Example Interfaces #
Simple interface with one operation: query : Unit -> Nat
Instances For
Behavioral Equivalence #
Behavioral equivalence of deep packages based on export interface equality.
In a full development, this would compare implementations via denotational semantics. Here we use a simplified definition based on exports.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Transitivity of Equivalence #
Behavioral equivalence is reflexive
Behavioral equivalence is symmetric
Behavioral equivalence is transitive
Separation Properties Demo #
Demonstration: two packages with disjoint location ids are separated.
Hybrid Sequence Structure #
A hybrid argument is a sequence of games with adjacent equivalences.
- games : List DeepPackage
The games in the sequence
Non-empty sequence
Instances For
The first and last games in a hybrid sequence are equivalent if all adjacent pairs are equivalent.
This is the key theorem for hybrid arguments: we can chain together local equivalences to get global equivalence.
Documentation: Benefits of Deep Embedding for Hybrid Arguments #
Key Advantages #
Explicit Syntax Trees
- Games are data structures, not opaque functions
- We can pattern match on code structure
- Transformations are explicit and verifiable
Structural Induction
RawCode.inductionOnprovides a principled way to analyze all code paths- No need for complex simulation relations
- Proof follows the syntax structure
Separation via Location Sets
DeepPackage.sep p1 p2captures state disjointness- Composition preserves separation (
par_sep_left,par_sep_right)
Compositional Reasoning
- Link and parallel composition have algebraic properties
- Separation is compositional
Comparison: Shallow vs Deep #
| Aspect | Shallow | Deep |
|---|---|---|
| Games | Functions | Syntax trees |
| Equivalence | Coupling/simulation | Structural + semantic |
| State separation | Manual invariants | Automatic via sep |
| Induction | Semantic domain | Syntax structure |
When to Use Deep Embedding #
The deep embedding is particularly beneficial when:
- The proof involves multiple games with similar structure
- State separation is a key reasoning principle
- You want to apply program transformations
For simple proofs where semantic reasoning suffices, the shallow embedding may be more direct.