@@ -31,6 +31,7 @@ import org.sosy_lab.java_smt.api.Model
3131 * // c -> h()
3232 * // d -> f(g(2), h())
3333 * ```
34+ *
3435 * We can leverage this information to write better error messages. If we have a constraint which
3536 * states b > 0, we can replace it with g(2) > 0.
3637 */
@@ -41,7 +42,6 @@ object ErrorMessages {
4142 * SMT formulae.
4243 *
4344 * For example, we cannot translate method calls to SMT:
44- *
4545 * ```kotlin
4646 * fun f(xs: List[String]): String {
4747 * pre({ !xs.get(0).isEmpty() }) { ... }
@@ -95,14 +95,13 @@ object ErrorMessages {
9595 *
9696 * See [arrow.meta.plugins.analysis.phases.analysis.solver.checkImplicationOf] for the code which
9797 * produces the errors.
98- *
9998 * - The _one_ constraint name and Boolean formula which could not be satisfied.
10099 * - A _counter-example_ (also called a _model_), which is an assignment of values to
101- * variableswhich show a specific instance in which the constraint is false.
100+ * variableswhich show a specific instance in which the constraint is false.
102101 * - In the `f` function above in the `UnsatBodyPost` epigraph, one such counter-example is `x ==
103- * 0`, since in that case `0 + 0 > 1` is false.
102+ * 0`, since in that case `0 + 0 > 1` is false.
104103 * - By looking at the values of the model for the arguments, we can derive one specific trace for
105- * which the function fails.
104+ * which the function fails.
106105 */
107106 object Unsatisfiability {
108107
@@ -111,7 +110,6 @@ object ErrorMessages {
111110 * property, function) call are not satisfied.
112111 *
113112 * For example:
114- *
115113 * ```kotlin
116114 * val wrong = 1 / 0 // does not satisfy '0 != 0' in Int.div law
117115 * ```
@@ -126,16 +124,15 @@ object ErrorMessages {
126124 | -> unsatisfiable constraint: `${callPreCondition.formula.dumpKotlinLike()} `
127125 | -> ${template(callPreCondition, this )}
128126 | -> ${branch(branch)}
129- """ .trimMargin(
130- )
127+ """
128+ .trimMargin( )
131129
132130 /* *
133131 * (attached to the return value)
134132 *
135133 * the post-condition declared in a function body is not true.
136134 *
137135 * For example:
138- *
139136 * ```kotlin
140137 * fun f(x: Int): Int {
141138 * pre(x >= 0) { "non-negative" }
@@ -152,15 +149,14 @@ object ErrorMessages {
152149 ): String =
153150 """ |declaration `${declaration.name} ` fails to satisfy the post-condition: ${postCondition.formula.dumpKotlinLike()}
154151 | -> ${branch(branch)}
155- """ .trimMargin(
156- )
152+ """
153+ .trimMargin( )
157154
158155 /* *
159156 * (attached to the new value): the invariant declared for a mutable variable is not satisfied
160157 * by the new value.
161158 *
162159 * For example:
163- *
164160 * ```kotlin
165161 * fun g(): Int {
166162 * var r = 1.invariant({ it > 0 }) { "it > 0" }
@@ -179,8 +175,8 @@ object ErrorMessages {
179175 """ |invariants are not satisfied in `${expression.text} `
180176 | -> unsatisfiable constraint: `${constraint.formula.dumpKotlinLike()} `
181177 | -> ${branch(branch)}
182- """ .trimMargin(
183- )
178+ """
179+ .trimMargin( )
184180 }
185181
186182 /* *
@@ -205,7 +201,6 @@ object ErrorMessages {
205201 * The set of pre-conditions given to the function leaves no possible way to call the function.
206202 *
207203 * For example:
208- *
209204 * ```kotlin
210205 * fun h(x: Int): Int {
211206 * pre({ x > 0 }) { "greater than 0" }
@@ -226,7 +221,6 @@ object ErrorMessages {
226221 * The default values do not satisfy the pre-conditions.
227222 *
228223 * For example:
229- *
230224 * ```kotlin
231225 * fun h(x: Int = 0): Int {
232226 * pre({ x > 0 }) { "greater than 0" }
@@ -245,7 +239,6 @@ object ErrorMessages {
245239 * condition it hangs upon conflicts with the rest of the information about the function.
246240 *
247241 * For example, if a condition goes against a pre-condition:
248- *
249242 * ```kotlin
250243 * fun i(x: Int): Int {
251244 * pre({ x > 0 }) { "greater than 0" }
@@ -265,8 +258,8 @@ object ErrorMessages {
265258 ): String =
266259 """ |unreachable code due to conflicting conditions: ${unsatCore.dumpKotlinLike()}
267260 | -> ${branch(branch)}
268- """ .trimMargin(
269- )
261+ """
262+ .trimMargin( )
270263
271264 /* *
272265 * (attached to the function call): the post-conditions gathered after calling a function imply
@@ -278,15 +271,14 @@ object ErrorMessages {
278271 ): String =
279272 """ |unreachable code due to post-conditions: ${unsatCore.dumpKotlinLike()}
280273 | -> ${branch(branch)}
281- """ .trimMargin(
282- )
274+ """
275+ .trimMargin( )
283276
284277 /* *
285278 * (attached to a local declaration): there is no way in which the invariant attached to a
286279 * declaration may be satisfied.
287280 *
288281 * For example:
289- *
290282 * ```kotlin
291283 * fun j(x: Int): Int {
292284 * pre({ x > 0 }) { "greater than 0" }
@@ -301,22 +293,22 @@ object ErrorMessages {
301293 ): String =
302294 """ |invariants are inconsistent: ${it.dumpKotlinLike()}
303295 | -> ${branch(branch)}
304- """ .trimMargin(
305- )
296+ """
297+ .trimMargin( )
306298 }
307299
308300 object Liskov {
309301 internal fun KotlinPrinter.notWeakerPrecondition (constraint : NamedConstraint ): String =
310302 """ |pre-condition `${constraint.msg} ` is not weaker than those from overridden members
311303 | -> problematic constraint: `${constraint.formula.dumpKotlinLike()} `
312- """ .trimMargin(
313- )
304+ """
305+ .trimMargin( )
314306
315307 internal fun KotlinPrinter.notStrongerPostcondition (constraint : NamedConstraint ): String =
316308 """ |post-condition `${constraint.msg} ` from overridden member is not satisfied
317309 | -> problematic constraint: `${constraint.formula.dumpKotlinLike()} `
318- """ .trimMargin(
319- )
310+ """
311+ .trimMargin( )
320312 }
321313
322314 object Exception {
0 commit comments