Skip to content

Commit 0059cd7

Browse files
committed
Vatras Overview
1 parent 37d4ea7 commit 0059cd7

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,110 @@ This library formalizes all results in our paper:
2727
Additionally, our library comes with a small **demo**, and **tutorials** for getting to know the library and for formalizing your own variability languages (see "Tutorials" section below).
2828
When run in a terminal, our demo will show a translation roundtrip, showcasing the circle of compilers developed for identifying the map of variability languages (Section 5).
2929

30+
## Overview: What is Static Variability and What is Vatras?
31+
32+
Vatras is a library to study and compare meta-languages for specifying variability in source code and data.
33+
Some software systems are configurable _before_ they are compiled, i.e., statically.
34+
A common way example for implementing static variability is by conditional compilation, as for example possible with the C preprocessor.
35+
For instance, the following [code snippet from the Linux kernel](https://github.com/torvalds/linux/blob/e271ed52b344ac02d4581286961d0c40acc54c03/include/linux/console.h#L479-L486)
36+
37+
```C
38+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
39+
extern bool console_srcu_read_lock_is_held(void);
40+
#else
41+
static inline bool console_srcu_read_lock_is_held(void)
42+
{
43+
return 1;
44+
}
45+
#endif
46+
```
47+
48+
replaces the function `console_srcu_read_lock_is_held` with a default implementation in case a particular feature should be debugged.
49+
Essentially, the code snippet above does not denote a single `C` program but two `C` programs, each using one of two alternatives for the function `console_srcu_read_lock_is_held`.
50+
51+
To model and analyze static variability, researchers have formalized various formal languages, including formalisms for conditional compilation.
52+
For example, the _choice calculus_ is a small language to formalize conditional compilation in terms of a singly syntactic term, referred to as a _choice_.
53+
A choice `F ⟨ l , r ⟩` specifies two alternatives `l` and `r` for a feature or configuration option `F`.
54+
Encoding the example above in choice calculus yields
55+
56+
```
57+
CONFIG_DEBUG_LOCK_ALLOC ⟨
58+
extern bool console_srcu_read_lock_is_held(void);
59+
,
60+
static inline bool console_srcu_read_lock_is_held(void)
61+
{
62+
return 1;
63+
}
64+
65+
```
66+
67+
Apart from source code, static configuration processes emerge in many other areas, including our daily lives.
68+
For instance, some restaurants offer your to configure your meal.
69+
Sticking to the choice calculus, we may for example specify a configurable sandwich that _always_ has bread 🍞 and cheese, _maybe_ has salad 🥗 (expressed as a choice between Salad 🥗 and an empty value `ε`), _either_ has a meat 🍖 or falafel 🧆 patty, and has _any_ combination of mayonnaise 🥚 and ketchup 🍅 as follows:
70+
71+
```
72+
🍞-<
73+
Salad⟨ 🥗, ε ⟩,
74+
🧀,
75+
Patty⟨ 🍖, 🧆 ⟩,
76+
Sauce⟨ ε, 🥚, 🍅, 🍅🥚 ⟩
77+
>-
78+
```
79+
where the Y-brackets of the outer expression `🍞-< ... >-` denote that the ingredients go _within_ the bread (i.e., we build a tree where the ingredients are sub-expressions of bread).
80+
81+
The goal of Vatras is to formalize and _compare_ languages for static variabilty.
82+
To this end, we formalize the syntax and semantics of the choice calculus, some of its dialects, and many more formal languages for static variability.
83+
For instance, writing out the above sandwich expression in our Agda formalization of the choice calculus, closely resembles the original expressions (most boilerplate comes from explicit list syntax):
84+
85+
``` agda
86+
sandwich : CCC Feature ∞ Artifact
87+
sandwich =
88+
"🍞" -<
89+
"Salad" ⟨ leaf "🥗" ∷ leaf "ε" ∷ [] ⟩
90+
∷ leaf "🧀"
91+
∷ "Patty" ⟨ leaf "🍖" ∷ leaf "🧆" ∷ [] ⟩
92+
∷ "Sauce" ⟨ leaf "ε" ∷ leaf "🥚" ∷ leaf "🍅" ∷ leaf "🍅🥚" ∷ [] ⟩
93+
∷ []
94+
>-
95+
where
96+
leaf : String → CCC Feature ∞ Artifact
97+
leaf a = a -< [] >-
98+
```
99+
100+
We may configure our sandwich in terms of the semantics `⟦_⟧` for choice calculus.
101+
The semantics is a function takes a configuration as input to produce a variant.
102+
For our sandwich example, a configuration decides for each configuration option `Salad`, `Patty`, and `Sauce` which alternative to pick.
103+
A variant is a sandwich without any conditional elements left (i.e., a term without choices).
104+
From a configuration, we can derive the respective sandwich variant, and we can use Agda to prove that the semantics derive the variant we expect:
105+
106+
``` agda
107+
config : Feature → ℕ
108+
config "Salad" = 0
109+
config "Patty" = 1
110+
config "Sauce" = 2
111+
config _ = 0
112+
113+
config-makes-falafel-ketchup-sandwich :
114+
⟦ sandwich ⟧ config ≡
115+
"🍞" -<
116+
leaf "🥗"
117+
∷ leaf "🧀"
118+
∷ leaf "🧆"
119+
∷ leaf "🍅"
120+
∷ []
121+
>-
122+
config-makes-falafel-ketchup-sandwich = refl
123+
```
124+
125+
Vatras enables semantic comparisons of variability languages based on a meta-theory centered around the three fundamental yet unexplored properties of completeness, soundness, and expressiveness.
126+
Completeness serves as a lower bound (i.e., a language can express at least a given semantic domain),
127+
soundness serves as an upper bound (i.e., a language can express at most a given semantic domain),
128+
and expressiveness serves as a relative comparison (i.e., a language can express at least the semantic domain of another language).
129+
Proofs of these properties come as _encodings_ for completeness (i.e., a function that creates a variational expression from a set of variants), _enumerations_ for soundness (i.e., a function that enumerates all variants denoted by a variational expression), and _compilers_ between languages for expressiveness.
130+
Vatras includes a range of proofs of these properties for existing languages as explained in our respective paper.
131+
As a showcase, Vatras will show a roundtrip translation of the configurable sandwich specification above when you run it.
132+
Details on the features implemented in Vatras, including tutorials for integrating new languages, can be found in the **Reusability Guide** below.
133+
30134
## Kick-the-Tires
31135

32136
This section gives you a short "Getting Started" guide.

0 commit comments

Comments
 (0)