Skip to content

Commit 39f9e0a

Browse files
committed
Separation logic: improve documentation.
1 parent 71fcd6a commit 39f9e0a

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

src/org/sosy_lab/java_smt/api/SLFormulaManager.java

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// an API wrapper for a collection of SMT solvers:
33
// https://github.com/sosy-lab/java-smt
44
//
5-
// SPDX-FileCopyrightText: 2020 Dirk Beyer <https://www.sosy-lab.org>
5+
// SPDX-FileCopyrightText: 2025 Dirk Beyer <https://www.sosy-lab.org>
66
//
77
// SPDX-License-Identifier: Apache-2.0
88

@@ -15,18 +15,73 @@
1515
* all formulae for one heap need to use matching types (sorts) for the AdressFormulae and
1616
* ValueFormulae. The user has to take care of this, otherwise the {@link ProverEnvironment}
1717
* complains at runtime!
18+
*
19+
* @see <a href="https://en.wikipedia.org/wiki/Separation_logic">Separation Logic</a>
20+
* @see <a href="https://cacm.acm.org/research/separation-logic/>Separation Logic</a>
21+
* @see <a
22+
* href="https://www.cs.cmu.edu/afs/cs.cmu.edu/project/fox-19/member/jcr/www15818As2011/cs818A3-11.html">15-818A3
23+
* Introduction to Separation Logic (6 units) Spring 2011</a>
24+
* @see <a href="https://www.philipzucker.com/executable-seperation>Modeling Separation Logic with
25+
* Python Dicts and Z3</a>
1826
*/
1927
@SuppressWarnings("MethodTypeParameterName")
2028
public interface SLFormulaManager {
2129

30+
/**
31+
* Creates a formula representing the "separating conjunction" (*) of two Boolean formulas. In
32+
* separation logic, the separating conjunction asserts that the two formulas describe disjoint
33+
* parts of the heap. It is similar to the logical AND operator, but with the additional
34+
* constraint that the memory regions described by the two formulas do not overlap.
35+
*
36+
* @return a Boolean formula representing the separating conjunction of {@code f1} and {@code f2}.
37+
*/
2238
BooleanFormula makeStar(BooleanFormula f1, BooleanFormula f2);
2339

40+
/**
41+
* Creates a formula representing a "points-to" relation in the heap. The "points-to" relation
42+
* asserts that a pointer points to a specific value in memory.
43+
*
44+
* @param <AF> the type of the address formula.
45+
* @param <VF> the type of the value formula.
46+
* @param ptr the pointer formula.
47+
* @param to the value formula.
48+
* @return a Boolean formula representing the "points-to" relation.
49+
*/
2450
<AF extends Formula, VF extends Formula> BooleanFormula makePointsTo(AF ptr, VF to);
2551

52+
/**
53+
* Creates a formula representing the "magic wand" (-*) operator in separation logic. The "magic
54+
* wand" operator asserts that if the first formula holds, then the second formula can be added to
55+
* the heap without conflict. It is a form of implication (=>) that takes into account the
56+
* disjointness of memory regions.
57+
*
58+
* @return a Boolean formula representing the "magic wand" of {@code f1} and {@code f2}.
59+
*/
2660
BooleanFormula makeMagicWand(BooleanFormula f1, BooleanFormula f2);
2761

62+
/**
63+
* Creates a formula representing an empty heap. The empty heap formula asserts that no memory is
64+
* allocated for the given address and value types.
65+
*
66+
* @param <AF> the type of the address formula.
67+
* @param <VF> the type of the value formula.
68+
* @param <AT> the type of the address formula type.
69+
* @param <VT> the type of the value formula type.
70+
* @param pAddressType the type of the address formula.
71+
* @param pValueType the type of the value formula.
72+
* @return a Boolean formula representing an empty heap.
73+
*/
2874
<AF extends Formula, VF extends Formula, AT extends FormulaType<AF>, VT extends FormulaType<VF>>
29-
BooleanFormula makeEmptyHeap(AT pAdressType, VT pValueType);
75+
BooleanFormula makeEmptyHeap(AT pAddressType, VT pValueType);
3076

77+
/**
78+
* Creates a formula representing the "nil" element for a given address type. The "nil" element is
79+
* used to represent a null pointer or an unallocated memory address.
80+
*
81+
* @param <AF> the type of the address formula.
82+
* @param <AT> the type of the address formula type.
83+
* @param pAdressType the type of the address formula.
84+
* @return a formula representing the "nil" element for the given address type.
85+
*/
3186
<AF extends Formula, AT extends FormulaType<AF>> AF makeNilElement(AT pAdressType);
3287
}

0 commit comments

Comments
 (0)