@@ -5,6 +5,7 @@ import io.ksmt.expr.KExpr
55import io.ksmt.expr.KInterpretedValue
66import io.ksmt.expr.KStringConcatExpr
77import io.ksmt.expr.KStringLiteralExpr
8+ import io.ksmt.sort.KBoolSort
89import io.ksmt.sort.KIntSort
910import io.ksmt.sort.KSort
1011import io.ksmt.sort.KStringSort
@@ -70,6 +71,8 @@ inline fun KContext.simplifyStringNestedConcat(
7071* String length expression simplification
7172* */
7273
74+ /* *
75+ * Eval length of string constant. */
7376inline fun KContext.simplifyStringLenExpr (
7477 arg : KExpr <KStringSort >,
7578 cont : (KExpr <KStringSort >) -> KExpr <KIntSort >
@@ -80,6 +83,32 @@ inline fun KContext.simplifyStringLenExpr(
8083 cont(arg)
8184 }
8285
86+ /*
87+ * SuffixOf and PrefixOf expression simplifications
88+ * */
89+
90+ /* * Simplifies string suffix checking expressions
91+ * (str_suffix_of strConst1 strConst2) ==> boolConst */
92+ inline fun KContext.simplifyStringBasicSuffixOfExpr (
93+ arg0 : KExpr <KStringSort >,
94+ arg1 : KExpr <KStringSort >,
95+ cont : (KExpr <KStringSort >, KExpr <KStringSort >) -> KExpr <KBoolSort >
96+ ): KExpr <KBoolSort > =
97+ tryEvalStringLiteralOperation(arg0, arg1, { a0, a1 -> StringUtils .isStringSuffix(a0, a1) }) {
98+ cont(arg0, arg1)
99+ }
100+
101+ /* * Simplifies string prefix checking expressions
102+ * (str_prefix_of strConst1 strConst2) ==> boolConst */
103+ inline fun KContext.simplifyStringBasicPrefixOfExpr (
104+ arg0 : KExpr <KStringSort >,
105+ arg1 : KExpr <KStringSort >,
106+ cont : (KExpr <KStringSort >, KExpr <KStringSort >) -> KExpr <KBoolSort >
107+ ): KExpr <KBoolSort > =
108+ tryEvalStringLiteralOperation(arg0, arg1, { a0, a1 -> StringUtils .isStringPrefix(a0, a1) }) {
109+ cont(arg0, arg1)
110+ }
111+
83112inline fun <K : KSort > tryEvalStringLiteralOperation (
84113 arg : KExpr <KStringSort >,
85114 operation : (KStringLiteralExpr ) -> KInterpretedValue <K >,
0 commit comments