Syng
Syng: A syntactic approach to concurrent separation logic with propositional ghost state, fully mechanized in Agda
Install / Use
/learn @hopv/SyngREADME
Syng
Syng is concurrent separation logic with propositional ghost state, fully mechanized in Agda.
Syng supports propositional ghost state, which brings powerful expressivity,
just like an existing separation logic Iris
(Jung et al., 2015).
Notably, Syng supports propositional invariants (a.k.a. impredicative
invariants).
But in contrast to Iris's fully semantic approach, Syng models the propositional ghost state simply using the logic's syntax (for propositions and judgments).
As a result, while Iris suffers from step indexing everywhere, Syng is not
step-indexed at all.
Thanks to that, Syng has intuitive, easy-to-extend semantics and can flexibly
support termination-sensitive program reasoning.
Syng is mechanized in Agda, a
modern, dependently typed programming language.
Agda is chosen here rather than Coq,
Lean, etc., because Agda has excellent support
of coinduction enabled by
sized types,
and Syng's approach takes great advantage of that.
Getting Started
Just install Agda.
Syng is known to work with Agda 2.6.2.2.
Syng has no dependencies on external libraries.
Agda Mode
For viewing and editing Agda code, you can use Agda mode for Emacs or VS Code.
When you open an Agda file, you should first load the file (Ctrl-c Ctrl-l in
Emacs and VS Code), which loads and type-checks the contents of the file and
its dependencies.
Also, you can quickly jump to the definition (Meta-. in Emacs and F12 in VS
Code) of any identifiers, including those that use symbols.
Fonts
Syng's source code uses a lot of Unicode characters.
To render them beautifully, we recommend you use monospace Unicode fonts that
support these characters, such as the following:
- JuliaMono ― Has a huge Unicode cover, including all the characters used in Syng's source code.
- Menlo ― Is preinstalled
on Mac and pretty beautiful. Doesn't support some characters (e.g.,
⊢).
For example, in VS Code, you can use the following setting (in settings.json)
to use Menlo as the primary font and fill in some gaps with JuliaMono.
"editor.fontFamily": "Menlo, JuliaMono"
Learning Agda
You can learn Agda's language features from the official document.
Here are notable features used in Syng.
- Sized types ― Enable flexible coinduction and induction, especially in combination with thunks and shrunks.
- With-abstractions ― Allow case analysis on calculated values.
- Copatterns ― Get access to a component of records like a pattern.
- Record modules ―
Extend record types with derived notions, effectively used by the type
ERA.
Source Code
In the folder src is the Agda source code for Syng.
Base/
In Base/ is a general-purpose library (though newly developed
for Syng).
Some of them re-export Agda's built-in libraries, possibly with renaming.
The library consists of the following parts.
- Basics ―
Levelfor universe levels;Funcfor functions;Fewfor two-, one- and zero-element sets;Eqfor equality;Decfor decidability;Accfor accessibility;Sizefor sizes (modeling ordinals), thunks and shrunks. - Data types ―
Boolfor Booleans;Zoifor zoi (zero, one, or infinity) numbers;Optionfor option types;Prodfor sigma and product types;Sumfor sum types;Natfor natural numbers;Natpfor positive natural numbers;Listfor singly linked lists;Seqfor infinite sequences;Strfor characters and strings;Ratpfor positive rational numbers. - Misc ―
Setyfor syntactic sets.
Syng/
In Syng/ is the heart of Syng, which consists of the
following parts.
Lang/― The target language of Syng.Logic/― The syntax of the separation logic Syng.Propfor propositions;Judgfor judgments.Corefor core proof rules;Namesfor the name set token;Fupdfor the fancy update;Horfor the Hoare triple;Heapfor the heap;Indfor the indirection modality and the precursors;Invfor the propositional invariant;Lftfor the lifetime;Borfor the borrow;Ubfor the upper bound.Paradoxfor paradoxes on plausible proof rules.Examplefor examples.
Model/― The semantic model and soundness proof of Syng.ERA/― Environmental resource algebras (ERAs), for modeling the ghost state of Syng.Basefor the basics of the ERA;Allfor the dependent-map ERA;Bndfor the bounded-map ERA;Finfor the finite-map ERA.- Basic ERAs ―
Zoifor the zoi ERA;Excfor the exclusive ERA;Agfor the agreement ERA;FracAgfor the fractional agreement ERA. - Tailored ERAs ―
Heapfor the heap ERA;Namesfor the name set ERA;Indfor the indirection ERAs;Invfor the invariant ERA;Lftfor the lifetime ERA;Borfor the borrow ERA;Ubfor the upper bound ERA. - Global ERA ―
Globfor the global ERA.
Prop/― The semantic model of the propositions and the semantic soundness of the pure sequent.Basefor the core semantic logic connectives;Smryfor the map summary;Namesfor the name set token;Heapfor the heap-related tokens;Lftfor the lifetime-related tokens;Ubfor the upper bound-related tokens.Basicfor basic propositions;Indfor the indirection modality and precursors;Invfor the invariant-related tokens;Borfor the borrow-related tokens.Interpfor the semantics of all the propositions;Soundfor the semantic soundness and adequacy of the logic's pure sequent.
Fupd/― The semantic model and soundness proof of the fancy update.
