agentleFS
rainoftimerainoftime/pl-skills/contextual-equivalence/SKILL.md

contextual-equivalence

Skill17 starsChanged 9 months agoApache-2.0View on GitHub

A skill for proving contextual equivalence between programs using operational semantics, bisimulation, and related techniques.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use operational semantics to reason about program behavior

    line 23

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Contextual Equivalence

Domain: Program Verification / Programming Languages

Overview

A skill for proving contextual equivalence between programs using operational semantics, bisimulation, and related techniques.

Capabilities

  • Prove that two programs are contextually equivalent
  • Build bisimulation relations for behavioral equivalence
  • Use operational semantics to reason about program behavior
  • Apply contextual equivalence in compiler verification

Techniques

  • Operational Semantics: Small-step and big-step semantics
  • Bisimulation: Trace equivalence, bisimilarity proofs
  • Contextual Equivalence: Observation-based equivalence
  • Game Semantics: Interactive models of computation

Use Cases

  • Compiler correctness proofs
  • Program transformation verification
  • Optimization validation
  • Language meta-theory development

References

ReferenceWhy It Matters
Morris, "Lambda Calculus Types and Models" (1968)Original contextual equivalence formulation
Milner, "Operational and Algebraic Semantics" (1997)Comprehensive overview of contextual equivalence
Gunter, "Semantic Foundations for Programming Languages"Formal treatment of program equivalence
Reynolds, "Theories of Programming Languages"Contextual equivalence in type theory

See also: ../simply-typed-lambda-calculus, ../bisimulation-checker, ../operational-semantics-definer

Research Tools & Artifacts

Real-world contextual equivalence verification:

ToolWhy It Matters
CoqInteractive proof of contextual equivalence
TwelfLogical framework for LF
AgdaDependent types for equivalence proofs
NuprlConstructive verification system
HOLHigher-order logic proofs

Key Verification Projects

  • CompCert: Verified compiler with contextual equivalence
  • GHC correctness: Haskell compiler verification
  • CakeML: Verified ML compiler

Research Frontiers

Current contextual equivalence research:

DirectionKey PapersChallenge
Untyped equivalence"Equivalence in untyped λ-calculus"Full abstraction
Relational"Relational Reasoning" (2008)Semantic relations
Step-indexed"Step-indexed Bisimulation" (2005)Recursive types
Logical relations"Logical Relations" (1998)Semantics
Game semantics"Game Semantics" (1997)Full abstraction

Hot Topics

  1. Probabilistic equivalence: Contextual equivalence for probabilistic programs
  2. Differential privacy: Verifying privacy via equivalence
  3. Quantum equivalence: Quantum program equivalence

Implementation Pitfalls

Common equivalence proof bugs:

PitfallReal ExamplePrevention
Incomplete contextsMissing context formsProve completeness
Bisimulation too strongFails for equivalent programsUse weak bisimulation
Recursive typesFixed-point handlingUse step-indexing
Non-terminationDivergence not handledUse contextual equivalence
StateState in languageRelational reasoning

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.