An overview of the Coq Formalization
For the Coq code, click on the file name of each part of the development.
A Program logic build on top of Iris for programming languages with continuations.
This folder essentially contains a copy of (an older version of) the program logic folder of the Iris development. Files whose name begins with "CC_" are those that really need to be extended to support continuations.
- The notion of a programming language: theories/program_logic/language.v
- Defining programming languages by defining head-step reduction relation and evaluation contexts: theories/program_logic/CC_ectx_language.v
- Defining evaluation contexts as lists of evaluation context items: theories/program_logic/CC_ectxi_language.v
- The definition of weakest precondition: theories/program_logic/weakestpre.v
- Facilitates proving weakest precondition inference rules for steps of computation: theories/program_logic/lifting.v
- Facilitates proving weakest precondition inference rules for steps of computation when language defined using evaluation context and head-step: theories/program_logic/CC_ectx_lifting.v
- Adequacy of weakest preconditions, i.e., the fact that weakest precondition WP e {Φ} implies e is safe and whenever e terminates with a value v, Φ(v) holds: theories/program_logic/adequacy.v
- Context-local weakest preconditions: theories/program_logic/cl_weakestpre.v
Languages
- A few basic constructs used in defining all programming languages: lang_base.v
- Types:
All programming languages below share the same types (with different typing rules!). Types for all these programming languages are defined in the following file:
- Types shared by all programming languages below: types.v
- F-μ-ref-conc-cc
This is the main programming language throughout the paper.
- F-μ-ref-cc-coop
This is the source language in the translation presented in section 7 of the paper.
- The language: cooperative/cooplang/lang.v, where it is also registered as an Iris language.
- The type system is formalized in cooperative.cooplang/typing.v
The language F-μ-ref-cc-coop is defined using an alternative version of a programming language than the one in theories/program_logic/CC_ectx_language.v (see above). We do not define a notion of weakest precondition for this kind of languages as we do not need it for this paper. This alternative notion of language is defined in the following files:
- The notion of a language with cooperative concurrency: cooperative/program_logic/coop_language.v
- The notion of a language with cooperative concurrency defined using head-step reduction and evaluation contexts: cooperative/program_logic/coop_ectx_language.v
- Defining evaluation contexts as lists of evaluation context items for cooperative languages: cooperative/program_logic/coop_ectxi_language.v
This is the target of the translation presented in section 7 of the paper.
- The language: F_mu_ref_cc/lang.v, where it is also registered as an Iris language.
- The type system is formalized in F_mu_ref_cc/typing.v
Weakest precondition (WP) rules
Basic WP inference rules for basic operations, e.g., beta-reduction, projections, reading references, etc.
- F-μ-ref-conc-cc
- WP rules: rules_unary.v
- F-μ-ref-cc
- WP rules: F_mu_ref_cc/rules_unary.v
Context local weakest precondition (CLWP) rules
Basic CLWP inference rules for basic operations, e.g., beta-reduction, projections, reading references, etc. These are derived based on the WP rules above.
- F-μ-ref-conc-cc
- CLWP rules: cl_rules.v
- F-μ-ref-cc
- CLWP rules: F_mu_ref_cc/cl_rules.v
Execution on the specification side (used in binary logical relations)
Basic rules for evaluation on the specification side (Section 3.2 of the paper)
- F-μ-ref-conc-cc
- Execution on the specification side: rules_binary.v
- F-μ-ref-cc-coop
- Execution on the specification side: cooperative/cooplang/rules_binary.v
Translation of cooperative concurrency to continuations
- The implementation of queue in F-μ-ref-cc used for scheduling threads: F_mu_ref_cc/queue.v
- The light-weight thread library LiThr: coop_logrel/light_weight_threads.v
- Compilation (stage 1): coop_logrel/translation.v
- Compilation (stage 2): coop_logrel/compilation.v
Logical relations models
- Binary logical relations for F-μ-ref-conc-cc
- The binary logical relation: logrel_binary.v
- Compatibility lemmas and the fundamental theorem: fundamental_binary.v
- The notion of contextual refinement and the fact that binary logical relatedness is closed under well-typed contexts: context_refinement.v
- Soundness with regard to contextual equivalence: soundness_binary.v
- Cross-language logical relations between F-μ-ref-cc and F-μ-ref-cc-coop for proving correctness of translation of cooperative concurrency
- The logical relation: coop_logrel/logrel.v
- Compatibility lemmas and the fundamental theorem of cross-language logical relations: coop_logrel.logical_correctness.v
- Soundness of cross-language logical relations (correctness of translation of cooperative concurrency with continuations): coop_logrel/correctness.v
- Unary logical relations for F-μ-ref-conc-cc (does not appear in the paper)
- The logical relation: logrel_unary.v
- The fundamental theorem: fundamental_unary.v
- Soundness of logical relations (type soundness): soundness_unary.v
Examples
- The file examples/cl_example.v contains the simple example of using callcc from Sec 3.1 of the paper and the proof of its WP and CLWP spec which are respectively presented in Section 3.1 and Section 4.
- Examples of CLWP specifications:
- CLWP specs: examples/stack.v
- CLWP for list reversal implemented using stack specs above: examples/list_rev.v
- Library code and its spec used in (possibly multiple) examples:
- Association lists and their CLWP specs: examples/refinement/list_assoc.v and examples/refinement/list_assoc_binary_spec.v
- CLWP for basic list operations: examples/refinement/list_basics.v
- A lock implementation and its specification side execution specs: examples/refinement/lock.v
- CLWP specs for locks above: examples/refinement/lock_unary_spec.v
- Examples that do appear in the paper
- One-shot continuations
- The two programs (continuation and one-shot continuations): examples/refinement/oneshotCC/oneshotCC_progs.v
- The formalization of the one-shot bit using Iris resources: examples/refinement/oneshotCC/oneshotCC_rules.v
- The two refinements (one side uses a helper lemma which is split in a separate file to speed up compilation with make -j): examples/refinement/oneshotCC/oneshotCC_LR1.v, examples/refinement/oneshotCC/oneshotCC_LR2.v and examples/refinement/oneshotCC/oneshotCC_LR2_helper.v
- Two servers
- The state-storing server implementation: examples/refinement/server/server_nat.v
- The continuation-based server implementation: examples/refinement/server/server_cont.v
- The two refinements: examples/refinement/server/refinement_1.v and examples/refinement/server/refinement_2.v
- One-shot continuations
- Examples that do not appear in the paper
- Refinement of concurrent stack modules
- The fine-grained concurrent stack: examples/refinement/stack/FG_stack.v
- The coarse-grained concurrent stack: examples/refinement/stack/CG_stack.v
- The formalization of stack resource used for proving refinement: examples/refinement/stack/stack_rules.v
- The proof that fine-grained implementation refines the coarse-grained implementation: examples/refinement/stack/refinement.v
- Refinement of concurrent counter modules
- The fine-grained and coarse-grained concurrent counter implementations and the proof that fine-grained implementation refines the coarse-grained implementation: examples/refinement/counter.v
- Refinement of concurrent stack modules
Misc.
- A few basic useful lemmas: prelude.v