From 7cece7f07c8533b4ad97c7c57e7efc0d609d2d79 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 12:03:08 +0200 Subject: [PATCH 01/10] Added spotless for java --- buildSrc/build.gradle.kts | 2 ++ buildSrc/gradle.properties | 3 ++- .../src/main/kotlin/java-common.gradle.kts | 25 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5b1c79903a..f731f11685 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -30,6 +30,7 @@ apply(from = rootDir.resolve("../gradle/shared-with-buildSrc/mirrors.gradle.kts" val kotlinVersion: String by project val shadowVersion: String by project +val spotlessVersion: String by project // https://github.com/gradle/kotlin-dsl/issues/430#issuecomment-414768887 fun gradlePlugin(id: String, version: String): String = "$id:$id.gradle.plugin:$version" @@ -38,6 +39,7 @@ dependencies { compileOnly(gradleKotlinDsl()) implementation(kotlin("gradle-plugin", kotlinVersion)) implementation(gradlePlugin("com.github.johnrengelman.shadow", shadowVersion)) + implementation(gradlePlugin("com.diffplug.spotless", spotlessVersion)) } // Force the embeddable Kotlin compiler version to be the selected kotlinVersion. diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index e9c71bc25e..48f1a02d7d 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -39,4 +39,5 @@ deltaCollectionsVersion=0.0.1 gsonVersion=2.9.1 javasmtVersion=4.1.1 sosylabVersion=0.3000-569-g89796f98 -cliktVersion=4.4.0 \ No newline at end of file +cliktVersion=4.4.0 +spotlessVersion=7.0.0.BETA3 \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/java-common.gradle.kts b/buildSrc/src/main/kotlin/java-common.gradle.kts index 96ffbd8ec6..4c1438291f 100644 --- a/buildSrc/src/main/kotlin/java-common.gradle.kts +++ b/buildSrc/src/main/kotlin/java-common.gradle.kts @@ -17,6 +17,7 @@ plugins { java id("jacoco-common") id("maven-artifact") + id("com.diffplug.spotless") } dependencies { @@ -65,3 +66,27 @@ tasks { jvmArgs("-Xss5m", "-Xms512m", "-Xmx1g") } } + +spotless { + java { + // apply a specific flavor of google-java-format + googleJavaFormat("1.8").aosp().reflowLongStrings().skipJavadocFormatting() + // fix formatting of type annotations + formatAnnotations() + licenseHeader( + """ Copyright $(YEAR) Budapest University of Technology and Economics + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.""".trimIndent() + ) + } +} \ No newline at end of file From 1aed01bfe0fa521a3a8d4721bc5d2925b0725d12 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 13:02:46 +0200 Subject: [PATCH 02/10] Initial java formatting --- build.gradle.kts | 3 ++- buildSrc/build.gradle.kts | 2 +- buildSrc/gradle.properties | 2 +- buildSrc/src/main/kotlin/java-common.gradle.kts | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 108baa86d1..7c35deef20 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + plugins { base id("jacoco-common") @@ -88,4 +89,4 @@ tasks { username = System.getenv("OSSRH_USERNAME") password = System.getenv("OSSRH_PASSWORD") } -} +} \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index f731f11685..17bd8d751c 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -106,4 +106,4 @@ tasks { named("compileKotlin", KotlinCompile::class) { dependsOn(generateVersions) } -} +} \ No newline at end of file diff --git a/buildSrc/gradle.properties b/buildSrc/gradle.properties index 48f1a02d7d..77da25281b 100644 --- a/buildSrc/gradle.properties +++ b/buildSrc/gradle.properties @@ -40,4 +40,4 @@ gsonVersion=2.9.1 javasmtVersion=4.1.1 sosylabVersion=0.3000-569-g89796f98 cliktVersion=4.4.0 -spotlessVersion=7.0.0.BETA3 \ No newline at end of file +spotlessVersion=6.25.0 \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/java-common.gradle.kts b/buildSrc/src/main/kotlin/java-common.gradle.kts index 4c1438291f..3700580aa8 100644 --- a/buildSrc/src/main/kotlin/java-common.gradle.kts +++ b/buildSrc/src/main/kotlin/java-common.gradle.kts @@ -70,7 +70,7 @@ tasks { spotless { java { // apply a specific flavor of google-java-format - googleJavaFormat("1.8").aosp().reflowLongStrings().skipJavadocFormatting() + googleJavaFormat("1.24.0").aosp().reflowLongStrings() // fix formatting of type annotations formatAnnotations() licenseHeader( From 81228be5bc593e9ee4c0e85a830923a13a38e4f8 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 13:24:14 +0200 Subject: [PATCH 03/10] Added kotlin and kotlin-script formatting Finalized formatting script --- .../src/main/kotlin/java-common.gradle.kts | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/buildSrc/src/main/kotlin/java-common.gradle.kts b/buildSrc/src/main/kotlin/java-common.gradle.kts index 3700580aa8..1eb2c30393 100644 --- a/buildSrc/src/main/kotlin/java-common.gradle.kts +++ b/buildSrc/src/main/kotlin/java-common.gradle.kts @@ -68,25 +68,42 @@ tasks { } spotless { + ratchetFrom("origin/master") + + val year = "\$YEAR" // you can't escape $ in raw strings.. + val licenseHeader = """ /* + * Copyright $year Budapest University of Technology and Economics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */""".trimIndent() + + java { - // apply a specific flavor of google-java-format + importOrder("java|javax", "hu.bme.", "") + removeUnusedImports() googleJavaFormat("1.24.0").aosp().reflowLongStrings() - // fix formatting of type annotations formatAnnotations() - licenseHeader( - """ Copyright $(YEAR) Budapest University of Technology and Economics - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at + licenseHeader(licenseHeader) + } + kotlin { + ktfmt("0.51").googleStyle() - http://www.apache.org/licenses/LICENSE-2.0 + licenseHeader(licenseHeader) + } + kotlinGradle { + target("*.gradle.kts") // default target for kotlinGradle - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License.""".trimIndent() - ) + ktlint() } } \ No newline at end of file From 35c33b8047fcf44fdb23712e07b5f4a688192c80 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:22:23 +0200 Subject: [PATCH 04/10] Revert "Reformatted code" This reverts commit e37b32302b2cb72893e26b52bc63d305e999a98f. Revert "Reformatted code" This reverts commit 185dc7ad29920254fc689ac68ff01952a1c65c5a. --- buildSrc/build.gradle.kts | 3 +- .../src/main/kotlin/maven-artifact.gradle.kts | 9 +- scripts/complex.kts | 324 +++------ scripts/simple.kts | 6 +- .../theta/cfa/analysis/CfaToMonolithicExpr.kt | 12 +- .../bounded/BoundedCheckerBuilder.kt | 18 +- .../analysis/algorithm/chc/HornChecker.kt | 3 +- .../analysis/algorithm/mcm/MemoryEvent.kt | 12 +- .../algorithm/mcm/analysis/PartialSolver.kt | 3 +- .../mit/theta/analysis/ptr/ItpRefToPtrPrec.kt | 6 +- .../bme/mit/theta/analysis/ptr/PtrAction.kt | 23 +- .../bme/mit/theta/analysis/ptr/PtrAnalysis.kt | 15 +- .../hu/bme/mit/theta/analysis/ptr/PtrUtils.kt | 40 +- .../analysis/runtimemonitor/CexMonitor.kt | 9 +- .../runtimemonitor/MonitorCheckpoint.kt | 3 +- .../mit/theta/analysis/multi/MultiInitFunc.kt | 2 +- .../theta/analysis/multi/MultiPartialOrd.kt | 2 +- .../theta/analysis/multi/MultiTransFunc.kt | 2 +- .../multi/builder/MultiBuilderResult.kt | 2 +- .../multi/builder/MultiControlInitFunc.kt | 2 +- .../theta/analysis/algorithm/BoundedTest.kt | 9 +- .../mit/theta/analysis/ptr/PtrAnalysisTest.kt | 37 +- .../java/hu/bme/mit/theta/core/ChcUtils.kt | 6 +- .../hu/bme/mit/theta/grammar/dsl/Utils.kt | 6 +- .../mit/theta/grammar/dsl/expr/ExprParser.kt | 210 ++---- .../mit/theta/grammar/dsl/stmt/StmtParser.kt | 3 +- .../bme/mit/theta/grammar/gson/ArgAdapter.kt | 6 +- .../theta/grammar/gson/ArgAdapterHelper.kt | 9 +- .../theta/grammar/gson/SafetyResultAdapter.kt | 12 +- .../mit/theta/grammar/gson/StateAdapters.kt | 6 +- .../mit/theta/grammar/gson/TraceAdapter.kt | 18 +- .../mit/theta/grammar/gson/VarDeclAdapter.kt | 6 +- .../hu/bme/mit/theta/grammar/dsl/ExprTest.kt | 283 +++----- .../hu/bme/mit/theta/grammar/dsl/StmtTest.kt | 18 +- .../hu/bme/mit/theta/grammar/dsl/TypeTest.kt | 6 +- .../hu/bme/mit/theta/grammar/gson/TestGson.kt | 54 +- .../MultiNondetDiningPhilosophersTest.kt | 30 +- .../hu/bme/mit/theta/frontend/CStatistics.kt | 6 +- subprojects/frontends/llvm/build.gradle.kts | 30 +- .../compilers/DefaultGraphPatternCompiler.kt | 6 +- .../compilers/GraphPatternCompiler.kt | 6 +- .../pattern2expr/Pattern2ExprCompiler.kt | 24 +- .../mit/theta/graphsolver/GraphSolverTest.kt | 162 ++--- .../smtlib/GenericSmtLibHornSolverTest.kt | 7 +- .../mit/theta/solver/z3/Z3HornSolverTest.kt | 7 +- .../mit/theta/c2xcfa/FrontendXcfaBuilder.kt | 488 +++++--------- .../java/hu/bme/mit/theta/c2xcfa/Utils.kt | 6 +- .../hu/bme/mit/theta/cat/dsl/CatVisitor.kt | 3 +- subprojects/xcfa/llvm2xcfa/build.gradle.kts | 6 +- .../hu/bme/mit/theta/xcfa/analysis/Utils.kt | 3 +- .../mit/theta/xcfa/analysis/XcfaAbstractor.kt | 7 +- .../bme/mit/theta/xcfa/analysis/XcfaAction.kt | 12 +- .../mit/theta/xcfa/analysis/XcfaAnalysis.kt | 148 ++--- .../theta/xcfa/analysis/XcfaPrecRefiner.kt | 15 +- .../analysis/XcfaSingeExprTraceRefiner.kt | 13 +- .../bme/mit/theta/xcfa/analysis/XcfaState.kt | 125 ++-- .../theta/xcfa/analysis/XcfaStateAdapter.kt | 6 +- .../xcfa/analysis/XcfaToMonolithicExpr.kt | 36 +- .../xcfa/analysis/coi/XcfaCoiMultiThread.kt | 6 +- .../theta/xcfa/analysis/oc/XcfaOcChecker.kt | 6 +- .../xcfa/analysis/oc/XcfaOcTraceExtractor.kt | 24 +- .../theta/xcfa/analysis/por/XcfaDporLts.kt | 7 +- .../xcfa/analysis/XcfaExplAnalysisTest.kt | 97 +-- .../xcfa/analysis/XcfaPredAnalysisTest.kt | 100 +-- .../theta/xcfa/analysis/XcfaStateLtsTest.kt | 3 +- .../bme/mit/theta/xcfa/cli/ExecuteConfig.kt | 26 +- .../cli/checkers/ConfigToBoundedChecker.kt | 24 +- .../xcfa/cli/checkers/ConfigToCegarChecker.kt | 45 +- .../xcfa/cli/checkers/ConfigToChecker.kt | 6 +- .../xcfa/cli/checkers/ConfigToOcChecker.kt | 12 +- .../xcfa/cli/checkers/ConfigToPortfolio.kt | 71 +- .../xcfa/cli/checkers/InProcessChecker.kt | 31 +- .../mit/theta/xcfa/cli/params/ParamValues.kt | 45 +- .../mit/theta/xcfa/cli/params/XcfaConfig.kt | 108 +-- .../mit/theta/xcfa/cli/portfolio/bounded.kt | 98 +-- .../mit/theta/xcfa/cli/portfolio/complex23.kt | 507 +++++--------- .../mit/theta/xcfa/cli/portfolio/complex24.kt | 616 ++++++------------ .../bme/mit/theta/xcfa/cli/portfolio/horn.kt | 44 +- .../bme/mit/theta/xcfa/cli/portfolio/stm.kt | 29 +- .../bme/mit/theta/xcfa/cli/utils/GsonUtils.kt | 54 +- .../mit/theta/xcfa/cli/utils/PropertyUtils.kt | 6 +- .../mit/theta/xcfa/cli/utils/XcfaParser.kt | 79 +-- .../theta/xcfa/cli/utils/XcfaWitnessWriter.kt | 93 +-- .../xcfa/cli/witnesses/TraceToWitness.kt | 39 +- .../mit/theta/xcfa/cli/witnesses/Witness.kt | 17 +- .../mit/theta/xcfa/cli/XcfaCliParseTest.kt | 136 ++-- .../theta/xcfa/cli/XcfaCliPortfolioTest.kt | 22 +- .../mit/theta/xcfa/cli/XcfaCliVerifyTest.kt | 24 +- .../mit/theta/xcfa/cli/XcfaCliWitnessTest.kt | 40 +- .../hu/bme/mit/theta/xcfa/cli/XcfaDslTest.kt | 15 +- .../hu/bme/mit/theta/xcfa/cli/XcfaToCTest.kt | 12 +- .../xcfa-cli/src/test/resources/simple.kts | 16 +- .../main/java/hu/bme/mit/theta/xcfa/Utils.kt | 36 +- .../java/hu/bme/mit/theta/xcfa/XcfaToC.kt | 6 +- .../hu/bme/mit/theta/xcfa/gson/XcfaAdapter.kt | 9 +- .../mit/theta/xcfa/gson/XcfaLabelAdapter.kt | 9 +- .../java/hu/bme/mit/theta/xcfa/model/Dsl.kt | 49 +- .../hu/bme/mit/theta/xcfa/model/Visualizer.kt | 3 +- .../hu/bme/mit/theta/xcfa/model/XcfaLabel.kt | 33 +- .../xcfa/passes/AssumeFalseRemovalPass.kt | 3 +- .../xcfa/passes/AtomicReadsOneWritePass.kt | 9 +- .../xcfa/passes/CLibraryFunctionsPass.kt | 16 +- .../theta/xcfa/passes/ErrorLocationPass.kt | 7 +- .../xcfa/passes/FetchExecuteWriteback.kt | 56 +- .../theta/xcfa/passes/FinalLocationPass.kt | 18 +- .../xcfa/passes/FpFunctionsToExprsPass.kt | 286 +++----- .../xcfa/passes/HavocPromotionAndRange.kt | 15 +- .../theta/xcfa/passes/InlineProceduresPass.kt | 40 +- .../hu/bme/mit/theta/xcfa/passes/LbePass.kt | 18 +- .../theta/xcfa/passes/MallocFunctionPass.kt | 42 +- .../mit/theta/xcfa/passes/NoSideEffectPass.kt | 4 +- .../theta/xcfa/passes/NondetFunctionPass.kt | 16 +- .../mit/theta/xcfa/passes/NormalizePass.kt | 4 +- .../theta/xcfa/passes/ProcedurePassManager.kt | 44 +- .../theta/xcfa/passes/ReferenceElimination.kt | 104 +-- .../theta/xcfa/passes/SvCompIntrinsicsPass.kt | 19 +- .../mit/theta/xcfa/passes/UnusedVarPass.kt | 6 +- .../hu/bme/mit/theta/xcfa/passes/Utils.kt | 66 +- .../hu/bme/mit/theta/xcfa/gson/GsonTest.kt | 24 +- .../hu/bme/mit/theta/xcfa/passes/PassTests.kt | 31 +- .../hu/bme/mit/theta/xcfa/passes/UtilsTest.kt | 36 +- .../hu/bme/mit/theta/xcfa2chc/TestChcUtils.kt | 112 ++-- .../theta/xsts/analysis/XstsToRelations.kt | 3 +- .../theta/xsts/analysis/util/RandomXsts.kt | 54 +- .../xsts/analysis/util/XstsSerializer.kt | 3 +- .../mit/theta/xsts/utils/XSTSVarChanger.kt | 6 +- 126 files changed, 2007 insertions(+), 3969 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 17bd8d751c..7b1e3380f6 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -46,8 +46,7 @@ dependencies { // https://github.com/gradle/kotlin-dsl/issues/1207 configurations.all { val isKotlinCompiler = name == "embeddedKotlin" || name.startsWith("kotlin") || name.startsWith( - "kapt" - ) + "kapt") if (!isKotlinCompiler) { resolutionStrategy.eachDependency { if (requested.group == "org.jetbrains.kotlin" && requested.module.name == "kotlin-compiler-embeddable") { diff --git a/buildSrc/src/main/kotlin/maven-artifact.gradle.kts b/buildSrc/src/main/kotlin/maven-artifact.gradle.kts index acb489be5d..95ddb2d588 100644 --- a/buildSrc/src/main/kotlin/maven-artifact.gradle.kts +++ b/buildSrc/src/main/kotlin/maven-artifact.gradle.kts @@ -107,14 +107,11 @@ tasks { repositories { maven { val releasesRepoUrl = uri( - "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" - ) + "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") val snapshotsRepoUrl = uri( - "https://s01.oss.sonatype.org/content/repositories/snapshots/" - ) + "https://s01.oss.sonatype.org/content/repositories/snapshots/") url = if (version.toString() - .endsWith("SNAPSHOT") - ) snapshotsRepoUrl else releasesRepoUrl + .endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl credentials { username = System.getenv("OSSRH_USERNAME") password = System.getenv("OSSRH_PASSWORD") diff --git a/scripts/complex.kts b/scripts/complex.kts index 98e5e6d073..b90d3907cc 100644 --- a/scripts/complex.kts +++ b/scripts/complex.kts @@ -89,60 +89,38 @@ val predConfig = baseConfig.copy(domain = Domain.PRED_CART, refinement = Refinem fun integerStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_z3_4.10.1_$inProcess", - quickExplConfig.copy( - abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_2_1 = ConfigNode( - "EmptyExpl_z3_4.10.1_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_3_1 = ConfigNode( - "PredCart_z3_4.10.1_$inProcess", - predConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1"), checker, inProcess - ) + val config_1_1 = ConfigNode("QuickFullExpl_z3_4.10.1_$inProcess", + quickExplConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_1 = ConfigNode("EmptyExpl_z3_4.10.1_$inProcess", + emptyExplConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_3_1 = ConfigNode("PredCart_z3_4.10.1_$inProcess", + predConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1"), checker, inProcess) val config_1_2 = ConfigNode("QuickFullExpl_Z3_$inProcess", quickExplConfig.copy(), checker, inProcess) val config_2_2 = ConfigNode("EmptyExpl_Z3_$inProcess", emptyExplConfig.copy(), checker, inProcess) val config_3_2 = ConfigNode("PredCart_Z3_$inProcess", predConfig.copy(), checker, inProcess) - val config_1_3 = ConfigNode( - "QuickFullExpl_princess_2022_07_01_$inProcess", + val config_1_3 = ConfigNode("QuickFullExpl_princess_2022_07_01_$inProcess", quickExplConfig.copy(abstractionSolver = "princess:2022-07-01", refinementSolver = "princess:2022-07-01"), - checker, inProcess - ) - val config_2_3 = ConfigNode( - "EmptyExpl_princess_2022_07_01_$inProcess", + checker, inProcess) + val config_2_3 = ConfigNode("EmptyExpl_princess_2022_07_01_$inProcess", emptyExplConfig.copy(abstractionSolver = "princess:2022-07-01", refinementSolver = "princess:2022-07-01"), - checker, inProcess - ) - val config_3_3 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", + checker, inProcess) + val config_3_3 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", predConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8"), checker, - inProcess - ) + inProcess) - val config_1_4 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", + val config_1_4 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", quickExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8"), checker, - inProcess - ) - val config_2_4 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", + inProcess) + val config_2_4 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", emptyExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8"), checker, - inProcess - ) - val config_3_4 = ConfigNode( - "PredCart_princess_2022_07_01_$inProcess", + inProcess) + val config_3_4 = ConfigNode("PredCart_princess_2022_07_01_$inProcess", predConfig.copy(abstractionSolver = "princess:2022-07-01", refinementSolver = "princess:2022-07-01"), - checker, inProcess - ) + checker, inProcess) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -158,13 +136,9 @@ fun integerStm(): STM { Edge(config_2_4, config_3_1, if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), @@ -192,60 +166,32 @@ fun integerStm(): STM { fun bitwiseStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_Z3_$inProcess", - quickExplConfig.copy(refinement = Refinement.NWT_IT_WP), checker, inProcess - ) - val config_2_1 = ConfigNode( - "EmptyExpl_Z3_$inProcess", emptyExplConfig.copy(refinement = Refinement.NWT_IT_WP), - checker, inProcess - ) - val config_3_1 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", + val config_1_1 = ConfigNode("QuickFullExpl_Z3_$inProcess", + quickExplConfig.copy(refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_1 = ConfigNode("EmptyExpl_Z3_$inProcess", emptyExplConfig.copy(refinement = Refinement.NWT_IT_WP), + checker, inProcess) + val config_3_1 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", predConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8"), checker, - inProcess - ) - - val config_1_2 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_2_2 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_3_2 = ConfigNode( - "PredCart_z3_4.10.1_$inProcess", - predConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1"), checker, inProcess - ) - - val config_1_3 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", - quickExplConfig.copy( - abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_2_3 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - refinement = Refinement.SEQ_ITP - ), checker, inProcess - ) - val config_3_3 = ConfigNode( - "PredCart_cvc5_1.0.2_$inProcess", - predConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) + inProcess) + + val config_1_2 = ConfigNode("QuickFullExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_2 = ConfigNode("EmptyExpl_cvc5_1.0.2_$inProcess", + emptyExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_3_2 = ConfigNode("PredCart_z3_4.10.1_$inProcess", + predConfig.copy(abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1"), checker, inProcess) + + val config_1_3 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", + quickExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_3 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", + emptyExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", + refinement = Refinement.SEQ_ITP), checker, inProcess) + val config_3_3 = ConfigNode("PredCart_cvc5_1.0.2_$inProcess", + predConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -258,13 +204,9 @@ fun bitwiseStm(): STM { Edge(config_2_3, config_3_1, if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), @@ -289,113 +231,57 @@ fun bitwiseStm(): STM { fun floatsStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_2_1 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_3_1 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", + val config_1_1 = ConfigNode("QuickFullExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_1 = ConfigNode("EmptyExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_3_1 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", predConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8"), checker, - inProcess - ) - - val config_1_2 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_seq_$inProcess", - quickExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.SEQ_ITP - ), checker, inProcess - ) - val config_2_2 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_seq_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.SEQ_ITP - ), checker, inProcess - ) - val config_3_2 = ConfigNode( - "PredCart_bitwuzla_latest_$inProcess", - predConfig.copy( - abstractionSolver = "bitwuzla:latest", refinementSolver = "bitwuzla:latest", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - - val config_1_3 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", - quickExplConfig.copy( - abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - validateAbstractionSolver = true, validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), - checker, inProcess - ) - val config_2_3 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - validateAbstractionSolver = true, validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), - checker, inProcess - ) - val config_3_3 = ConfigNode( - "PredCart_cvc5_1.0.2_$inProcess", - predConfig.copy( - abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - - val config_1_4 = ConfigNode( - "QuickFullExpl_mathsat_fp_$inProcess", - quickExplConfig.copy( - abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker, inProcess - ) - val config_2_4 = ConfigNode( - "EmptyExpl_mathsat_fp_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker, inProcess - ) - val config_3_4 = ConfigNode( - "PredCart_mathsat_fp_$inProcess", - predConfig.copy( - abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker, inProcess - ) - - val config_1_5 = ConfigNode( - "QuickFullExpl_Z3_$inProcess", - quickExplConfig.copy( - abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, - validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_2_5 = ConfigNode( - "EmptyExpl_Z3_$inProcess", - emptyExplConfig.copy( - abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, - validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), checker, inProcess - ) - val config_3_5 = ConfigNode( - "PredCart_Z3_$inProcess", + inProcess) + + val config_1_2 = ConfigNode("QuickFullExpl_cvc5_1.0.2_seq_$inProcess", + quickExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.SEQ_ITP), checker, inProcess) + val config_2_2 = ConfigNode("EmptyExpl_cvc5_1.0.2_seq_$inProcess", + emptyExplConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.SEQ_ITP), checker, inProcess) + val config_3_2 = ConfigNode("PredCart_bitwuzla_latest_$inProcess", + predConfig.copy(abstractionSolver = "bitwuzla:latest", refinementSolver = "bitwuzla:latest", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + + val config_1_3 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", + quickExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", + validateAbstractionSolver = true, validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), + checker, inProcess) + val config_2_3 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", + emptyExplConfig.copy(abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", + validateAbstractionSolver = true, validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), + checker, inProcess) + val config_3_3 = ConfigNode("PredCart_cvc5_1.0.2_$inProcess", + predConfig.copy(abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker, inProcess) + + val config_1_4 = ConfigNode("QuickFullExpl_mathsat_fp_$inProcess", + quickExplConfig.copy(abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", + validateAbstractionSolver = true, validateRefinementSolver = true), checker, inProcess) + val config_2_4 = ConfigNode("EmptyExpl_mathsat_fp_$inProcess", + emptyExplConfig.copy(abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", + validateAbstractionSolver = true, validateRefinementSolver = true), checker, inProcess) + val config_3_4 = ConfigNode("PredCart_mathsat_fp_$inProcess", + predConfig.copy(abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", + validateAbstractionSolver = true, validateRefinementSolver = true), checker, inProcess) + + val config_1_5 = ConfigNode("QuickFullExpl_Z3_$inProcess", + quickExplConfig.copy(abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, + validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_2_5 = ConfigNode("EmptyExpl_Z3_$inProcess", + emptyExplConfig.copy(abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, + validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), checker, inProcess) + val config_3_5 = ConfigNode("PredCart_Z3_$inProcess", predConfig.copy(abstractionSolver = "Z3", refinementSolver = "Z3", refinement = Refinement.NWT_IT_WP), - checker, inProcess - ) + checker, inProcess) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -414,13 +300,9 @@ fun floatsStm(): STM { Edge(config_2_5, config_3_1, if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), diff --git a/scripts/simple.kts b/scripts/simple.kts index da95633e75..78c2678a13 100644 --- a/scripts/simple.kts +++ b/scripts/simple.kts @@ -47,10 +47,8 @@ var baseConfig = XcfaCegarConfig( ) if (traitsTyped.multithreaded) { - baseConfig = baseConfig.copy( - search = Search.BFS, porLevel = POR.AAPOR, - pruneStrategy = PruneStrategy.LAZY - ) + baseConfig = baseConfig.copy(search = Search.BFS, porLevel = POR.AAPOR, + pruneStrategy = PruneStrategy.LAZY) if (propertyTyped == ErrorDetection.DATA_RACE) { baseConfig = baseConfig.copy(porLevel = POR.BASIC) diff --git a/subprojects/cfa/cfa-analysis/src/main/kotlin/hu/bme/mit/theta/cfa/analysis/CfaToMonolithicExpr.kt b/subprojects/cfa/cfa-analysis/src/main/kotlin/hu/bme/mit/theta/cfa/analysis/CfaToMonolithicExpr.kt index 1164bb66af..ca6c125314 100644 --- a/subprojects/cfa/cfa-analysis/src/main/kotlin/hu/bme/mit/theta/cfa/analysis/CfaToMonolithicExpr.kt +++ b/subprojects/cfa/cfa-analysis/src/main/kotlin/hu/bme/mit/theta/cfa/analysis/CfaToMonolithicExpr.kt @@ -41,13 +41,11 @@ fun CFA.toMonolithicExpr(): MonolithicExpr { } val locVar = Decls.Var("__loc__", Int()) val tranList = this.edges.map { e -> - SequenceStmt.of( - listOf( - AssumeStmt.of(Eq(locVar.ref, Int(map[e.source]!!))), - e.stmt, - AssignStmt.of(locVar, Int(map[e.target]!!)) - ) - ) + SequenceStmt.of(listOf( + AssumeStmt.of(Eq(locVar.ref, Int(map[e.source]!!))), + e.stmt, + AssignStmt.of(locVar, Int(map[e.target]!!)) + )) }.toList() val trans = NonDetStmt.of(tranList); val transUnfold = StmtUtils.toExpr(trans, VarIndexingFactory.indexing(0)); diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/bounded/BoundedCheckerBuilder.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/bounded/BoundedCheckerBuilder.kt index 03de89fb27..bfd1aeadf9 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/bounded/BoundedCheckerBuilder.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/bounded/BoundedCheckerBuilder.kt @@ -34,10 +34,8 @@ fun buildBMC( bmcEnabled: () -> Boolean = { true }, lfPathOnly: () -> Boolean = { true }, ): BoundedChecker { - return BoundedChecker( - monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, null, { false }, null, - { false }, valToState, biValToAction, logger - ) + return BoundedChecker(monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, null, { false }, null, + { false }, valToState, biValToAction, logger) } @JvmOverloads @@ -53,10 +51,8 @@ fun buildKIND( lfPathOnly: () -> Boolean = { true }, kindEnabled: (Int) -> Boolean = { true }, ): BoundedChecker { - return BoundedChecker( - monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, null, { false }, indSolver, - kindEnabled, valToState, biValToAction, logger - ) + return BoundedChecker(monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, null, { false }, indSolver, + kindEnabled, valToState, biValToAction, logger) } @JvmOverloads @@ -72,8 +68,6 @@ fun buildIMC( lfPathOnly: () -> Boolean = { true }, imcEnabled: (Int) -> Boolean = { true }, ): BoundedChecker { - return BoundedChecker( - monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, itpSolver, imcEnabled, null, - { false }, valToState, biValToAction, logger - ) + return BoundedChecker(monolithicExpr, shouldGiveUp, bmcSolver, bmcEnabled, lfPathOnly, itpSolver, imcEnabled, null, + { false }, valToState, biValToAction, logger) } \ No newline at end of file diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/chc/HornChecker.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/chc/HornChecker.kt index 8630eed180..0c083b7cd0 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/chc/HornChecker.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/chc/HornChecker.kt @@ -68,8 +68,7 @@ class HornChecker( logger.write(Logger.Level.MAINSTEP, "Proof (model) found\n") val model = solver.model.toMap() SafetyResult.safe( - Invariant(relations.associateWith { model[it.constDecl] as? Expr ?: True() }) - ) + Invariant(relations.associateWith { model[it.constDecl] as? Expr ?: True() })) } SolverStatus.UNSAT -> { diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/MemoryEvent.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/MemoryEvent.kt index eeb9b794a4..d10f26e4d1 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/MemoryEvent.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/MemoryEvent.kt @@ -52,10 +52,8 @@ open class MemoryEvent(protected val type: MemoryEventType, protected val tag: S throw UnsupportedOperationException("Not memory IO!") } - abstract class MemoryIO( - id: Int, private val `var`: VarDecl<*>, private val localVar: VarDecl<*>, - type: MemoryEventType, tag: String - ) : + abstract class MemoryIO(id: Int, private val `var`: VarDecl<*>, private val localVar: VarDecl<*>, + type: MemoryEventType, tag: String) : MemoryEvent(type, tag, id) { override fun asMemoryIO(): MemoryIO { @@ -88,10 +86,8 @@ open class MemoryEvent(protected val type: MemoryEventType, protected val tag: S } } - class Write( - id: Int, `var`: VarDecl<*>, localVar: VarDecl<*>, private val dependencies: Set>, - tag: String - ) : + class Write(id: Int, `var`: VarDecl<*>, localVar: VarDecl<*>, private val dependencies: Set>, + tag: String) : MemoryIO(id, `var`, localVar, MemoryEventType.WRITE, tag) { override fun asWrite(): Write { diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/analysis/PartialSolver.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/analysis/PartialSolver.kt index 24b877d848..a0257bb216 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/analysis/PartialSolver.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/algorithm/mcm/analysis/PartialSolver.kt @@ -54,6 +54,5 @@ class PartialSolver( data class CandidateExecutionGraph( val nodes: List, - val knownEvents: Map, ThreeVL> -) { + val knownEvents: Map, ThreeVL>) { } \ No newline at end of file diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/ItpRefToPtrPrec.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/ItpRefToPtrPrec.kt index 6b17827bf2..c3ec804041 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/ItpRefToPtrPrec.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/ItpRefToPtrPrec.kt @@ -30,10 +30,8 @@ class ItpRefToPtrPrec

(private val innerRefToPrec: RefutationToPrec { val newDerefs = refutation[index].dereferences val innerPrec = innerRefToPrec.toPrec(refutation, index).repatch() - return PtrPrec( - innerPrec, newDerefs.flatMap { it.ops }.toSet(), - if (newDerefs.isEmpty()) 0 else refutation.size() - index - ) + return PtrPrec(innerPrec, newDerefs.flatMap { it.ops }.toSet(), + if (newDerefs.isEmpty()) 0 else refutation.size() - index) } override fun join(prec1: PtrPrec

, prec2: PtrPrec

): PtrPrec

{ diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAction.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAction.kt index 4dee747bb0..015084a889 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAction.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAction.kt @@ -61,30 +61,19 @@ abstract class PtrAction(writeTriples: WriteTriples = emptyMap(), val inCnt: Int val postList = ArrayList() for ((deref, type) in stmt.dereferencesWithAccessTypes) { - Preconditions.checkState( - deref.uniquenessIdx.isPresent, - "Incomplete dereferences (missing uniquenessIdx) are not handled properly." - ) + Preconditions.checkState(deref.uniquenessIdx.isPresent, + "Incomplete dereferences (missing uniquenessIdx) are not handled properly.") val expr = deref.getIte(nextWriteTriples) if (type == AccessType.WRITE) { val writeExpr = ExprUtils.simplify(IntExprs.Add(expr, IntExprs.Int(1))) nextWriteTriples.getOrPut(deref.type) { ArrayList() } .add(Triple(lookup[deref]!!.first, lookup[deref]!!.second, deref.uniquenessIdx.get())) - postList.add( - Stmts.Assume( - ExprUtils.simplify( - BoolExprs.And( - listOf( - AbstractExprs.Eq(writeExpr, deref.uniquenessIdx.get()), - ) - ) - ) - ) - ) + postList.add(Stmts.Assume(ExprUtils.simplify(BoolExprs.And(listOf( + AbstractExprs.Eq(writeExpr, deref.uniquenessIdx.get()), + ))))) } else { preList.add( - Stmts.Assume(ExprUtils.simplify(AbstractExprs.Eq(expr, deref.uniquenessIdx.get()))) - ) + Stmts.Assume(ExprUtils.simplify(AbstractExprs.Eq(expr, deref.uniquenessIdx.get())))) } // postList.add(Stmts.Assume(Eq(vargen("value", deref.type).ref, deref))) // debug mode } diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysis.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysis.kt index 881fecb5bb..4eb29ec625 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysis.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysis.kt @@ -35,20 +35,16 @@ import hu.bme.mit.theta.core.stmt.Stmt * */ -class PtrAnalysis( - private val innerAnalysis: Analysis, - private val isHavoc: Boolean = false -) : +class PtrAnalysis(private val innerAnalysis: Analysis, + private val isHavoc: Boolean = false) : Analysis, PtrAction, PtrPrec

> { override fun getPartialOrd(): PartialOrd> = innerAnalysis.partialOrd.getPtrPartialOrd() override fun getInitFunc(): InitFunc, PtrPrec

> = innerAnalysis.initFunc.getPtrInitFunc() - override fun getTransFunc(): TransFunc, PtrAction, PtrPrec

> = - innerAnalysis.transFunc.getPtrTransFunc( - isHavoc - ) + override fun getTransFunc(): TransFunc, PtrAction, PtrPrec

> = innerAnalysis.transFunc.getPtrTransFunc( + isHavoc) } fun PartialOrd.getPtrPartialOrd(): PartialOrd> = PartialOrd { state1, state2 -> @@ -60,8 +56,7 @@ fun InitFunc.getPtrInitFunc(): InitFunc TransFunc.getPtrTransFunc( - isHavoc: Boolean = false -): TransFunc, PtrAction, PtrPrec

> = TransFunc { state, action, prec -> + isHavoc: Boolean = false): TransFunc, PtrAction, PtrPrec

> = TransFunc { state, action, prec -> val writeTriples = action.nextWriteTriples() val patchedPrec = prec.innerPrec.patch(writeTriples) val exprAction: ExprAction = if (isHavoc) { diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrUtils.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrUtils.kt index e051625334..3cc08a0cf1 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrUtils.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/ptr/PtrUtils.kt @@ -53,8 +53,7 @@ enum class AccessType { val Stmt.dereferencesWithAccessTypes: List, AccessType>> get() = when (this) { is MemoryAssignStmt<*, *, *> -> expr.dereferences.map { Pair(it, AccessType.READ) } + listOf( - Pair(deref, AccessType.WRITE) - ) + deref.ops.flatMap { it.dereferences }.map { Pair(it, AccessType.READ) } + Pair(deref, AccessType.WRITE)) + deref.ops.flatMap { it.dereferences }.map { Pair(it, AccessType.READ) } is AssignStmt<*> -> expr.dereferences.map { Pair(it, AccessType.READ) } is AssumeStmt -> cond.dereferences.map { Pair(it, AccessType.READ) } @@ -84,23 +83,19 @@ fun SequenceStmt.collapse(): Stmt = this } -fun Stmt.uniqueDereferences( - vargen: (String, Type) -> VarDecl<*>, - lookup: MutableMap, Pair, Expr<*>>> -): Stmt { +fun Stmt.uniqueDereferences(vargen: (String, Type) -> VarDecl<*>, + lookup: MutableMap, Pair, Expr<*>>>): Stmt { val ret = ArrayList() val newStmt = when (this) { is MemoryAssignStmt<*, *, *> -> { MemoryAssignStmt.create( deref.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second as Dereference<*, *, *>, - expr.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second - ) + expr.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second) } is AssignStmt<*> -> AssignStmt.of( TypeUtils.cast(varDecl, varDecl.type), - TypeUtils.cast(expr.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second, varDecl.type) - ) + TypeUtils.cast(expr.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second, varDecl.type)) is AssumeStmt -> AssumeStmt.of(cond.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second) is SequenceStmt -> Stmts.SequenceStmt(stmts.map { it.uniqueDereferences(vargen, lookup) }) @@ -114,16 +109,13 @@ fun Stmt.uniqueDereferences( return SequenceStmt.of(ret + newStmt).collapse() } -fun Expr.uniqueDereferences( - vargen: (String, Type) -> VarDecl<*>, - lookup: MutableMap, Pair, Expr<*>>> -): Pair, Expr> = +fun Expr.uniqueDereferences(vargen: (String, Type) -> VarDecl<*>, + lookup: MutableMap, Pair, Expr<*>>>): Pair, Expr> = if (this is Dereference<*, *, T>) { val ret = ArrayList() Preconditions.checkState(this.uniquenessIdx.isEmpty, "Only non-pretransformed dereferences should be here") val arrayExpr = ExprUtils.simplify( - array.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second - ) + array.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second) val arrayLaterRef = if (arrayExpr !is LitExpr<*>) { val arrayConst = vargen("a", array.type).ref ret.add(Assume(Eq(arrayConst, arrayExpr))) @@ -132,8 +124,7 @@ fun Expr.uniqueDereferences( arrayExpr } val offsetExpr = ExprUtils.simplify( - offset.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second - ) + offset.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second) val offsetLaterRef = if (offsetExpr !is LitExpr<*>) { val offsetConst = vargen("o", offset.type).ref ret.add(Assume(Eq(offsetConst, offsetExpr))) @@ -149,10 +140,8 @@ fun Expr.uniqueDereferences( Pair(ret, retDeref) } else { val ret = ArrayList() - Pair( - ret, - this.withOps(this.ops.map { it.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second }) - ) + Pair(ret, + this.withOps(this.ops.map { it.uniqueDereferences(vargen, lookup).also { ret.addAll(it.first) }.second })) } object TopCollection : Set> { @@ -179,11 +168,8 @@ enum class PtrTracking { fun Dereference.getIte(writeTriples: WriteTriples): Expr { val list = writeTriples[type] ?: emptyList() return list.fold(Int(0) as Expr) { elze, (arr, off, value) -> - IteExpr.of( - BoolExprs.And( - listOf(Eq(arr, array), Eq(off, offset)) - ), value, elze - ) + IteExpr.of(BoolExprs.And( + listOf(Eq(arr, array), Eq(off, offset))), value, elze) } } diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/CexMonitor.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/CexMonitor.kt index 95069ed1c1..32c78c9b0e 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/CexMonitor.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/CexMonitor.kt @@ -39,10 +39,8 @@ class CexMonitor constructor( fun checkIfNewCexFound(): Boolean { return if (arg.cexs.anyMatch { cex -> !cexHashStorage.contains(cex) }) { - logger.write( - Logger.Level.VERBOSE, - "Counterexample hash check: new cex found successfully\n" - ) + logger.write(Logger.Level.VERBOSE, + "Counterexample hash check: new cex found successfully\n") true } else { logger.write(Logger.Level.INFO, "Counterexample hash check: NO new cex found\n") @@ -67,8 +65,7 @@ class CexMonitor constructor( when (checkpointName) { "CegarChecker.unsafeARG" -> if (checkIfNewCexFound()) addNewCounterexample() else throwNotSolvable() else -> throw RuntimeException( - "Unknown checkpoint name in CexMonitor execution: $checkpointName" - ) + "Unknown checkpoint name in CexMonitor execution: $checkpointName") } } } diff --git a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/MonitorCheckpoint.kt b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/MonitorCheckpoint.kt index 7ddfe7adec..0e1faccd73 100644 --- a/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/MonitorCheckpoint.kt +++ b/subprojects/common/analysis/src/main/java/hu/bme/mit/theta/analysis/runtimemonitor/MonitorCheckpoint.kt @@ -52,8 +52,7 @@ class MonitorCheckpoint internal constructor(private val name: String) { assert(registeredCheckpoints.contains(checkpointName)) { "Checkpoint name $checkpointName was not registered (add it in MonitorCheckpoint.kt)" } // see checkpointNames above registeredCheckpoints[checkpointName]?.registerMonitor(m) ?: error( - "Checkpoint with name $checkpointName not found." - ) + "Checkpoint with name $checkpointName not found.") } fun execute(name: String) { diff --git a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiInitFunc.kt b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiInitFunc.kt index f3c1ab15ec..4d7e740082 100644 --- a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiInitFunc.kt +++ b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiInitFunc.kt @@ -22,7 +22,7 @@ import hu.bme.mit.theta.analysis.State class MultiInitFunc> - ( +( private val createInitialState: (LControl, RControl, DataState) -> MState, private val dataInitFunc: InitFunc, private val extractLeftControlPrec: (LPrec) -> LControlPrec, diff --git a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiPartialOrd.kt b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiPartialOrd.kt index b48b564c28..68b3c77b27 100644 --- a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiPartialOrd.kt +++ b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiPartialOrd.kt @@ -20,7 +20,7 @@ import hu.bme.mit.theta.analysis.State class MultiPartialOrd> - ( +( private val leftPartOrd: PartialOrd, private val leftCombineStates: (LControl, DataState) -> LState, private val rightPartOrd: PartialOrd, diff --git a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiTransFunc.kt b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiTransFunc.kt index 02021807d9..ffe72c9757 100644 --- a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiTransFunc.kt +++ b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/MultiTransFunc.kt @@ -24,7 +24,7 @@ class MultiTransFunc, MAction : MultiAction> - ( +( private val defineNextSide: (MState) -> MultiSide, private val createState: (LControl, RControl, DataState, MultiSide) -> MState, private val leftTransFunc: TransFunc, diff --git a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiBuilderResult.kt b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiBuilderResult.kt index d090ac8cb4..eea37fb1ce 100644 --- a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiBuilderResult.kt +++ b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiBuilderResult.kt @@ -33,7 +33,7 @@ import hu.bme.mit.theta.analysis.unit.UnitState * the whole IDE. For this reason, a POJO has to be used instead */ private data class MultiBuilderResult, MControlState : MultiState, MAction : MultiAction, MLts : MultiLts> - ( +( val side: MultiAnalysisSide, MultiPrec>, val lts: MLts ) diff --git a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiControlInitFunc.kt b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiControlInitFunc.kt index 6aa4f6614a..d094692eac 100644 --- a/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiControlInitFunc.kt +++ b/subprojects/common/analysis/src/main/kotlin/hu/bme/mit/theta/analysis/multi/builder/MultiControlInitFunc.kt @@ -28,7 +28,7 @@ import hu.bme.mit.theta.analysis.unit.UnitState * Serves as a control initial function for a multi analysis if the product is nested and this analysis is going to be a part of a larger product. */ internal class MultiControlInitFunc, MPrec : MultiPrec> - ( +( private val leftControlInitFunc: InitFunc, private val rightControlInitFunc: InitFunc, private val createState: (lState: LControl, rState: RControl) -> MState diff --git a/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/algorithm/BoundedTest.kt b/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/algorithm/BoundedTest.kt index 5156908c26..c1a49e333e 100644 --- a/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/algorithm/BoundedTest.kt +++ b/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/algorithm/BoundedTest.kt @@ -43,8 +43,7 @@ class BoundedTest { } private val biValToAction = { valuation: Valuation?, valuation2: Valuation? -> ExprActionStub( - emptyList() - ) + emptyList()) } init { @@ -77,8 +76,7 @@ class BoundedTest { indSolver = indSolver, valToState = valToState, biValToAction = biValToAction, - logger = ConsoleLogger(Logger.Level.VERBOSE) - ) + logger = ConsoleLogger(Logger.Level.VERBOSE)) val safetyResult: SafetyResult<*, *> = checker.check() Assert.assertTrue(safetyResult.isUnsafe()) } @@ -95,8 +93,7 @@ class BoundedTest { indSolver = indSolver, valToState = valToState, biValToAction = biValToAction, - logger = ConsoleLogger(Logger.Level.VERBOSE) - ) + logger = ConsoleLogger(Logger.Level.VERBOSE)) val safetyResult: SafetyResult<*, *> = checker.check() Assert.assertTrue(safetyResult.isSafe()) } diff --git a/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysisTest.kt b/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysisTest.kt index 6c2a0a179c..9379846676 100644 --- a/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysisTest.kt +++ b/subprojects/common/analysis/src/test/java/hu/bme/mit/theta/analysis/ptr/PtrAnalysisTest.kt @@ -43,44 +43,31 @@ class PtrAnalysisTest { private val explTop1 = PtrState(ExplState.top(), nextCnt = 1) private val emptyAction = PtrActionStub(listOf(), emptyMap()) - private val readLiteralOnly = PtrActionStub( - listOf(Assume(Eq(Dereference(Int(0), Int(1), Int()), Int(0)))), - emptyMap() - ) - private val writeLiteralOnly = PtrActionStub( - listOf(MemoryAssign(Dereference(Int(0), Int(1), Int()), Int(0))), - emptyMap() - ) + private val readLiteralOnly = PtrActionStub(listOf(Assume(Eq(Dereference(Int(0), Int(1), Int()), Int(0)))), + emptyMap()) + private val writeLiteralOnly = PtrActionStub(listOf(MemoryAssign(Dereference(Int(0), Int(1), Int()), Int(0))), + emptyMap()) private val emptyPrec = PtrPrec(ExplPrec.empty(), emptySet()) @JvmStatic fun testInputs(): Collection { return listOf( - Arguments.of( - explTop0, emptyAction, emptyPrec, - listOf(explTop0) - ), - Arguments.of( - explTop0, readLiteralOnly, emptyPrec, - listOf(explTop1) - ), - Arguments.of( - explTop0, writeLiteralOnly, emptyPrec, + Arguments.of(explTop0, emptyAction, emptyPrec, + listOf(explTop0)), + Arguments.of(explTop0, readLiteralOnly, emptyPrec, + listOf(explTop1)), + Arguments.of(explTop0, writeLiteralOnly, emptyPrec, listOf( - PtrState(ExplState.top(), 1) - ) - ), + PtrState(ExplState.top(), 1))), ) } } @ParameterizedTest @MethodSource("testInputs") - fun transFuncTest( - state: PtrState, action: PtrAction, prec: PtrPrec, - expectedResult: Collection> - ) { + fun transFuncTest(state: PtrState, action: PtrAction, prec: PtrPrec, + expectedResult: Collection>) { val analysis = PtrAnalysis(ExplAnalysis.create(Z3LegacySolverFactory.getInstance().createSolver(), True())) val result = analysis.transFunc.getSuccStates(state, action, prec) diff --git a/subprojects/common/core/src/main/java/hu/bme/mit/theta/core/ChcUtils.kt b/subprojects/common/core/src/main/java/hu/bme/mit/theta/core/ChcUtils.kt index 1f3d2ee7c5..5b7789b350 100644 --- a/subprojects/common/core/src/main/java/hu/bme/mit/theta/core/ChcUtils.kt +++ b/subprojects/common/core/src/main/java/hu/bme/mit/theta/core/ChcUtils.kt @@ -61,10 +61,8 @@ open class Relation(val name: String, vararg paramTypes: Type) { open operator fun invoke(vararg params: Expr<*>) = RelationApp(this, params.toList()) } -data class RelationApp( - val relation: Relation, val params: List>, - val constraints: List> = emptyList() -) { +data class RelationApp(val relation: Relation, val params: List>, + val constraints: List> = emptyList()) { init { checkArgument(params.size == relation.arity) diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/Utils.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/Utils.kt index 665121a5cd..488fe3330b 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/Utils.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/Utils.kt @@ -33,10 +33,8 @@ fun ParserRuleContext.textWithWS(): String { object ThrowingErrorListener : BaseErrorListener() { @Throws(ParseCancellationException::class) - override fun syntaxError( - recognizer: Recognizer<*, *>?, offendingSymbol: Any?, line: Int, - charPositionInLine: Int, msg: String, e: RecognitionException? - ) { + override fun syntaxError(recognizer: Recognizer<*, *>?, offendingSymbol: Any?, line: Int, + charPositionInLine: Int, msg: String, e: RecognitionException?) { throw ParseCancellationException("line $line:$charPositionInLine $msg") } } \ No newline at end of file diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/expr/ExprParser.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/expr/ExprParser.kt index adfdcc3f80..f896e6265a 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/expr/ExprParser.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/expr/ExprParser.kt @@ -118,10 +118,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } private fun pop() { - Preconditions.checkState( - currentScope.enclosingScope().isPresent, - "Enclosing scope is not present." - ) + Preconditions.checkState(currentScope.enclosingScope().isPresent, + "Enclosing scope is not present.") currentScope = currentScope.enclosingScope().get() env.pop() } @@ -129,10 +127,8 @@ class ExpressionWrapper(scope: Scope, content: String) { //// override fun visitFuncLitExpr(ctx: FuncLitExprContext): Expr { return if (ctx.result != null) { - val param = Decls.Param( - ctx.param.name.text, - TypeWrapper(ctx.param.type().textWithWS()).instantiate() - ) + val param = Decls.Param(ctx.param.name.text, + TypeWrapper(ctx.param.type().textWithWS()).instantiate()) push(listOf(param)) val result = ctx.result.accept>(this) as Expr pop() @@ -148,10 +144,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } else { ctx.decls.stream() .map { d: DeclContext -> - Decls.Param( - d.name.getText(), - TypeWrapper(d.ttype.textWithWS()).instantiate() - ) + Decls.Param(d.name.getText(), + TypeWrapper(d.ttype.textWithWS()).instantiate()) }.collect(Collectors.toList()) } } @@ -159,10 +153,8 @@ class ExpressionWrapper(scope: Scope, content: String) { //// override fun visitIteExpr(ctx: IteExprContext): Expr { return if (ctx.cond != null) { - val cond: Expr = TypeUtils.cast( - ctx.cond.accept>(this), - BoolExprs.Bool() - ) + val cond: Expr = TypeUtils.cast(ctx.cond.accept>(this), + BoolExprs.Bool()) val then: Expr<*> = ctx.then.accept>(this) val elze: Expr<*> = ctx.elze.accept>(this) AbstractExprs.Ite(cond, then, elze) @@ -173,14 +165,10 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitIffExpr(ctx: IffExprContext): Expr { return if (ctx.rightOp != null) { - val leftOp: Expr = TypeUtils.cast( - ctx.leftOp.accept>(this), - BoolExprs.Bool() - ) - val rightOp: Expr = TypeUtils.cast( - ctx.rightOp.accept>(this), - BoolExprs.Bool() - ) + val leftOp: Expr = TypeUtils.cast(ctx.leftOp.accept>(this), + BoolExprs.Bool()) + val rightOp: Expr = TypeUtils.cast(ctx.rightOp.accept>(this), + BoolExprs.Bool()) BoolExprs.Iff(leftOp, rightOp) } else { visitChildren(ctx) @@ -189,14 +177,10 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitImplyExpr(ctx: ImplyExprContext): Expr { return if (ctx.rightOp != null) { - val leftOp: Expr = TypeUtils.cast( - ctx.leftOp.accept>(this), - BoolExprs.Bool() - ) - val rightOp: Expr = TypeUtils.cast( - ctx.rightOp.accept>(this), - BoolExprs.Bool() - ) + val leftOp: Expr = TypeUtils.cast(ctx.leftOp.accept>(this), + BoolExprs.Bool()) + val rightOp: Expr = TypeUtils.cast(ctx.rightOp.accept>(this), + BoolExprs.Bool()) BoolExprs.Imply(leftOp, rightOp) } else { visitChildren(ctx) @@ -207,10 +191,8 @@ class ExpressionWrapper(scope: Scope, content: String) { return if (ctx.paramDecls != null) { val paramDecls = createParamList(ctx.paramDecls) push(paramDecls) - val op: Expr = TypeUtils.cast( - ctx.op.accept>(this), - BoolExprs.Bool() - ) + val op: Expr = TypeUtils.cast(ctx.op.accept>(this), + BoolExprs.Bool()) pop() BoolExprs.Forall(paramDecls, op) } else { @@ -222,10 +204,8 @@ class ExpressionWrapper(scope: Scope, content: String) { return if (ctx.paramDecls != null) { val paramDecls = createParamList(ctx.paramDecls) push(paramDecls) - val op: Expr = TypeUtils.cast( - ctx.op.accept>(this), - BoolExprs.Bool() - ) + val op: Expr = TypeUtils.cast(ctx.op.accept>(this), + BoolExprs.Bool()) pop() BoolExprs.Exists(paramDecls, op) } else { @@ -248,14 +228,10 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitXorExpr(ctx: XorExprContext): Expr { return if (ctx.rightOp != null) { - val leftOp: Expr = TypeUtils.cast( - ctx.leftOp.accept>(this), - BoolExprs.Bool() - ) - val rightOp: Expr = TypeUtils.cast( - ctx.rightOp.accept>(this), - BoolExprs.Bool() - ) + val leftOp: Expr = TypeUtils.cast(ctx.leftOp.accept>(this), + BoolExprs.Bool()) + val rightOp: Expr = TypeUtils.cast(ctx.rightOp.accept>(this), + BoolExprs.Bool()) BoolExprs.Xor(leftOp, rightOp) } else { visitChildren(ctx) @@ -277,10 +253,8 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitNotExpr(ctx: NotExprContext): Expr { return if (ctx.op != null) { - val op: Expr = TypeUtils.cast( - ctx.op.accept>(this), - BoolExprs.Bool() - ) + val op: Expr = TypeUtils.cast(ctx.op.accept>(this), + BoolExprs.Bool()) BoolExprs.Not(op) } else { visitChildren(ctx) @@ -412,10 +386,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createAdditiveExpr( - opsHead: Expr<*>, opsTail: List>, - oper: Token, ctx: AdditiveExprContext - ): Expr { + private fun createAdditiveExpr(opsHead: Expr<*>, opsTail: List>, + oper: Token, ctx: AdditiveExprContext): Expr { return if (opsTail.isEmpty()) { opsHead } else { @@ -426,24 +398,18 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createAdditiveSubExpr( - leftOp: Expr<*>, rightOp: Expr<*>, oper: Token, - ctx: AdditiveExprContext - ): Expr { + private fun createAdditiveSubExpr(leftOp: Expr<*>, rightOp: Expr<*>, oper: Token, + ctx: AdditiveExprContext): Expr { return when (oper.type) { PLUS -> createAddExpr(leftOp, rightOp) MINUS -> createSubExpr(leftOp, rightOp) BV_ADD -> createBvAddExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) BV_SUB -> createBvSubExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) - FPADD -> FpExprs.Add( - getRoundingMode(ctx.oper.text), - java.util.List.of(TypeUtils.castFp(leftOp), TypeUtils.castFp(rightOp)) - ) + FPADD -> FpExprs.Add(getRoundingMode(ctx.oper.text), + java.util.List.of(TypeUtils.castFp(leftOp), TypeUtils.castFp(rightOp))) - FPSUB -> FpExprs.Sub( - getRoundingMode(ctx.oper.text), TypeUtils.castFp(leftOp), - TypeUtils.castFp(rightOp) - ) + FPSUB -> FpExprs.Sub(getRoundingMode(ctx.oper.text), TypeUtils.castFp(leftOp), + TypeUtils.castFp(rightOp)) else -> throw ParseException(ctx, "Unknown operator '" + oper.text + "'") } @@ -493,10 +459,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createMutliplicativeExpr( - opsHead: Expr<*>, opsTail: List>, - oper: Token, ctx: MultiplicativeExprContext - ): Expr { + private fun createMutliplicativeExpr(opsHead: Expr<*>, opsTail: List>, + oper: Token, ctx: MultiplicativeExprContext): Expr { return if (opsTail.isEmpty()) { opsHead } else { @@ -507,10 +471,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createMultiplicativeSubExpr( - leftOp: Expr<*>, rightOp: Expr<*>, oper: Token, - ctx: MultiplicativeExprContext - ): Expr { + private fun createMultiplicativeSubExpr(leftOp: Expr<*>, rightOp: Expr<*>, oper: Token, + ctx: MultiplicativeExprContext): Expr { return when (oper.type) { MUL -> createMulExpr(leftOp, rightOp) BV_MUL -> createBvMulExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) @@ -523,15 +485,11 @@ class ExpressionWrapper(scope: Scope, content: String) { BV_UREM -> createBvURemExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) BV_SREM -> createBvSRemExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) FPREM -> FpExprs.Rem(leftOp as Expr, rightOp as Expr) - FPMUL -> FpExprs.Mul( - getRoundingMode(ctx.oper.text), - java.util.List.of(leftOp as Expr, rightOp as Expr) - ) + FPMUL -> FpExprs.Mul(getRoundingMode(ctx.oper.text), + java.util.List.of(leftOp as Expr, rightOp as Expr)) - FPDIV -> FpExprs.Div( - getRoundingMode(ctx.oper.text), leftOp as Expr, - rightOp as Expr - ) + FPDIV -> FpExprs.Div(getRoundingMode(ctx.oper.text), leftOp as Expr, + rightOp as Expr) else -> throw ParseException(ctx, "Unknown operator '" + oper.text + "'") } @@ -605,10 +563,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createConcatExpr( - opsHead: Expr<*>, opsTail: List>, - oper: Token - ): Expr { + private fun createConcatExpr(opsHead: Expr<*>, opsTail: List>, + oper: Token): Expr { return if (opsTail.isEmpty()) { opsHead } else { @@ -619,10 +575,8 @@ class ExpressionWrapper(scope: Scope, content: String) { } } - private fun createConcatSubExpr( - leftOp: Expr<*>, rightOp: Expr<*>, - oper: Token - ): Expr { + private fun createConcatSubExpr(leftOp: Expr<*>, rightOp: Expr<*>, + oper: Token): Expr { return when (oper.type) { BV_CONCAT -> createBvConcatExpr(TypeUtils.castBv(leftOp), TypeUtils.castBv(rightOp)) else -> throw AssertionError() @@ -645,12 +599,10 @@ class ExpressionWrapper(scope: Scope, content: String) { val extendType = BvExprs.BvType(ctx.rightOp.size.getText().toInt()) when (ctx.oper.getType()) { BV_ZERO_EXTEND -> BvExprs.ZExt( - TypeUtils.castBv(ctx.leftOp.accept>(this)), extendType - ) + TypeUtils.castBv(ctx.leftOp.accept>(this)), extendType) BV_SIGN_EXTEND -> BvExprs.SExt( - TypeUtils.castBv(ctx.leftOp.accept>(this)), extendType - ) + TypeUtils.castBv(ctx.leftOp.accept>(this)), extendType) else -> throw AssertionError() } @@ -669,28 +621,20 @@ class ExpressionWrapper(scope: Scope, content: String) { FP_ABS -> FpExprs.Abs(op as Expr) FP_IS_INF -> FpExprs.IsInfinite(op as Expr) FP_IS_NAN -> FpExprs.IsNan(op as Expr) - FPROUNDTOINT -> FpExprs.RoundToIntegral( - getRoundingMode(ctx.oper.text), - op as Expr - ) + FPROUNDTOINT -> FpExprs.RoundToIntegral(getRoundingMode(ctx.oper.text), + op as Expr) FPSQRT -> FpExprs.Sqrt(getRoundingMode(ctx.oper.text), op as Expr) - FPTOFP -> FpExprs.ToFp( - getRoundingMode(ctx.oper.text), op as Expr, - getExp(ctx.oper.getText()), getSignificand(ctx.oper.getText()) - ) - - FPTOBV -> FpExprs.ToBv( - getRoundingMode(ctx.oper.text), op as Expr, - getBvSize(ctx.oper.getText()), isSignedBv(ctx.oper.getText()) - ) - - FP_FROM_BV -> FpExprs.FromBv( - getRoundingMode(ctx.oper.text), + FPTOFP -> FpExprs.ToFp(getRoundingMode(ctx.oper.text), op as Expr, + getExp(ctx.oper.getText()), getSignificand(ctx.oper.getText())) + + FPTOBV -> FpExprs.ToBv(getRoundingMode(ctx.oper.text), op as Expr, + getBvSize(ctx.oper.getText()), isSignedBv(ctx.oper.getText())) + + FP_FROM_BV -> FpExprs.FromBv(getRoundingMode(ctx.oper.text), op as Expr, FpType.of(getExp(ctx.oper.getText()), getSignificand(ctx.oper.getText())), - isSignedFp(ctx.oper.getText()) - ) + isSignedFp(ctx.oper.getText())) FPNEG -> FpExprs.Neg(op as Expr) FPPOS -> FpExprs.Pos(op as Expr) @@ -773,8 +717,7 @@ class ExpressionWrapper(scope: Scope, content: String) { return if (ctx.array != null) { ArrayReadExpr.create( ctx.array.accept(this), - ctx.index.accept(this) - ) + ctx.index.accept(this)) } else { visitChildren(ctx) } @@ -785,8 +728,7 @@ class ExpressionWrapper(scope: Scope, content: String) { ArrayWriteExpr.create( ctx.array.accept(this), ctx.index.accept(this), - ctx.elem.accept(this) - ) + ctx.elem.accept(this)) } else { visitChildren(ctx) } @@ -804,10 +746,8 @@ class ExpressionWrapper(scope: Scope, content: String) { return if (ctx.op != null) { val op = ctx.op.accept(this) val bitvec = TypeUtils.castBv(op) - return BvExprs.Extract( - bitvec, Int(ctx.from.getText()), - IntExprs.Int(ctx.until.getText()) - ) + return BvExprs.Extract(bitvec, Int(ctx.from.getText()), + IntExprs.Int(ctx.until.getText())) } else { visitChildren(ctx) } @@ -864,19 +804,14 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitArrLitExpr(ctx: ArrLitExprContext): Expr { Preconditions.checkNotNull(ctx.elseExpr) val indexType = if (ctx.indexExpr.size > 0) ctx.indexExpr[0].accept( - this - ).type else Int() + this).type else Int() val elseElem = ctx.elseExpr.accept(this) val valueType = elseElem.type val elems = ctx.indexExpr.mapIndexed { idx, it -> Tuple2.of(it.accept(this), ctx.valueExpr[idx].accept(this)) } - return ExprUtils.simplify( - ArrayInitExpr.create( - elems, elseElem, - ArrayType.of(indexType, valueType) - ) - ) + return ExprUtils.simplify(ArrayInitExpr.create(elems, elseElem, + ArrayType.of(indexType, valueType))) } override fun visitBvLitExpr(ctx: BvLitExprContext): Expr { @@ -887,8 +822,7 @@ class ExpressionWrapper(scope: Scope, content: String) { decodeBinaryBvContent(content.substring(1)) } else if (content.startsWith("d")) { check( - sizeAndContent.size == 2 - ) { "Decimal value is only parseable if size is given." } + sizeAndContent.size == 2) { "Decimal value is only parseable if size is given." } decodeDecimalBvContent(content.substring(1), sizeAndContent[0].toInt()) } else if (content.startsWith("x")) { decodeHexadecimalBvContent(content.substring(1)) @@ -909,8 +843,7 @@ class ExpressionWrapper(scope: Scope, content: String) { '0' -> value[i] = false '1' -> value[i] = true else -> throw IllegalArgumentException( - "Binary literal can contain only 0 and 1" - ) + "Binary literal can contain only 0 and 1") } } return value @@ -920,8 +853,7 @@ class ExpressionWrapper(scope: Scope, content: String) { var value = BigInteger(lit) Preconditions.checkArgument( value.compareTo( - BigInteger.TWO.pow(size - 1).multiply(BigInteger.valueOf(-1)) - ) >= 0 && + BigInteger.TWO.pow(size - 1).multiply(BigInteger.valueOf(-1))) >= 0 && value.compareTo(BigInteger.TWO.pow(size)) < 0, "Decimal literal is not in range" ) @@ -960,10 +892,8 @@ class ExpressionWrapper(scope: Scope, content: String) { override fun visitIdExpr(ctx: IdExprContext): RefExpr<*> { val optSymbol = currentScope.resolve(ctx.id.getText()) if (optSymbol.isEmpty) { - throw ParseException( - ctx, - "Identifier '" + ctx.id.getText() + "' cannot be resolved" - ) + throw ParseException(ctx, + "Identifier '" + ctx.id.getText() + "' cannot be resolved") } val symbol = optSymbol.get() val decl = env.eval(symbol) as Decl<*> diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/stmt/StmtParser.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/stmt/StmtParser.kt index d11ca4187c..09ea6e8f9d 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/stmt/StmtParser.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/dsl/stmt/StmtParser.kt @@ -108,8 +108,7 @@ class StatementWrapper(val content: String, scope: Scope) { override fun visitMemAssignStmt(ctx: MemAssignStmtContext): Stmt { val derefExpr: Dereference<*, *, *> = ExpressionWrapper(scope, ctx.derefExpr().textWithWS()).instantiate( - env - ) as Dereference<*, *, *> + env) as Dereference<*, *, *> val value = ExpressionWrapper(scope, ctx.value.textWithWS()) val valueE: Expr<*> = value.instantiate(env) return if (derefExpr.type == valueE.type) { diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapter.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapter.kt index eaad49e3e0..a05598f87e 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapter.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapter.kt @@ -26,11 +26,9 @@ import hu.bme.mit.theta.analysis.State import hu.bme.mit.theta.analysis.algorithm.arg.ARG import java.lang.reflect.Type -class ArgAdapter( - val gsonSupplier: () -> Gson, +class ArgAdapter(val gsonSupplier: () -> Gson, private val partialOrdSupplier: () -> PartialOrd, - private val argTypeSupplier: () -> Type -) : TypeAdapter>() { + private val argTypeSupplier: () -> Type) : TypeAdapter>() { private lateinit var gson: Gson private lateinit var partialOrd: PartialOrd diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapterHelper.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapterHelper.kt index 05e193a195..f00ff2ac89 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapterHelper.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/ArgAdapterHelper.kt @@ -54,14 +54,11 @@ data class ArgAdapterHelper( while (waitSet.isNotEmpty()) { val entry = waitSet.firstOrNull { lut.keys.contains(checkNotNull(edges[it]).source) } check( - entry != null - ) { "Unreachable node(s) present: $waitSet\nedges: $edges\nlut: $lut" } + entry != null) { "Unreachable node(s) present: $waitSet\nedges: $edges\nlut: $lut" } waitSet.remove(entry) val edge = checkNotNull(edges[entry]) - lut[entry] = arg.createSuccNode( - lut[edge.source], edge.action, checkNotNull(nodes[entry]).state, - checkNotNull(nodes[entry]).target - ) + lut[entry] = arg.createSuccNode(lut[edge.source], edge.action, checkNotNull(nodes[entry]).state, + checkNotNull(nodes[entry]).target) .also { n -> if (checkNotNull(nodes[entry]).expanded) n.expanded = true } } coveringEdges.forEach { checkNotNull(lut[it.key]).cover(lut[it.value]) } diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/SafetyResultAdapter.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/SafetyResultAdapter.kt index 271417ea04..6829d577c0 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/SafetyResultAdapter.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/SafetyResultAdapter.kt @@ -40,10 +40,8 @@ class SafetyResultAdapter( private lateinit var argType: Type private lateinit var traceType: Type - override fun write( - writer: JsonWriter, - value: SafetyResult, Trace> - ) { + override fun write(writer: JsonWriter, + value: SafetyResult, Trace>) { initGson() writer.beginObject() writer.name("arg") @@ -82,10 +80,8 @@ class SafetyResultAdapter( return if (stats.isEmpty) if (safe == true) SafetyResult.safe(arg) else SafetyResult.unsafe(trace, arg) else - if (safe == false) SafetyResult.safe(arg, stats.get()) else SafetyResult.unsafe( - trace, - arg, stats.get() - ) + if (safe == false) SafetyResult.safe(arg, stats.get()) else SafetyResult.unsafe(trace, + arg, stats.get()) } private fun initGson() { diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/StateAdapters.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/StateAdapters.kt index 30031d82e0..a75f2133cb 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/StateAdapters.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/StateAdapters.kt @@ -89,10 +89,8 @@ class PredStateAdapter(val gsonSupplier: () -> Gson, val scope: Scope, val env: check(reader.nextName() == "bottom") if (reader.nextBoolean()) ret = PredState.bottom() check(reader.nextName() == "preds") - val preds = gson.fromJson>>( - reader, - object : TypeToken>>() {}.type - ) + val preds = gson.fromJson>>(reader, + object : TypeToken>>() {}.type) if (ret == null) ret = PredState.of(preds) reader.endObject() return ret!! diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/TraceAdapter.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/TraceAdapter.kt index 649ec9d72c..0571800b23 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/TraceAdapter.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/TraceAdapter.kt @@ -26,10 +26,8 @@ import hu.bme.mit.theta.analysis.State import hu.bme.mit.theta.analysis.Trace import java.lang.reflect.Type -class TraceAdapter( - val gsonSupplier: () -> Gson, private val stateTypeSupplier: () -> Type, - private val actionType: Type -) : TypeAdapter>() { +class TraceAdapter(val gsonSupplier: () -> Gson, private val stateTypeSupplier: () -> Type, + private val actionType: Type) : TypeAdapter>() { private lateinit var gson: Gson private lateinit var stateType: Type @@ -49,15 +47,11 @@ class TraceAdapter( if (!this::stateType.isInitialized) stateType = stateTypeSupplier() reader.beginObject() check(reader.nextName() == "states") - val stateList: List = gson.fromJson( - reader, - TypeToken.getParameterized(TypeToken.get(List::class.java).type, stateType).type - ) + val stateList: List = gson.fromJson(reader, + TypeToken.getParameterized(TypeToken.get(List::class.java).type, stateType).type) check(reader.nextName() == "actions") - val actionList: List = gson.fromJson( - reader, - TypeToken.getParameterized(TypeToken.get(List::class.java).type, actionType).type - ) + val actionList: List = gson.fromJson(reader, + TypeToken.getParameterized(TypeToken.get(List::class.java).type, actionType).type) reader.endObject() return Trace.of(stateList, actionList) } diff --git a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/VarDeclAdapter.kt b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/VarDeclAdapter.kt index 2dc571788f..8e0ea55885 100644 --- a/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/VarDeclAdapter.kt +++ b/subprojects/common/grammar/src/main/java/hu/bme/mit/theta/grammar/gson/VarDeclAdapter.kt @@ -29,10 +29,8 @@ import hu.bme.mit.theta.core.decl.Decls.Var import hu.bme.mit.theta.core.decl.VarDecl import hu.bme.mit.theta.core.type.Type -class VarDeclAdapter( - val gsonSupplier: () -> Gson, val scope: MutableScope, val env: Env, - val throwIfNotInScope: Boolean = false -) : TypeAdapter>() { +class VarDeclAdapter(val gsonSupplier: () -> Gson, val scope: MutableScope, val env: Env, + val throwIfNotInScope: Boolean = false) : TypeAdapter>() { private lateinit var gson: Gson diff --git a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/ExprTest.kt b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/ExprTest.kt index b647fb75c2..ff72c48eb5 100644 --- a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/ExprTest.kt +++ b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/ExprTest.kt @@ -91,57 +91,36 @@ class ExprTest { arrayOf(fpLit1, "(#b1 #b1010 #b101010)", emptyMap>()), arrayOf(fpLit2, "(#b0 #b1010 #b101010)", emptyMap>()), + arrayOf(ArrayLitExpr.of(listOf(), Int(2), ArrayType.of(Int(), Int())), + "(array (default 2))", emptyMap>()), + arrayOf(ArrayLitExpr.of(listOf(Tuple2.of(Int(0), Int(1))), Int(2), + ArrayType.of(Int(), Int())), "(array (0 1) (default 2))", + emptyMap>()), arrayOf( - ArrayLitExpr.of(listOf(), Int(2), ArrayType.of(Int(), Int())), - "(array (default 2))", emptyMap>() - ), - arrayOf( - ArrayLitExpr.of( - listOf(Tuple2.of(Int(0), Int(1))), Int(2), - ArrayType.of(Int(), Int()) - ), "(array (0 1) (default 2))", - emptyMap>() - ), - arrayOf( - ArrayLitExpr.of( - listOf(Tuple2.of(Int(0), Int(1)), Tuple2.of(Int(1), Int(2))), - Int(3), ArrayType.of(Int(), Int()) - ), "(array (0 1) (1 2) (default 3))", - emptyMap>() - ), + ArrayLitExpr.of(listOf(Tuple2.of(Int(0), Int(1)), Tuple2.of(Int(1), Int(2))), + Int(3), ArrayType.of(Int(), Int())), "(array (0 1) (1 2) (default 3))", + emptyMap>()), arrayOf(RefExpr.of(x), "x", mapOf(Pair(NamedSymbol("x"), x))), - arrayOf( - Ite(True(), Int(1), Int(2)), "(ite true 1 2)", - emptyMap>() - ), + arrayOf(Ite(True(), Int(1), Int(2)), "(ite true 1 2)", + emptyMap>()), arrayOf(Iff(True(), False()), "(iff true false)", emptyMap>()), arrayOf(Imply(True(), False()), "(=> true false)", emptyMap>()), - arrayOf( - Forall(listOf(p), True()), "(forall ((p Int)) true)", - mapOf(Pair(NamedSymbol("p"), p)) - ), - arrayOf( - Exists(listOf(p), True()), "(exists ((p Int)) true)", - mapOf(Pair(NamedSymbol("p"), p)) - ), + arrayOf(Forall(listOf(p), True()), "(forall ((p Int)) true)", + mapOf(Pair(NamedSymbol("p"), p))), + arrayOf(Exists(listOf(p), True()), "(exists ((p Int)) true)", + mapOf(Pair(NamedSymbol("p"), p))), - arrayOf( - Max(fpLit1, fpLit2), "(fpmax (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), - arrayOf( - Min(fpLit1, fpLit2), "(fpmin (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), + arrayOf(Max(fpLit1, fpLit2), "(fpmax (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", + emptyMap>()), + arrayOf(Min(fpLit1, fpLit2), "(fpmin (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", + emptyMap>()), arrayOf(Or(True(), False()), "(or true false)", emptyMap>()), arrayOf(Xor(True(), False()), "(xor true false)", emptyMap>()), - arrayOf( - And(True(), False(), False()), "(and true false false)", - emptyMap>() - ), + arrayOf(And(True(), False(), False()), "(and true false false)", + emptyMap>()), arrayOf(Not(True()), "(not true)", emptyMap>()), arrayOf(Eq(Int(1), Int(2)), "(= 1 2)", emptyMap>()), @@ -150,142 +129,80 @@ class ExprTest { arrayOf(Gt(Int(1), Int(2)), "(> 1 2)", emptyMap>()), arrayOf(Geq(Int(1), Int(2)), "(>= 1 2)", emptyMap>()), - arrayOf( - BvExprs.ULt(bvLit1, bvLit1), "(bvult #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.ULeq(bvLit1, bvLit1), "(bvule #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.UGt(bvLit1, bvLit1), "(bvugt #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.UGeq(bvLit1, bvLit1), "(bvuge #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.SLt(bvLit1, bvLit1), "(bvslt #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.SLeq(bvLit1, bvLit1), "(bvsle #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.SGt(bvLit1, bvLit1), "(bvsgt #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.SGeq(bvLit1, bvLit1), "(bvsge #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.Or(listOf(bvLit1, bvLit1)), "(bvor #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.Xor(listOf(bvLit1, bvLit1)), "(bvxor #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.And(listOf(bvLit1, bvLit1)), "(bvand #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.ShiftLeft(bvLit1, bvLit1), "(bvshl #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.ArithShiftRight(bvLit1, bvLit1), "(bvashr #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.LogicShiftRight(bvLit1, bvLit1), "(bvlshr #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.RotateLeft(bvLit1, bvLit1), "(bvrol #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.RotateRight(bvLit1, bvLit1), "(bvror #b1010 #b1010)", - emptyMap>() - ), - - arrayOf( - Add(listOf(Int(1), Int(2), Int(3))), "(+ 1 2 3)", - emptyMap>() - ), + arrayOf(BvExprs.ULt(bvLit1, bvLit1), "(bvult #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.ULeq(bvLit1, bvLit1), "(bvule #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.UGt(bvLit1, bvLit1), "(bvugt #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.UGeq(bvLit1, bvLit1), "(bvuge #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.SLt(bvLit1, bvLit1), "(bvslt #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.SLeq(bvLit1, bvLit1), "(bvsle #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.SGt(bvLit1, bvLit1), "(bvsgt #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.SGeq(bvLit1, bvLit1), "(bvsge #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.Or(listOf(bvLit1, bvLit1)), "(bvor #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.Xor(listOf(bvLit1, bvLit1)), "(bvxor #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.And(listOf(bvLit1, bvLit1)), "(bvand #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.ShiftLeft(bvLit1, bvLit1), "(bvshl #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.ArithShiftRight(bvLit1, bvLit1), "(bvashr #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.LogicShiftRight(bvLit1, bvLit1), "(bvlshr #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.RotateLeft(bvLit1, bvLit1), "(bvrol #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.RotateRight(bvLit1, bvLit1), "(bvror #b1010 #b1010)", + emptyMap>()), + + arrayOf(Add(listOf(Int(1), Int(2), Int(3))), "(+ 1 2 3)", + emptyMap>()), arrayOf(Sub(Int(1), Int(2)), "(- 1 2)", emptyMap>()), arrayOf(Add(bvLit1, bvLit1), "(bvadd #b1010 #b1010)", emptyMap>()), arrayOf(Sub(bvLit1, bvLit1), "(bvsub #b1010 #b1010)", emptyMap>()), - arrayOf( - Add(fpLit1, fpLit2), "(fpadd (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), - arrayOf( - Sub(fpLit1, fpLit2), "(fpsub (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), + arrayOf(Add(fpLit1, fpLit2), "(fpadd (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", + emptyMap>()), + arrayOf(Sub(fpLit1, fpLit2), "(fpsub (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", + emptyMap>()), - arrayOf( - Mul(listOf(Int(1), Int(2), Int(3))), "(* 1 2 3)", - emptyMap>() - ), + arrayOf(Mul(listOf(Int(1), Int(2), Int(3))), "(* 1 2 3)", + emptyMap>()), arrayOf(Div(Int(1), Int(2)), "(div 1 2)", emptyMap>()), arrayOf(Mod(Int(1), Int(2)), "(mod 1 2)", emptyMap>()), arrayOf(Rem(Int(1), Int(2)), "(rem 1 2)", emptyMap>()), arrayOf(Mul(bvLit1, bvLit1), "(bvmul #b1010 #b1010)", emptyMap>()), - arrayOf( - UDiv(bvLit1, bvLit1), "(bvudiv #b1010 #b1010)", - emptyMap>() - ), - arrayOf( - BvExprs.SDiv(bvLit1, bvLit2), "(bvsdiv #b1010 #b0101)", - emptyMap>() - ), - arrayOf( - BvExprs.SMod(bvLit1, bvLit2), "(bvsmod #b1010 #b0101)", - emptyMap>() - ), - arrayOf( - BvExprs.URem(bvLit1, bvLit2), "(bvurem #b1010 #b0101)", - emptyMap>() - ), - arrayOf( - BvExprs.SRem(bvLit1, bvLit2), "(bvsrem #b1010 #b0101)", - emptyMap>() - ), - arrayOf( - Mul(fpLit1, fpLit2), "(fpmul (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), - arrayOf( - FpExprs.Div(FpRoundingMode.RNE, fpLit1, fpLit2), + arrayOf(UDiv(bvLit1, bvLit1), "(bvudiv #b1010 #b1010)", + emptyMap>()), + arrayOf(BvExprs.SDiv(bvLit1, bvLit2), "(bvsdiv #b1010 #b0101)", + emptyMap>()), + arrayOf(BvExprs.SMod(bvLit1, bvLit2), "(bvsmod #b1010 #b0101)", + emptyMap>()), + arrayOf(BvExprs.URem(bvLit1, bvLit2), "(bvurem #b1010 #b0101)", + emptyMap>()), + arrayOf(BvExprs.SRem(bvLit1, bvLit2), "(bvsrem #b1010 #b0101)", + emptyMap>()), + arrayOf(Mul(fpLit1, fpLit2), "(fpmul (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", + emptyMap>()), + arrayOf(FpExprs.Div(FpRoundingMode.RNE, fpLit1, fpLit2), "(fpdiv[rne] (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), - arrayOf( - FpExprs.Rem(fpLit1, fpLit2), + emptyMap>()), + arrayOf(FpExprs.Rem(fpLit1, fpLit2), "(fprem (#b1 #b1010 #b101010) (#b0 #b1010 #b101010))", - emptyMap>() - ), + emptyMap>()), - arrayOf( - Concat(listOf(bvLit1, bvLit2)), "(++ #b1010 #b0101)", - emptyMap>() - ), - arrayOf( - ZExt(bvLit1, BvType(5)), "(bv_zero_extend #b1010 (Bv 5))", - emptyMap>() - ), - arrayOf( - SExt(bvLit1, BvType(5)), "(bv_sign_extend #b1010 (Bv 5))", - emptyMap>() - ), + arrayOf(Concat(listOf(bvLit1, bvLit2)), "(++ #b1010 #b0101)", + emptyMap>()), + arrayOf(ZExt(bvLit1, BvType(5)), "(bv_zero_extend #b1010 (Bv 5))", + emptyMap>()), + arrayOf(SExt(bvLit1, BvType(5)), "(bv_sign_extend #b1010 (Bv 5))", + emptyMap>()), arrayOf(Pos(Int(1)), "(+ 1)", emptyMap>()), arrayOf(Neg(Int(1)), "(- 1)", emptyMap>()), @@ -293,27 +210,17 @@ class ExprTest { arrayOf(Neg(bvLit1), "(bvneg #b1010)", emptyMap>()), arrayOf(Not(bvLit1), "(bvnot #b1010)", emptyMap>()), - arrayOf( - ArrayReadExpr.create( - ArrayLitExpr.of(emptyList(), Int(2), ArrayType.of(Int(), Int())), Int(5) - ), - "(read (array (default 2)) 5)", emptyMap>() - ), - arrayOf( - ArrayWriteExpr.create( - ArrayLitExpr.of( - emptyList(), Int(2), - ArrayType.of(Int(), Int()) - ), Int(5), Int(6) - ), - "(write (array (default 2)) 5 6)", emptyMap>() - ), + arrayOf(ArrayReadExpr.create( + ArrayLitExpr.of(emptyList(), Int(2), ArrayType.of(Int(), Int())), Int(5)), + "(read (array (default 2)) 5)", emptyMap>()), + arrayOf(ArrayWriteExpr.create( + ArrayLitExpr.of(emptyList(), Int(2), + ArrayType.of(Int(), Int())), Int(5), Int(6)), + "(write (array (default 2)) 5 6)", emptyMap>()), arrayOf(Prime(Int(1)), "(prime 1)", emptyMap>()), - arrayOf( - Extract(bvLit1, Int(1), Int(4)), "(extract #b1010 1 4)", - emptyMap>() - ), + arrayOf(Extract(bvLit1, Int(1), Int(4)), "(extract #b1010 1 4)", + emptyMap>()), arrayOf(Dereference(Int(0), Int(1), Int()), "(deref 0 1 Int)", emptyMap>()), ) @@ -333,8 +240,7 @@ class ExprTest { val env = Env() decls.forEach { env.define(it.key, it.value) } val expr = simplify( - ExpressionWrapper(SimpleScope(symbolTable), serialized).instantiate(env) - ) + ExpressionWrapper(SimpleScope(symbolTable), serialized).instantiate(env)) Assert.assertEquals(simplify(memory), expr) } @@ -346,8 +252,7 @@ class ExprTest { val env = Env() decls.forEach { env.define(it.key, it.value) } val expr = simplify( - ExpressionWrapper(SimpleScope(symbolTable), memory.toString()).instantiate(env) - ) + ExpressionWrapper(SimpleScope(symbolTable), memory.toString()).instantiate(env)) Assert.assertEquals(simplify(memory), expr) } diff --git a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/StmtTest.kt b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/StmtTest.kt index 2dc532876e..372e1f796e 100644 --- a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/StmtTest.kt +++ b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/StmtTest.kt @@ -53,19 +53,13 @@ class StmtTest { val addr = x.hashCode() return listOf( - arrayOf( - Assign(x, Int(1)), "(assign x 1)", - mapOf(Pair(ExprTest.NamedSymbol("x"), x)) - ), - arrayOf( - MemoryAssign(Dereference(Int(addr), Int(0), Int()), Int(1)), + arrayOf(Assign(x, Int(1)), "(assign x 1)", + mapOf(Pair(ExprTest.NamedSymbol("x"), x))), + arrayOf(MemoryAssign(Dereference(Int(addr), Int(0), Int()), Int(1)), "(memassign (deref $addr 0 Int) 1)", - mapOf(Pair(ExprTest.NamedSymbol("x"), x)) - ), - arrayOf( - Assume(Eq(x.ref, Int(1))), "(assume (= x 1))", - mapOf(Pair(ExprTest.NamedSymbol("x"), x)) - ), + mapOf(Pair(ExprTest.NamedSymbol("x"), x))), + arrayOf(Assume(Eq(x.ref, Int(1))), "(assume (= x 1))", + mapOf(Pair(ExprTest.NamedSymbol("x"), x))), arrayOf(Havoc(x), "(havoc x)", mapOf(Pair(ExprTest.NamedSymbol("x"), x))), ) } diff --git a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/TypeTest.kt b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/TypeTest.kt index 8745fef7c3..a94dfbf86d 100644 --- a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/TypeTest.kt +++ b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/dsl/TypeTest.kt @@ -52,10 +52,8 @@ class TypeTest { arrayOf(BvType(32), "(Bv 32)"), arrayOf(FpType(12, 45), "(Fp 12 45)"), - arrayOf( - Func(Int(), ArrayExprs.Array(Int(), Rat())), - "(Func Int (Array ([Int] -> Rat)))" - ), + arrayOf(Func(Int(), ArrayExprs.Array(Int(), Rat())), + "(Func Int (Array ([Int] -> Rat)))"), ) } } diff --git a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt index c4d39653a0..cb6ca93071 100644 --- a/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt +++ b/subprojects/common/grammar/src/test/java/hu/bme/mit/theta/grammar/gson/TestGson.kt @@ -101,18 +101,12 @@ class TestGson { private fun getExplBuilder(gsonSuppl: () -> Gson): GsonBuilder { val gsonBuilder = GsonBuilder() - gsonBuilder.registerTypeHierarchyAdapter( - ARG::class.java, - ArgAdapter(gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() }) - ) - gsonBuilder.registerTypeHierarchyAdapter( - Trace::class.java, - TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java) - ) - gsonBuilder.registerTypeHierarchyAdapter( - SafetyResult::class.java, - SafetyResultAdapter(gsonSuppl, { explArgHelper() }, { explTraceHelper() }) - ) + gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, + ArgAdapter(gsonSuppl, { ExplOrd.getInstance() }, { explArgAdapterHelper() })) + gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, + TraceAdapter(gsonSuppl, { ExplState::class.java }, SimpleStmtAction::class.java)) + gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java, + SafetyResultAdapter(gsonSuppl, { explArgHelper() }, { explTraceHelper() })) return gsonBuilder } @@ -120,18 +114,12 @@ class TestGson { private fun getPredBuilder(gsonSuppl: () -> Gson): GsonBuilder { val gsonBuilder = GsonBuilder() - gsonBuilder.registerTypeHierarchyAdapter( - ARG::class.java, - ArgAdapter(gsonSuppl, { PartialOrd { a, b -> true } }, { predArgAdapterHelper() }) - ) - gsonBuilder.registerTypeHierarchyAdapter( - Trace::class.java, - TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java) - ) - gsonBuilder.registerTypeHierarchyAdapter( - SafetyResult::class.java, - SafetyResultAdapter(gsonSuppl, { predArgHelper() }, { predTraceHelper() }) - ) + gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, + ArgAdapter(gsonSuppl, { PartialOrd { a, b -> true } }, { predArgAdapterHelper() })) + gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, + TraceAdapter(gsonSuppl, { PredState::class.java }, SimpleStmtAction::class.java)) + gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java, + SafetyResultAdapter(gsonSuppl, { predArgHelper() }, { predTraceHelper() })) return gsonBuilder } @@ -145,10 +133,8 @@ class TestGson { val env = Env() env.define(symbol, x) - gsonBuilder.registerTypeHierarchyAdapter( - VarDecl::class.java, - VarDeclAdapter(gsonSuppl, scope, env, false) - ) + gsonBuilder.registerTypeHierarchyAdapter(VarDecl::class.java, + VarDeclAdapter(gsonSuppl, scope, env, false)) gsonBuilder.registerTypeHierarchyAdapter(Stmt::class.java, StringTypeAdapter { StatementWrapper(it, scope).instantiate(env) }) gsonBuilder.registerTypeHierarchyAdapter(Expr::class.java, @@ -158,10 +144,8 @@ class TestGson { gsonBuilder.registerTypeHierarchyAdapter(VarIndexing::class.java, StringTypeAdapter { BasicVarIndexing.fromString(it, scope, env) }) gsonBuilder.registerTypeHierarchyAdapter(ExplState::class.java, ExplStateAdapter(scope, env)) - gsonBuilder.registerTypeHierarchyAdapter( - PredState::class.java, - PredStateAdapter(gsonSuppl, scope, env) - ) + gsonBuilder.registerTypeHierarchyAdapter(PredState::class.java, + PredStateAdapter(gsonSuppl, scope, env)) gsonBuilder.registerTypeHierarchyAdapter(Pair::class.java, PairAdapter(gsonSuppl)) gsonBuilder.registerTypeHierarchyAdapter(Triple::class.java, TripleAdapter(gsonSuppl)) gsonBuilder.registerTypeHierarchyAdapter(Optional::class.java, OptionalAdapter(gsonSuppl)) @@ -210,10 +194,8 @@ class TestGson { gson = getGson(getExplBuilder { gson }) { gson } val trace = Trace.of( - listOf( - ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()), - ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build()) - ), + listOf(ExplState.of(ImmutableValuation.builder().put(x, Int(1)).build()), + ExplState.of(ImmutableValuation.builder().put(x, Int(2)).build())), listOf(SimpleStmtAction(SkipStmt.getInstance())) ) diff --git a/subprojects/common/multi-tests/src/test/kotlin/multi/MultiNondetDiningPhilosophersTest.kt b/subprojects/common/multi-tests/src/test/kotlin/multi/MultiNondetDiningPhilosophersTest.kt index 408190e912..ce30555dea 100644 --- a/subprojects/common/multi-tests/src/test/kotlin/multi/MultiNondetDiningPhilosophersTest.kt +++ b/subprojects/common/multi-tests/src/test/kotlin/multi/MultiNondetDiningPhilosophersTest.kt @@ -73,28 +73,20 @@ class MultiNondetDiningPhilosophersTest { val phil3cfa = phil3rawCfa.copyWithReplacingVars(variables.associateBy { it.name }) val phil4cfa = phil4rawCfa.copyWithReplacingVars(variables.associateBy { it.name }) - val cfa1ConfigBuilder = CfaConfigBuilder( - CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, - Z3LegacySolverFactory.getInstance() - ) + val cfa1ConfigBuilder = CfaConfigBuilder(CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, + Z3LegacySolverFactory.getInstance()) cfa1ConfigBuilder.encoding(CfaConfigBuilder.Encoding.LBE) val cfa1ExplBuilder = cfa1ConfigBuilder.ExplStrategy(phil1cfa) - val cfa2ConfigBuilder = CfaConfigBuilder( - CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, - Z3LegacySolverFactory.getInstance() - ) + val cfa2ConfigBuilder = CfaConfigBuilder(CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, + Z3LegacySolverFactory.getInstance()) cfa2ConfigBuilder.encoding(CfaConfigBuilder.Encoding.LBE) val cfa2ExplBuilder = cfa1ConfigBuilder.ExplStrategy(phil2cfa) - val cfa3ConfigBuilder = CfaConfigBuilder( - CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, - Z3LegacySolverFactory.getInstance() - ) + val cfa3ConfigBuilder = CfaConfigBuilder(CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, + Z3LegacySolverFactory.getInstance()) cfa3ConfigBuilder.encoding(CfaConfigBuilder.Encoding.LBE) val cfa3ExplBuilder = cfa1ConfigBuilder.ExplStrategy(phil3cfa) - val cfa4ConfigBuilder = CfaConfigBuilder( - CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, - Z3LegacySolverFactory.getInstance() - ) + val cfa4ConfigBuilder = CfaConfigBuilder(CfaConfigBuilder.Domain.EXPL, CfaConfigBuilder.Refinement.SEQ_ITP, + Z3LegacySolverFactory.getInstance()) cfa4ConfigBuilder.encoding(CfaConfigBuilder.Encoding.LBE) val cfa4ExplBuilder = cfa1ConfigBuilder.ExplStrategy(phil4cfa) @@ -118,15 +110,13 @@ class MultiNondetDiningPhilosophersTest { var prop: Expr = True() variables.forEach { prop = And(prop, Eq(it.ref, True())) } val dataPredicate = ExplStatePredicate(prop, solver) - val multiConfigBuilder = StmtMultiConfigBuilder.ItpStmtMultiConfigBuilder( - totalProduct, prop, + val multiConfigBuilder = StmtMultiConfigBuilder.ItpStmtMultiConfigBuilder(totalProduct, prop, MultiStatePredicate(dataPredicate), RefToMultiPrec(cfaRefToPrec, cfaRefToPrec, ItpRefToExplPrec()), RefToMultiPrec(cfaRefToPrec, cfaRefToPrec, ItpRefToExplPrec()), ItpRefToExplPrec(), MultiPrec(cfaInitPrec, cfaInitPrec, dataInitPrec), MultiPrec(cfaInitPrec, cfaInitPrec, dataInitPrec), dataInitPrec, Z3LegacySolverFactory.getInstance(), - logger - ) + logger) val result = multiConfigBuilder.build().check() Assertions.assertTrue(result.isUnsafe) diff --git a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/CStatistics.kt b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/CStatistics.kt index 1f8d894b79..6be63aab98 100644 --- a/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/CStatistics.kt +++ b/subprojects/frontends/c-frontend/src/main/java/hu/bme/mit/theta/frontend/CStatistics.kt @@ -50,10 +50,8 @@ fun CProgram.getStatistics(): CStatistics { fun CFunction.collectStatistics(): Triple { val statisticsCollectorVisitor = StatisticsCollectorVisitor() this.compound?.accept(statisticsCollectorVisitor, Unit) - return Triple( - statisticsCollectorVisitor.loopNumber, statisticsCollectorVisitor.deepestLoop, - statisticsCollectorVisitor.linear - ) + return Triple(statisticsCollectorVisitor.loopNumber, statisticsCollectorVisitor.deepestLoop, + statisticsCollectorVisitor.linear) } fun Expr<*>.isNonLinear(): Boolean { diff --git a/subprojects/frontends/llvm/build.gradle.kts b/subprojects/frontends/llvm/build.gradle.kts index 812b35248b..2d93c23af0 100644 --- a/subprojects/frontends/llvm/build.gradle.kts +++ b/subprojects/frontends/llvm/build.gradle.kts @@ -104,10 +104,8 @@ fun llvmConfigFlags(vararg args: String): Array { fun jniConfigFlags(): Array { if (!taskEnabled) return arrayOf() - val jdkHomeArr = runCommandForOutput( - "bash", "-c", - "dirname \$(cd \$(dirname \$(readlink -f \$(which javac) || which javac)); pwd -P)" - ) + val jdkHomeArr = runCommandForOutput("bash", "-c", + "dirname \$(cd \$(dirname \$(readlink -f \$(which javac) || which javac)); pwd -P)") check(jdkHomeArr.size == 1) val jdkHome = File(jdkHomeArr[0]) check(jdkHome.exists()) @@ -122,14 +120,11 @@ fun jniConfigFlags(): Array { library { targetMachines.add(machines.linux.x86_64) tasks.withType(CppCompile::class) { - compilerArgs.addAll( - listOf( - "-Wall", - "-fpic", - *jniConfigFlags(), - *llvmConfigFlags("--cxxflags") - ) - ) + compilerArgs.addAll(listOf( + "-Wall", + "-fpic", + *jniConfigFlags(), + *llvmConfigFlags("--cxxflags"))) if (!taskEnabled) { println("CppCompile is enabled: $taskEnabled") enabled = false @@ -137,13 +132,10 @@ library { } tasks.withType(LinkSharedLibrary::class) { - linkerArgs.addAll( - listOf( - "-rdynamic", - *llvmConfigFlags("--cxxflags", "--ldflags", "--libs", "core", "bitreader"), - "-ldl" - ) - ) + linkerArgs.addAll(listOf( + "-rdynamic", + *llvmConfigFlags("--cxxflags", "--ldflags", "--libs", "core", "bitreader"), + "-ldl")) if (!taskEnabled) { println("LinkSharedLibrary is enabled: $taskEnabled") enabled = false diff --git a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/DefaultGraphPatternCompiler.kt b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/DefaultGraphPatternCompiler.kt index 1869904e1e..facf177953 100644 --- a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/DefaultGraphPatternCompiler.kt +++ b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/DefaultGraphPatternCompiler.kt @@ -110,10 +110,8 @@ abstract class DefaultGraphPatternCompiler : GraphPatternCompiler { override fun compile(pattern: BasicEventSet): T? = null override fun compile(pattern: BasicRelation): T? = null - override fun getCompleteGraph( - mcm: Set, - model: Valuation - ): Pair, Map, ThreeVL>> { + override fun getCompleteGraph(mcm: Set, + model: Valuation): Pair, Map, ThreeVL>> { error("Not implemented") } } \ No newline at end of file diff --git a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/GraphPatternCompiler.kt b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/GraphPatternCompiler.kt index fa24ce82cc..0490c9f006 100644 --- a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/GraphPatternCompiler.kt +++ b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/GraphPatternCompiler.kt @@ -59,8 +59,6 @@ interface GraphPatternCompiler { fun compile(pattern: UnionNode): T2 fun compile(pattern: BasicEventSet): T2 fun compile(pattern: BasicRelation): T2 - fun getCompleteGraph( - namedPatterns: Set, - model: Valuation - ): Pair, Map, ThreeVL>> + fun getCompleteGraph(namedPatterns: Set, + model: Valuation): Pair, Map, ThreeVL>> } \ No newline at end of file diff --git a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/pattern2expr/Pattern2ExprCompiler.kt b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/pattern2expr/Pattern2ExprCompiler.kt index d6355f1d95..4102e138ff 100644 --- a/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/pattern2expr/Pattern2ExprCompiler.kt +++ b/subprojects/solver/graph-solver/src/main/java/hu/bme/mit/theta/graphsolver/compilers/pattern2expr/Pattern2ExprCompiler.kt @@ -48,10 +48,8 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map, - model: Valuation - ): Pair, Map, ThreeVL>> { + override fun getCompleteGraph(namedPatterns: Set, + model: Valuation): Pair, Map, ThreeVL>> { val ret = LinkedHashMap, ThreeVL>() ret.putAll(facts) ret.putAll(namedLookup.map { n -> @@ -202,8 +200,7 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map val const = if (pattern.patternName != null) { val const = namedLookup[Pair(pattern.patternName!!, Tuple2.of(a, b))] ?: Const( - "RTC_" + uuid + "_" + a + "_" + b, Bool() - ) + "RTC_" + uuid + "_" + a + "_" + b, Bool()) namedLookup[Pair(pattern.patternName!!, Tuple2.of(a, b))] = const const } else { @@ -266,8 +263,7 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map val const = if (pattern.patternName != null) { val const = namedLookup[Pair(pattern.patternName!!, Tuple2.of(a, b))] ?: Const( - "TC_" + uuid + "_" + a + "_" + b, Bool() - ) + "TC_" + uuid + "_" + a + "_" + b, Bool()) namedLookup[Pair(pattern.patternName!!, Tuple2.of(a, b))] = const const } else { @@ -318,8 +314,7 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map> { return events.associate { a -> - Pair( - Tuple1.of(a), + Pair(Tuple1.of(a), when (facts[Pair(pattern.name, Tuple1.of(a))]) { ThreeVL.FALSE -> False() ThreeVL.TRUE -> True() @@ -328,16 +323,14 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map> { return events.map { a -> events.map { b -> - Pair( - Tuple2.of(a, b), + Pair(Tuple2.of(a, b), when (facts[Pair(pattern.name, Tuple2.of(a, b))]) { ThreeVL.FALSE -> False() ThreeVL.TRUE -> True() @@ -346,8 +339,7 @@ class Pattern2ExprCompiler : GraphPatternCompiler, Map { companion object { - private val smallLine: Pair, Map, ThreeVL>> = Pair( - listOf(1, 2, 3), mapOf( - Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.FALSE), - ) - ) + private val smallLine: Pair, Map, ThreeVL>> = Pair(listOf(1, 2, 3), mapOf( + Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.FALSE), + )) - private val smallCycle: Pair, Map, ThreeVL>> = Pair( - listOf(1, 2, 3), mapOf( - Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.FALSE), - Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.FALSE), - ) - ) + private val smallCycle: Pair, Map, ThreeVL>> = Pair(listOf(1, 2, 3), mapOf( + Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.FALSE), + Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.FALSE), + )) - private val smallFull: Pair, Map, ThreeVL>> = Pair( - listOf(1, 2, 3), mapOf( - Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.TRUE), - Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.TRUE), - Pair(Pair("W", Tuple1.of(1)), ThreeVL.TRUE), - Pair(Pair("R", Tuple1.of(2)), ThreeVL.TRUE), - Pair(Pair("F", Tuple1.of(3)), ThreeVL.TRUE), - ) - ) + private val smallFull: Pair, Map, ThreeVL>> = Pair(listOf(1, 2, 3), mapOf( + Pair(Pair("po", Tuple2.of(1, 1)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(1, 2)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(1, 3)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(2, 1)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(2, 2)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(2, 3)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 1)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 2)), ThreeVL.TRUE), + Pair(Pair("po", Tuple2.of(3, 3)), ThreeVL.TRUE), + Pair(Pair("W", Tuple1.of(1)), ThreeVL.TRUE), + Pair(Pair("R", Tuple1.of(2)), ThreeVL.TRUE), + Pair(Pair("F", Tuple1.of(3)), ThreeVL.TRUE), + )) @Parameterized.Parameters @JvmStatic @@ -108,8 +102,7 @@ class GraphSolverTest { smallLine.first, smallLine.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -118,8 +111,7 @@ class GraphSolverTest { smallCycle.first, smallCycle.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -128,8 +120,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -138,8 +129,7 @@ class GraphSolverTest { smallLine.first, smallLine.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -148,8 +138,7 @@ class GraphSolverTest { smallCycle.first, smallCycle.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -158,8 +147,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -168,8 +156,7 @@ class GraphSolverTest { smallLine.first, smallLine.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -178,8 +165,7 @@ class GraphSolverTest { smallCycle.first, smallCycle.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -188,8 +174,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -198,8 +183,7 @@ class GraphSolverTest { smallLine.first, smallLine.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -208,8 +192,7 @@ class GraphSolverTest { smallCycle.first, smallCycle.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -218,8 +201,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -228,8 +210,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -238,8 +219,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), arrayOf( @@ -248,8 +228,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -258,8 +237,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -268,8 +246,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -278,8 +255,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -288,8 +264,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -298,8 +273,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -308,8 +282,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -318,8 +291,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -328,8 +300,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -338,8 +309,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -348,8 +318,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -358,8 +327,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -368,8 +336,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), true ), arrayOf( @@ -378,8 +345,7 @@ class GraphSolverTest { smallFull.first, smallFull.second, SATGraphSolver( - Z3LegacySolverFactory.getInstance().createSolver() - ), + Z3LegacySolverFactory.getInstance().createSolver()), false ), ) diff --git a/subprojects/solver/solver-smtlib/src/test/java/hu/bme/mit/theta/solver/smtlib/GenericSmtLibHornSolverTest.kt b/subprojects/solver/solver-smtlib/src/test/java/hu/bme/mit/theta/solver/smtlib/GenericSmtLibHornSolverTest.kt index e1c2533a6d..9383d479b8 100644 --- a/subprojects/solver/solver-smtlib/src/test/java/hu/bme/mit/theta/solver/smtlib/GenericSmtLibHornSolverTest.kt +++ b/subprojects/solver/solver-smtlib/src/test/java/hu/bme/mit/theta/solver/smtlib/GenericSmtLibHornSolverTest.kt @@ -126,11 +126,8 @@ class GenericSmtLibHornSolverTest { App( App( model.get(init.constDecl) as FuncLitExpr>, - p0.ref - ), - p1.ref - ) - ) + p0.ref), + p1.ref)) checkerSolver.add(Lt(p1.ref, Int(0))) Assertions.assertTrue(checkerSolver.check().isUnsat) diff --git a/subprojects/solver/solver-z3/src/test/java/hu/bme/mit/theta/solver/z3/Z3HornSolverTest.kt b/subprojects/solver/solver-z3/src/test/java/hu/bme/mit/theta/solver/z3/Z3HornSolverTest.kt index eafd44ec12..859165d9cf 100644 --- a/subprojects/solver/solver-z3/src/test/java/hu/bme/mit/theta/solver/z3/Z3HornSolverTest.kt +++ b/subprojects/solver/solver-z3/src/test/java/hu/bme/mit/theta/solver/z3/Z3HornSolverTest.kt @@ -85,11 +85,8 @@ class Z3HornSolverTest { App( App( model.get(init.constDecl) as FuncLitExpr>, - p0.ref - ), - p1.ref - ) - ) + p0.ref), + p1.ref)) checkerSolver.add(Lt(p1.ref, Int(0))) Assertions.assertTrue(checkerSolver.check().isUnsat) diff --git a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt index a015c6ce1d..d82a92fa4a 100644 --- a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt +++ b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/FrontendXcfaBuilder.kt @@ -54,20 +54,16 @@ import org.abego.treelayout.internal.util.Contract.checkState import java.math.BigInteger import java.util.stream.Collectors -class FrontendXcfaBuilder( - val parseContext: ParseContext, val checkOverflow: Boolean = false, - val uniqueWarningLogger: Logger -) : +class FrontendXcfaBuilder(val parseContext: ParseContext, val checkOverflow: Boolean = false, + val uniqueWarningLogger: Logger) : CStatementVisitorBase() { private val locationLut: MutableMap = LinkedHashMap() private var ptrCnt = 1 // counts up, uses 3k+1 get() = field.also { field += 3 } - private fun getLoc( - builder: XcfaProcedureBuilder, name: String?, - metadata: MetaData - ): XcfaLocation { + private fun getLoc(builder: XcfaProcedureBuilder, name: String?, + metadata: MetaData): XcfaLocation { if (name == null) return getAnonymousLoc(builder, metadata = metadata) locationLut.putIfAbsent(name, XcfaLocation(name, metadata = metadata)) val location = locationLut[name] @@ -104,64 +100,40 @@ class FrontendXcfaBuilder( } builder.addVar(XcfaGlobalVar(globalDeclaration.get2(), type.nullValue)) if (type is CArray) { - initStmtList.add( - StmtLabel( - Stmts.Assign( - cast(globalDeclaration.get2(), globalDeclaration.get2().type), - cast(type.getValue("$ptrCnt"), globalDeclaration.get2().type) - ) - ) - ) + initStmtList.add(StmtLabel( + Stmts.Assign(cast(globalDeclaration.get2(), globalDeclaration.get2().type), + cast(type.getValue("$ptrCnt"), globalDeclaration.get2().type)) + )) } else { if (globalDeclaration.get1().initExpr != null && globalDeclaration.get1().initExpr.expression !is UnsupportedInitializer) { - initStmtList.add( - StmtLabel( - Stmts.Assign( - cast(globalDeclaration.get2(), globalDeclaration.get2().type), - cast( - type.castTo(globalDeclaration.get1().initExpr.expression), - globalDeclaration.get2().type - ) - ) - ) - ) + initStmtList.add(StmtLabel( + Stmts.Assign(cast(globalDeclaration.get2(), globalDeclaration.get2().type), + cast(type.castTo(globalDeclaration.get1().initExpr.expression), + globalDeclaration.get2().type)) + )) } else { - initStmtList.add( - StmtLabel( - Stmts.Assign( - cast(globalDeclaration.get2(), globalDeclaration.get2().type), - cast(type.nullValue, globalDeclaration.get2().type) - ) - ) - ) + initStmtList.add(StmtLabel( + Stmts.Assign(cast(globalDeclaration.get2(), globalDeclaration.get2().type), + cast(type.nullValue, globalDeclaration.get2().type)) + )) } } if (globalDeclaration.get1().arrayDimensions.size == 1) { - val bounds = ExprUtils.simplify( - CComplexType.getUnsignedLong(parseContext) - .castTo(globalDeclaration.get1().arrayDimensions[0].expression) - ) - checkState( - bounds is IntLitExpr || bounds is BvLitExpr, - "Only IntLit and BvLit expression expected here." - ) - val literalValue = - if (bounds is IntLitExpr) bounds.value.toLong() else BvUtils.neutralBvLitExprToBigInteger( - bounds as BvLitExpr - ).toLong() + val bounds = ExprUtils.simplify(CComplexType.getUnsignedLong(parseContext) + .castTo(globalDeclaration.get1().arrayDimensions[0].expression)) + checkState(bounds is IntLitExpr || bounds is BvLitExpr, + "Only IntLit and BvLit expression expected here.") + val literalValue = if (bounds is IntLitExpr) bounds.value.toLong() else BvUtils.neutralBvLitExprToBigInteger( + bounds as BvLitExpr).toLong() val literalToExpr = { x: Long -> if (bounds is IntLitExpr) IntLitExpr.of( - BigInteger.valueOf(x) - ) else BvUtils.bigIntegerToNeutralBvLitExpr( - BigInteger.valueOf(x), - (bounds as BvLitExpr).type.size - ) + BigInteger.valueOf(x)) else BvUtils.bigIntegerToNeutralBvLitExpr(BigInteger.valueOf(x), + (bounds as BvLitExpr).type.size) } - val initExprs: Map> = - (globalDeclaration.get1()?.initExpr as? CInitializerList)?.statements?.mapIndexed { i, it -> - Pair(i, it.get2().expression) - }?.toMap() ?: emptyMap() + val initExprs: Map> = (globalDeclaration.get1()?.initExpr as? CInitializerList)?.statements?.mapIndexed { i, it -> + Pair(i, it.get2().expression) + }?.toMap() ?: emptyMap() for (i in 0 until literalValue) { checkState(globalDeclaration.get1().actualType is CArray, "Only arrays are expected here") val embeddedType = (globalDeclaration.get1().actualType as CArray).embeddedType @@ -183,10 +155,8 @@ class FrontendXcfaBuilder( return builder } - private fun handleFunction( - function: CFunction, param: List, - xcfaBuilder: XcfaBuilder - ): XcfaProcedureBuilder { + private fun handleFunction(function: CFunction, param: List, + xcfaBuilder: XcfaBuilder): XcfaProcedureBuilder { locationLut.clear() val flatVariables = function.flatVariables val funcDecl = function.funcDecl @@ -213,8 +183,7 @@ class FrontendXcfaBuilder( for (functionParam in funcDecl.functionParams) { Preconditions.checkState( functionParam.actualType is CVoid || functionParam.varDecls.size > 0, - "Function param should have an associated variable!" - ) + "Function param should have an associated variable!") for (varDecl in functionParam.varDecls) { if (varDecl != null) builder.addParam(varDecl, ParamDirection.IN) } @@ -224,14 +193,10 @@ class FrontendXcfaBuilder( builder.addVar(flatVariable) val type = CComplexType.getType(flatVariable.ref, parseContext) if ((type is CArray || type is CStruct) && builder.getParams().none { it.first == flatVariable }) { - initStmtList.add( - StmtLabel( - Stmts.Assign( - cast(flatVariable, flatVariable.type), - cast(type.getValue("$ptrCnt"), flatVariable.type) - ) - ) - ) + initStmtList.add(StmtLabel( + Stmts.Assign(cast(flatVariable, flatVariable.type), + cast(type.getValue("$ptrCnt"), flatVariable.type)) + )) } } builder.createInitLoc(getMetadata(function)) @@ -247,10 +212,8 @@ class FrontendXcfaBuilder( val endinit = getAnonymousLoc(builder, getMetadata(function)) builder.addLoc(endinit) - val initEdge = XcfaEdge( - init, endinit, SequenceLabel(initStmtList), - metadata = getMetadata(function) - ) + val initEdge = XcfaEdge(init, endinit, SequenceLabel(initStmtList), + metadata = getMetadata(function)) builder.addEdge(initEdge) init = endinit builder.createFinalLoc(getMetadata(function)) @@ -294,13 +257,10 @@ class FrontendXcfaBuilder( } is RefExpr<*> -> { - StmtLabel( - Stmts.Assign( - cast(lValue.decl as VarDecl<*>, (lValue.decl as VarDecl<*>).type), - cast(CComplexType.getType(lValue, parseContext).castTo(rExpression), lValue.type) - ), - metadata = getMetadata(statement) - ) + StmtLabel(Stmts.Assign( + cast(lValue.decl as VarDecl<*>, (lValue.decl as VarDecl<*>).type), + cast(CComplexType.getType(lValue, parseContext).castTo(rExpression), lValue.type)), + metadata = getMetadata(statement)) } else -> { @@ -321,23 +281,17 @@ class FrontendXcfaBuilder( xcfaEdge = XcfaEdge(initLoc, middleLoc1, label, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - xcfaEdge = XcfaEdge( - middleLoc1, location, + xcfaEdge = XcfaEdge(middleLoc1, location, StmtLabel(type.limit(lhs.ref), metadata = getMetadata(statement)), - metadata = getMetadata(statement) - ) + metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - xcfaEdge = XcfaEdge( - middleLoc1, middleLoc2, + xcfaEdge = XcfaEdge(middleLoc1, middleLoc2, StmtLabel(Assume(Not(type.limit(lhs.ref).cond)), metadata = getMetadata(statement)), - metadata = getMetadata(statement) - ) + metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - xcfaEdge = XcfaEdge( - middleLoc2, location, + xcfaEdge = XcfaEdge(middleLoc2, location, InvokeLabel("overflow", listOf(), metadata = getMetadata(statement)), - metadata = getMetadata(statement) - ) + metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } return location @@ -355,13 +309,11 @@ class FrontendXcfaBuilder( builder.addEdge(xcfaEdge) val location = getAnonymousLoc(builder, metadata = getMetadata(statement)) builder.addLoc(location) - xcfaEdge = XcfaEdge( - initLoc, location, StmtLabel( - statement.assumeStmt, - choiceType = ChoiceType.MAIN_PATH, - metadata = getMetadata(statement) - ), metadata = getMetadata(statement) - ) + xcfaEdge = XcfaEdge(initLoc, location, StmtLabel( + statement.assumeStmt, + choiceType = ChoiceType.MAIN_PATH, + metadata = getMetadata(statement) + ), metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) return location } @@ -378,10 +330,8 @@ class FrontendXcfaBuilder( builder.addEdge(edge) check(breakLoc != null) edge = XcfaEdge(initLoc, breakLoc, metadata = getMetadata(statement)) - val unreachableLoc = XcfaLocation( - "Unreachable" + XcfaLocation.uniqueCounter(), - metadata = getMetadata(statement) - ) + val unreachableLoc = XcfaLocation("Unreachable" + XcfaLocation.uniqueCounter(), + metadata = getMetadata(statement)) builder.addLoc(unreachableLoc) builder.addEdge(edge) return unreachableLoc @@ -405,10 +355,8 @@ class FrontendXcfaBuilder( builder.addVar(ret) params.add(ret.ref) for (cStatement in myParams) { - initLoc = cStatement.accept( - this, - ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc) - ) + initLoc = cStatement.accept(this, + ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc)) } params.addAll(myParams.stream().map { obj: CStatement -> obj.expression } .collect(Collectors.toList())) @@ -440,20 +388,14 @@ class FrontendXcfaBuilder( val edge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(edge) lastLoc = initLoc - if (preStatements != null) lastLoc = preStatements.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + if (preStatements != null) lastLoc = preStatements.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) for (cStatement in statement.getcStatementList()) { - if (cStatement != null) lastLoc = cStatement.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + if (cStatement != null) lastLoc = cStatement.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) } - if (postStatements != null) lastLoc = postStatements.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + if (postStatements != null) lastLoc = postStatements.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) return lastLoc } @@ -470,8 +412,7 @@ class FrontendXcfaBuilder( check(continueLoc != null) edge = XcfaEdge(initLoc, continueLoc, metadata = getMetadata(statement)) val unreachableLoc: XcfaLocation = XcfaLocation( - "Unreachable" + XcfaLocation.uniqueCounter(), metadata = getMetadata(statement) - ) + "Unreachable" + XcfaLocation.uniqueCounter(), metadata = getMetadata(statement)) builder.addLoc(unreachableLoc) builder.addEdge(edge) return unreachableLoc @@ -506,40 +447,26 @@ class FrontendXcfaBuilder( builder.addLoc(initLoc) var xcfaEdge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val lastBody = body.accept( - this, - ParamPack(builder, initLoc, endLoc, innerEndLoc, returnLoc) - ) + val lastBody = body.accept(this, + ParamPack(builder, initLoc, endLoc, innerEndLoc, returnLoc)) xcfaEdge = XcfaEdge(lastBody, innerEndLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val lastPre = buildWithoutPostStatement( - guard, - ParamPack(builder, innerEndLoc, null, null, returnLoc) - ) - val assume = StmtLabel( - Stmts.Assume( - AbstractExprs.Neq(guard.expression, CComplexType.getType(guard.expression, parseContext).nullValue) - ), - choiceType = ChoiceType.MAIN_PATH, metadata = getMetadata(guard) - ) + val lastPre = buildWithoutPostStatement(guard, + ParamPack(builder, innerEndLoc, null, null, returnLoc)) + val assume = StmtLabel(Stmts.Assume( + AbstractExprs.Neq(guard.expression, CComplexType.getType(guard.expression, parseContext).nullValue)), + choiceType = ChoiceType.MAIN_PATH, metadata = getMetadata(guard)) xcfaEdge = XcfaEdge(lastPre, innerInnerGuard, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val assume1 = StmtLabel( - Stmts.Assume( - AbstractExprs.Eq(guard.expression, CComplexType.getType(guard.expression, parseContext).nullValue) - ), - choiceType = ChoiceType.ALTERNATIVE_PATH, metadata = getMetadata(guard) - ) + val assume1 = StmtLabel(Stmts.Assume( + AbstractExprs.Eq(guard.expression, CComplexType.getType(guard.expression, parseContext).nullValue)), + choiceType = ChoiceType.ALTERNATIVE_PATH, metadata = getMetadata(guard)) xcfaEdge = XcfaEdge(lastPre, outerInnerGuard, assume1, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val outerLastGuard = buildPostStatement( - guard, - ParamPack(builder, outerInnerGuard, null, null, null) - ) - val innerLastGuard = buildPostStatement( - guard, - ParamPack(builder, innerInnerGuard, null, null, null) - ) + val outerLastGuard = buildPostStatement(guard, + ParamPack(builder, outerInnerGuard, null, null, null)) + val innerLastGuard = buildPostStatement(guard, + ParamPack(builder, innerInnerGuard, null, null, null)) xcfaEdge = XcfaEdge(outerLastGuard, endLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) xcfaEdge = XcfaEdge(innerLastGuard, initLoc, metadata = getMetadata(statement)) @@ -578,21 +505,13 @@ class FrontendXcfaBuilder( builder.addLoc(startIncrement) var xcfaEdge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val lastInit = if (init == null) initLoc else init.accept( - this, - ParamPack(builder, initLoc, null, null, returnLoc) - ) - val lastTest = if (guard == null) lastInit else buildWithoutPostStatement( - guard, - ParamPack(builder, lastInit!!, null, null, returnLoc) - ) + val lastInit = if (init == null) initLoc else init.accept(this, + ParamPack(builder, initLoc, null, null, returnLoc)) + val lastTest = if (guard == null) lastInit else buildWithoutPostStatement(guard, + ParamPack(builder, lastInit!!, null, null, returnLoc)) val assume = StmtLabel( - Stmts.Assume( - if (guard == null) True() else AbstractExprs.Neq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(if (guard == null) True() else AbstractExprs.Neq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.MAIN_PATH, metadata = if (guard == null) getMetadata(statement) else getMetadata(guard) ) @@ -600,42 +519,30 @@ class FrontendXcfaBuilder( xcfaEdge = XcfaEdge(lastTest, endInit, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) val assume1 = StmtLabel( - Stmts.Assume( - if (guard == null) False() else AbstractExprs.Eq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(if (guard == null) False() else AbstractExprs.Eq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.ALTERNATIVE_PATH, metadata = if (guard == null) getMetadata(statement) else getMetadata(guard) ) xcfaEdge = XcfaEdge(lastTest, outerLastTest, assume1, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val innerLastGuard = if (guard == null) endInit else buildPostStatement( - guard, - ParamPack(builder, endInit, endLoc, startIncrement, returnLoc) - ) - val lastBody = if (body == null) innerLastGuard else body.accept( - this, - ParamPack(builder, innerLastGuard, endLoc, startIncrement, returnLoc) - ) + val innerLastGuard = if (guard == null) endInit else buildPostStatement(guard, + ParamPack(builder, endInit, endLoc, startIncrement, returnLoc)) + val lastBody = if (body == null) innerLastGuard else body.accept(this, + ParamPack(builder, innerLastGuard, endLoc, startIncrement, returnLoc)) xcfaEdge = XcfaEdge(lastBody, startIncrement, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) if (increment != null) { - val lastIncrement = increment.accept( - this, - ParamPack(builder, startIncrement, null, null, returnLoc) - ) + val lastIncrement = increment.accept(this, + ParamPack(builder, startIncrement, null, null, returnLoc)) xcfaEdge = XcfaEdge(lastIncrement, lastInit, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } else { xcfaEdge = XcfaEdge(startIncrement, lastInit, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } - val outerLastGuard = if (guard == null) outerLastTest else buildPostStatement( - guard, - ParamPack(builder, outerLastTest, endLoc, startIncrement, returnLoc) - ) + val outerLastGuard = if (guard == null) outerLastTest else buildPostStatement(guard, + ParamPack(builder, outerLastTest, endLoc, startIncrement, returnLoc)) xcfaEdge = XcfaEdge(outerLastGuard, endLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) return endLoc @@ -651,14 +558,11 @@ class FrontendXcfaBuilder( builder.addLoc(initLoc) var edge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(edge) - edge = XcfaEdge( - initLoc, - getLoc(builder, statement.label, metadata = getMetadata(statement)) - ) + edge = XcfaEdge(initLoc, + getLoc(builder, statement.label, metadata = getMetadata(statement))) builder.addLoc(getLoc(builder, statement.label, metadata = getMetadata(statement))) val unreachableLoc: XcfaLocation = XcfaLocation( - "Unreachable" + XcfaLocation.uniqueCounter(), metadata = getMetadata(statement) - ) + "Unreachable" + XcfaLocation.uniqueCounter(), metadata = getMetadata(statement)) builder.addLoc(unreachableLoc) builder.addEdge(edge) return unreachableLoc @@ -683,51 +587,33 @@ class FrontendXcfaBuilder( builder.addLoc(initLoc) var xcfaEdge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val endGuard = buildWithoutPostStatement( - guard, - ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc) - ) + val endGuard = buildWithoutPostStatement(guard, + ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc)) val assume = StmtLabel( - Stmts.Assume( - AbstractExprs.Neq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(AbstractExprs.Neq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.MAIN_PATH, metadata = getMetadata(guard) ) xcfaEdge = XcfaEdge(endGuard, mainBranch, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) val assume1 = StmtLabel( - Stmts.Assume( - AbstractExprs.Eq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(AbstractExprs.Eq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.ALTERNATIVE_PATH, metadata = getMetadata(guard) ) xcfaEdge = XcfaEdge(endGuard, elseBranch, assume1, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val mainAfterGuard = buildPostStatement( - guard, - ParamPack(builder, mainBranch, breakLoc, continueLoc, returnLoc) - ) - val mainEnd = body.accept( - this, - ParamPack(builder, mainAfterGuard, breakLoc, continueLoc, returnLoc) - ) + val mainAfterGuard = buildPostStatement(guard, + ParamPack(builder, mainBranch, breakLoc, continueLoc, returnLoc)) + val mainEnd = body.accept(this, + ParamPack(builder, mainAfterGuard, breakLoc, continueLoc, returnLoc)) if (elseStatement != null) { - val elseAfterGuard = buildPostStatement( - guard, - ParamPack(builder, elseBranch, breakLoc, continueLoc, returnLoc) - ) - val elseEnd = elseStatement.accept( - this, - ParamPack(builder, elseAfterGuard, breakLoc, continueLoc, returnLoc) - ) + val elseAfterGuard = buildPostStatement(guard, + ParamPack(builder, elseBranch, breakLoc, continueLoc, returnLoc)) + val elseEnd = elseStatement.accept(this, + ParamPack(builder, elseAfterGuard, breakLoc, continueLoc, returnLoc)) xcfaEdge = XcfaEdge(elseEnd, endLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } else { @@ -763,24 +649,16 @@ class FrontendXcfaBuilder( builder.addLoc(initLoc) val xcfaEdge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val endExpr = expr?.accept( - this, - ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc) - ) ?: initLoc + val endExpr = expr?.accept(this, + ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc)) ?: initLoc val endLoc = getAnonymousLoc(builder, metadata = getMetadata(statement)) builder.addLoc(endLoc) val key: VarDecl<*> = builder.getParams()[0].first check(returnLoc != null) val type = CComplexType.getType(key.ref, parseContext) - val edge = XcfaEdge( - endExpr, returnLoc, StmtLabel( - Stmts.Assign( - cast(key, key.type), - cast(type.castTo(expr?.expression ?: type.nullValue), key.type) - ), - metadata = getMetadata(statement) - ), metadata = getMetadata(statement) - ) + val edge = XcfaEdge(endExpr, returnLoc, StmtLabel(Stmts.Assign(cast(key, key.type), + cast(type.castTo(expr?.expression ?: type.nullValue), key.type)), + metadata = getMetadata(statement)), metadata = getMetadata(statement)) builder.addEdge(edge) return endLoc } @@ -799,18 +677,14 @@ class FrontendXcfaBuilder( builder.addLoc(endLoc) val edge: XcfaEdge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(edge) - val endInit = buildWithoutPostStatement( - testValue, - ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc) - ) + val endInit = buildWithoutPostStatement(testValue, + ParamPack(builder, initLoc, breakLoc, continueLoc, returnLoc)) Preconditions.checkState(body is CCompound, "Switch body has to be a CompoundStatement!") var defaultExpr: Expr? = True() for (cStatement in (body as CCompound).getcStatementList()) { if (cStatement is CCase) { - defaultExpr = BoolExprs.And( - defaultExpr, - AbstractExprs.Neq(testValue.expression, cStatement.expr.expression) - ) + defaultExpr = BoolExprs.And(defaultExpr, + AbstractExprs.Neq(testValue.expression, cStatement.expr.expression)) } } var lastLocation: XcfaLocation? = null @@ -823,24 +697,19 @@ class FrontendXcfaBuilder( builder.addEdge(xcfaEdge) } if (cStatement is CCase) { - val afterGuard = buildPostStatement( - testValue, - ParamPack(builder, checkNotNull(endInit), breakLoc, continueLoc, returnLoc) - ) + val afterGuard = buildPostStatement(testValue, + ParamPack(builder, checkNotNull(endInit), breakLoc, continueLoc, returnLoc)) val assume = StmtLabel( Stmts.Assume( - AbstractExprs.Eq(testValue.expression, cStatement.expr.expression) - ), + AbstractExprs.Eq(testValue.expression, cStatement.expr.expression)), choiceType = ChoiceType.MAIN_PATH, metadata = getMetadata(testValue) ) xcfaEdge = XcfaEdge(afterGuard, location, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } else if (cStatement is CDefault) { - val afterGuard = buildPostStatement( - testValue, - ParamPack(builder, endInit!!, breakLoc, continueLoc, returnLoc) - ) + val afterGuard = buildPostStatement(testValue, + ParamPack(builder, endInit!!, breakLoc, continueLoc, returnLoc)) val assume = StmtLabel( Stmts.Assume(defaultExpr), choiceType = ChoiceType.MAIN_PATH, // TODO: is this what validators expect? @@ -849,16 +718,12 @@ class FrontendXcfaBuilder( xcfaEdge = XcfaEdge(afterGuard, location, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } - lastLocation = cStatement.accept( - this, - ParamPack(builder, location, endLoc, continueLoc, returnLoc) - ) + lastLocation = cStatement.accept(this, + ParamPack(builder, location, endLoc, continueLoc, returnLoc)) } if (lastLocation != null) { - val xcfaEdge: XcfaEdge = XcfaEdge( - lastLocation, endLoc, - metadata = getMetadata(statement) - ) + val xcfaEdge: XcfaEdge = XcfaEdge(lastLocation, endLoc, + metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } return endLoc @@ -884,66 +749,46 @@ class FrontendXcfaBuilder( for (i in 0 until if (UNROLL_COUNT == 0) 1 else UNROLL_COUNT) { val innerLoop = getAnonymousLoc(builder, metadata = getMetadata(statement)) builder.addLoc(innerLoop) - val testEndLoc = buildWithoutPostStatement( - guard, - ParamPack(builder, initLoc, null, null, returnLoc) - ) + val testEndLoc = buildWithoutPostStatement(guard, + ParamPack(builder, initLoc, null, null, returnLoc)) if (UNROLL_COUNT > 0) { initLoc = getAnonymousLoc(builder, metadata = getMetadata(statement)) builder.addLoc(initLoc) } val assume = StmtLabel( - Stmts.Assume( - AbstractExprs.Neq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(AbstractExprs.Neq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.MAIN_PATH, metadata = getMetadata(guard) ) xcfaEdge = XcfaEdge(testEndLoc, innerLoop, assume, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) val assume1 = StmtLabel( - Stmts.Assume( - AbstractExprs.Eq( - guard.expression, - CComplexType.getType(guard.expression, parseContext).nullValue - ) - ), + Stmts.Assume(AbstractExprs.Eq(guard.expression, + CComplexType.getType(guard.expression, parseContext).nullValue)), choiceType = ChoiceType.ALTERNATIVE_PATH, metadata = getMetadata(statement) ) - xcfaEdge = XcfaEdge( - testEndLoc, outerBeforeGuard, assume1, - metadata = getMetadata(statement) - ) + xcfaEdge = XcfaEdge(testEndLoc, outerBeforeGuard, assume1, + metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) - val lastGuard = buildPostStatement( - guard, - ParamPack(builder, innerLoop, endLoc, initLoc, returnLoc) - ) - val lastBody = body.accept( - this, - ParamPack(builder, lastGuard, endLoc, initLoc, returnLoc) - ) + val lastGuard = buildPostStatement(guard, + ParamPack(builder, innerLoop, endLoc, initLoc, returnLoc)) + val lastBody = body.accept(this, + ParamPack(builder, lastGuard, endLoc, initLoc, returnLoc)) xcfaEdge = XcfaEdge(lastBody, initLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) } - val outerLastGuard = buildPostStatement( - guard, - ParamPack(builder, outerBeforeGuard, null, null, null) - ) + val outerLastGuard = buildPostStatement(guard, + ParamPack(builder, outerBeforeGuard, null, null, null)) xcfaEdge = XcfaEdge(outerLastGuard, endLoc, metadata = getMetadata(statement)) builder.addEdge(xcfaEdge) return endLoc } private fun buildWithoutPostStatement(cStatement: CStatement, param: ParamPack): XcfaLocation { - Preconditions.checkState( - cStatement is CCompound, - "Currently only CCompounds have pre- and post statements!" - ) + Preconditions.checkState(cStatement is CCompound, + "Currently only CCompounds have pre- and post statements!") val statement = cStatement as CCompound val builder: XcfaProcedureBuilder = param.builder var lastLoc = param.lastLoc @@ -958,38 +803,28 @@ class FrontendXcfaBuilder( val edge = XcfaEdge(lastLoc, initLoc, metadata = getMetadata(statement)) builder.addEdge(edge) lastLoc = initLoc - if (preStatements != null) lastLoc = preStatements.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + if (preStatements != null) lastLoc = preStatements.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) for (i in 0 until cStatementList.size - 1) { val stmt = cStatementList[i] - if (stmt != null) lastLoc = stmt.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + if (stmt != null) lastLoc = stmt.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) } if (cStatementList.size == 0) return lastLoc val lastStatement = cStatementList[cStatementList.size - 1] lastLoc = if (postStatements == null) { - buildWithoutPostStatement( - lastStatement, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + buildWithoutPostStatement(lastStatement, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) } else { - lastStatement.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + lastStatement.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) } return lastLoc } private fun buildPostStatement(cStatement: CStatement, param: ParamPack): XcfaLocation { - Preconditions.checkState( - cStatement is CCompound, - "Currently only CCompounds have pre- and post statements!" - ) + Preconditions.checkState(cStatement is CCompound, + "Currently only CCompounds have pre- and post statements!") val statement = cStatement as CCompound val builder: XcfaProcedureBuilder = param.builder var lastLoc = param.lastLoc @@ -999,20 +834,15 @@ class FrontendXcfaBuilder( val preStatements = statement.preStatements val postStatements = statement.postStatements val cStatementList = statement.getcStatementList() - lastLoc = if (postStatements != null) postStatements.accept( - this, - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) else buildPostStatement( + lastLoc = if (postStatements != null) postStatements.accept(this, + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) else buildPostStatement( cStatementList[cStatementList.size - 1], - ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc) - ) + ParamPack(builder, lastLoc, breakLoc, continueLoc, returnLoc)) return lastLoc } - class ParamPack( - builder: XcfaProcedureBuilder, lastLoc: XcfaLocation, breakLoc: XcfaLocation?, - continueLoc: XcfaLocation?, returnLoc: XcfaLocation? - ) { + class ParamPack(builder: XcfaProcedureBuilder, lastLoc: XcfaLocation, breakLoc: XcfaLocation?, + continueLoc: XcfaLocation?, returnLoc: XcfaLocation?) { val builder: XcfaProcedureBuilder val lastLoc: XcfaLocation diff --git a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/Utils.kt b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/Utils.kt index d1faac52da..40d06bd9c1 100644 --- a/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/Utils.kt +++ b/subprojects/xcfa/c2xcfa/src/main/java/hu/bme/mit/theta/c2xcfa/Utils.kt @@ -30,10 +30,8 @@ import org.antlr.v4.runtime.CharStreams import org.antlr.v4.runtime.CommonTokenStream import java.io.InputStream -fun getXcfaFromC( - stream: InputStream, parseContext: ParseContext, collectStatistics: Boolean, - checkOverflow: Boolean, warningLogger: Logger -): Triple?> { +fun getXcfaFromC(stream: InputStream, parseContext: ParseContext, collectStatistics: Boolean, + checkOverflow: Boolean, warningLogger: Logger): Triple?> { val input = CharStreams.fromStream(stream) val lexer = CLexer(input) val tokens = CommonTokenStream(lexer) diff --git a/subprojects/xcfa/cat/src/main/java/hu/bme/mit/theta/cat/dsl/CatVisitor.kt b/subprojects/xcfa/cat/src/main/java/hu/bme/mit/theta/cat/dsl/CatVisitor.kt index 861ba376b5..6fc85e623d 100644 --- a/subprojects/xcfa/cat/src/main/java/hu/bme/mit/theta/cat/dsl/CatVisitor.kt +++ b/subprojects/xcfa/cat/src/main/java/hu/bme/mit/theta/cat/dsl/CatVisitor.kt @@ -238,8 +238,7 @@ class CatVisitor(file: File) : CatBaseVisitor() { override fun visitExprComplement(ctx: ExprComplementContext): GraphPattern { val rel = ctx.e.accept(this) return if (rel is EdgePattern) Complement(rel) else if (rel is NodePattern) ComplementNode(rel) else error( - "Mismatched types" - ) + "Mismatched types") } override fun visitExprInverse(ctx: ExprInverseContext): GraphPattern { diff --git a/subprojects/xcfa/llvm2xcfa/build.gradle.kts b/subprojects/xcfa/llvm2xcfa/build.gradle.kts index 874d563124..1888b50a11 100644 --- a/subprojects/xcfa/llvm2xcfa/build.gradle.kts +++ b/subprojects/xcfa/llvm2xcfa/build.gradle.kts @@ -36,9 +36,7 @@ tasks.test { } val linkTask = task.first() dependsOn(linkTask) - systemProperty( - "java.library.path", - linkTask.linkedFile.get().asFile.parent + ":/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib" - ) + systemProperty("java.library.path", + linkTask.linkedFile.get().asFile.parent + ":/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib") } } diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/Utils.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/Utils.kt index 4f9bbd7bee..cf5d298dab 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/Utils.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/Utils.kt @@ -52,8 +52,7 @@ private fun S.getState(varLookup: Map, VarDecl<*>>): is PredState -> PredState.of(preds.map { p -> p.changeVars(varLookup) }) is PtrState<*> -> PtrState(innerState.getState(varLookup)) else -> throw NotImplementedError( - "Generalizing variable instances is not implemented for data states that are not explicit or predicate." - ) + "Generalizing variable instances is not implemented for data states that are not explicit or predicate.") } as S class LazyDelegate(val getProperty: T.() -> P) { diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAbstractor.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAbstractor.kt index 0e2d35e29c..d17f15fda1 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAbstractor.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAbstractor.kt @@ -122,14 +122,13 @@ class XcfaAbstractor( companion object { fun builder( - argBuilder: ArgBuilder - ): BasicAbstractor.Builder { + argBuilder: ArgBuilder): BasicAbstractor.Builder { return Builder(argBuilder) } } - class Builder(argBuilder: ArgBuilder) : - BasicAbstractor.Builder(argBuilder) { + class Builder(argBuilder: ArgBuilder) + : BasicAbstractor.Builder(argBuilder) { override fun build(): BasicAbstractor { return XcfaAbstractor(argBuilder, projection, waitlist, stopCriterion, logger) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAction.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAction.kt index 798886422e..82a8e65178 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAction.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAction.kt @@ -24,10 +24,8 @@ import hu.bme.mit.theta.xcfa.passes.flatten data class XcfaAction @JvmOverloads -constructor( - val pid: Int, val edge: XcfaEdge, private val lastWrites: WriteTriples = emptyMap(), - private val nextCnt: Int = 0 -) : +constructor(val pid: Int, val edge: XcfaEdge, private val lastWrites: WriteTriples = emptyMap(), + private val nextCnt: Int = 0) : PtrAction(lastWrites, nextCnt) { val source: XcfaLocation = edge.source @@ -35,14 +33,12 @@ constructor( val label: XcfaLabel = edge.label private val stmts: List = label.toStmt().flatten() - constructor( - pid: Int, + constructor(pid: Int, source: XcfaLocation, target: XcfaLocation, label: XcfaLabel = NopLabel, lastWrites: WriteTriples = emptyMap(), - nextCnt: Int = 0 - ) : + nextCnt: Int = 0) : this(pid, XcfaEdge(source, target, label), lastWrites, nextCnt) override val stmtList: List diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAnalysis.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAnalysis.kt index d630b6ac06..64bd2e3d62 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAnalysis.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaAnalysis.kt @@ -60,8 +60,7 @@ open class XcfaAnalysis( ) : Analysis>, XcfaAction, XcfaPrec

> { init { - ConeOfInfluence.coreTransFunc = - transFunc as TransFunc>, XcfaAction, XcfaPrec> + ConeOfInfluence.coreTransFunc = transFunc as TransFunc>, XcfaAction, XcfaPrec> coreTransFunc = ConeOfInfluence.transFunc as TransFunc>, XcfaAction, XcfaPrec

> } @@ -75,28 +74,14 @@ private var tempCnt: Int = 0 fun getCoreXcfaLts() = LTS>, XcfaAction> { s -> s.processes.map { proc -> if (proc.value.locs.peek().final) { - listOf( - XcfaAction( - proc.key, - XcfaEdge( - proc.value.locs.peek(), proc.value.locs.peek(), SequenceLabel( - listOf( - proc.value.paramStmts.peek().second, - ReturnLabel(proc.value.returnStmts.peek()), - ) - ) - ), nextCnt = s.sGlobal.nextCnt - ) - ) + listOf(XcfaAction(proc.key, + XcfaEdge(proc.value.locs.peek(), proc.value.locs.peek(), SequenceLabel(listOf( + proc.value.paramStmts.peek().second, + ReturnLabel(proc.value.returnStmts.peek()), + ))), nextCnt = s.sGlobal.nextCnt)) } else if (!proc.value.paramsInitialized) { - listOf( - XcfaAction( - proc.key, XcfaEdge( - proc.value.locs.peek(), proc.value.locs.peek(), - proc.value.paramStmts.peek().first - ), nextCnt = s.sGlobal.nextCnt - ) - ) + listOf(XcfaAction(proc.key, XcfaEdge(proc.value.locs.peek(), proc.value.locs.peek(), + proc.value.paramStmts.peek().first), nextCnt = s.sGlobal.nextCnt)) } else { proc.value.locs.peek().outgoingEdges.map { edge -> val newLabel = edge.label.changeVars(proc.value.varLookup.peek()) @@ -110,21 +95,15 @@ fun getCoreXcfaLts() = LTS>, XcfaAction> { SequenceLabel(listOf(procedure.params.withIndex() .filter { it.value.second != ParamDirection.OUT }.map { iVal -> val originalVar = iVal.value.first - val tempVar = Var( - "tmp${tempCnt++}_" + originalVar.name, - originalVar.type - ) + val tempVar = Var("tmp${tempCnt++}_" + originalVar.name, + originalVar.type) lookup[originalVar] = tempVar StmtLabel( Stmts.Assign( TypeUtils.cast(tempVar, tempVar.type), - TypeUtils.cast(label.params[iVal.index], tempVar.type) - ), - metadata = label.metadata - ) - }, listOf(label.copy(tempLookup = lookup)) - ).flatten() - ) + TypeUtils.cast(label.params[iVal.index], tempVar.type)), + metadata = label.metadata) + }, listOf(label.copy(tempLookup = lookup))).flatten()) } else if (label is StartLabel) { val procedure = s.xcfa?.procedures?.find { proc -> proc.name == label.name } ?: error("No such method ${label.name}.") @@ -132,28 +111,22 @@ fun getCoreXcfaLts() = LTS>, XcfaAction> { SequenceLabel(listOf(procedure.params.withIndex() .filter { it.value.second != ParamDirection.OUT }.mapNotNull { iVal -> val originalVar = iVal.value.first - val tempVar = Var( - "tmp${tempCnt++}_" + originalVar.name, - originalVar.type - ) + val tempVar = Var("tmp${tempCnt++}_" + originalVar.name, + originalVar.type) lookup[originalVar] = tempVar val trial = Try.attempt { StmtLabel( Stmts.Assign( TypeUtils.cast(tempVar, tempVar.type), - TypeUtils.cast(label.params[iVal.index], tempVar.type) - ), - metadata = label.metadata - ) + TypeUtils.cast(label.params[iVal.index], tempVar.type)), + metadata = label.metadata) } if (trial.isSuccess) { trial.asSuccess().value } else { null } - }, listOf(label.copy(tempLookup = lookup)) - ).flatten() - ) + }, listOf(label.copy(tempLookup = lookup))).flatten()) } else label }) XcfaAction(proc.key, edge.withLabel(newNewLabel), nextCnt = s.sGlobal.nextCnt) @@ -179,8 +152,7 @@ enum class ErrorDetection { } fun getXcfaErrorPredicate( - errorDetection: ErrorDetection -): Predicate>> = when (errorDetection) { + errorDetection: ErrorDetection): Predicate>> = when (errorDetection) { ErrorDetection.ERROR_LOCATION -> Predicate>> { s -> s.processes.any { it.value.locs.peek().error } } @@ -213,14 +185,11 @@ fun getXcfaErrorPredicate( fun getPartialOrder(partialOrd: PartialOrd>) = PartialOrd>> { s1, s2 -> s1.processes == s2.processes && s1.bottom == s2.bottom && s1.mutexes == s2.mutexes && partialOrd.isLeq( - s1.sGlobal, s2.sGlobal - ) + s1.sGlobal, s2.sGlobal) } -private fun stackIsLeq( - s1: XcfaState>, - s2: XcfaState> -) = s2.processes.keys.all { pid -> +private fun stackIsLeq(s1: XcfaState>, + s2: XcfaState>) = s2.processes.keys.all { pid -> s1.processes[pid]?.let { ps1 -> val ps2 = s2.processes.getValue(pid) ps1.locs.peek() == ps2.locs.peek() && ps1.paramsInitialized && ps2.paramsInitialized @@ -229,18 +198,15 @@ private fun stackIsLeq( fun getStackPartialOrder(partialOrd: PartialOrd>) = PartialOrd>> { s1, s2 -> - s1.processes.size == s2.processes.size && stackIsLeq( - s1, - s2 - ) && s1.bottom == s2.bottom && s1.mutexes == s2.mutexes + s1.processes.size == s2.processes.size && stackIsLeq(s1, + s2) && s1.bottom == s2.bottom && s1.mutexes == s2.mutexes && partialOrd.isLeq(s1.withGeneralizedVars(), s2.withGeneralizedVars()) } private fun >, P : XcfaPrec> getXcfaArgBuilder( analysis: Analysis, lts: LTS>, XcfaAction>, - errorDetection: ErrorDetection -) + errorDetection: ErrorDetection) : ArgBuilder = ArgBuilder.create( lts, @@ -267,19 +233,13 @@ fun >, P : XcfaPrec> getXcfa /// EXPL -private fun getExplXcfaInitFunc( - xcfa: XCFA, - solver: Solver -): (XcfaPrec>) -> List>> { +private fun getExplXcfaInitFunc(xcfa: XCFA, + solver: Solver): (XcfaPrec>) -> List>> { val processInitState = xcfa.initProcedures.mapIndexed { i, it -> val initLocStack: LinkedList = LinkedList() initLocStack.add(it.first.initLoc) - Pair( - i, XcfaProcessState( - initLocStack, prefix = "T$i", - varLookup = LinkedList(listOf(createLookup(it.first, "T$i", ""))) - ) - ) + Pair(i, XcfaProcessState(initLocStack, prefix = "T$i", + varLookup = LinkedList(listOf(createLookup(it.first, "T$i", ""))))) }.toMap() return { p -> ExplInitFunc.create(solver, True()).getPtrInitFunc().getInitStates(p.p) @@ -288,28 +248,19 @@ private fun getExplXcfaInitFunc( } private fun getExplXcfaTransFunc(solver: Solver, maxEnum: Int, isHavoc: Boolean): - (XcfaState>, XcfaAction, XcfaPrec>) -> List>> { - val explTransFunc = (ExplStmtTransFunc.create( - solver, - maxEnum - ) as TransFunc).getPtrTransFunc(isHavoc) + (XcfaState>, XcfaAction, XcfaPrec>) -> List>> { + val explTransFunc = (ExplStmtTransFunc.create(solver, + maxEnum) as TransFunc).getPtrTransFunc(isHavoc) return { s, a, p -> val (newSt, newAct) = s.apply(a) - explTransFunc.getSuccStates( - newSt.sGlobal, newAct, p.p.addVars( - listOf( - s.processes.map { it.value.varLookup }.flatten(), - listOf(getTempLookup(a.label)) - ).flatten() - ) - ).map { newSt.withState(it) } + explTransFunc.getSuccStates(newSt.sGlobal, newAct, p.p.addVars( + listOf(s.processes.map { it.value.varLookup }.flatten(), + listOf(getTempLookup(a.label))).flatten())).map { newSt.withState(it) } } } -class ExplXcfaAnalysis( - xcfa: XCFA, solver: Solver, maxEnum: Int, - partialOrd: PartialOrd>>, isHavoc: Boolean -) : +class ExplXcfaAnalysis(xcfa: XCFA, solver: Solver, maxEnum: Int, + partialOrd: PartialOrd>>, isHavoc: Boolean) : XcfaAnalysis>( corePartialOrd = partialOrd, coreInitFunc = getExplXcfaInitFunc(xcfa, solver), @@ -318,19 +269,13 @@ class ExplXcfaAnalysis( /// PRED -private fun getPredXcfaInitFunc( - xcfa: XCFA, - predAbstractor: PredAbstractor -): (XcfaPrec>) -> List>> { +private fun getPredXcfaInitFunc(xcfa: XCFA, + predAbstractor: PredAbstractor): (XcfaPrec>) -> List>> { val processInitState = xcfa.initProcedures.mapIndexed { i, it -> val initLocStack: LinkedList = LinkedList() initLocStack.add(it.first.initLoc) - Pair( - i, XcfaProcessState( - initLocStack, prefix = "T$i", - varLookup = LinkedList(listOf(createLookup(it.first, "T$i", ""))) - ) - ) + Pair(i, XcfaProcessState(initLocStack, prefix = "T$i", + varLookup = LinkedList(listOf(createLookup(it.first, "T$i", ""))))) }.toMap() return { p -> PredInitFunc.create(predAbstractor, True()).getPtrInitFunc().getInitStates(p.p) @@ -339,10 +284,9 @@ private fun getPredXcfaInitFunc( } private fun getPredXcfaTransFunc(predAbstractor: PredAbstractors.PredAbstractor, isHavoc: Boolean): - (XcfaState>, XcfaAction, XcfaPrec>) -> List>> { + (XcfaState>, XcfaAction, XcfaPrec>) -> List>> { val predTransFunc = (PredTransFunc.create( - predAbstractor - ) as TransFunc).getPtrTransFunc(isHavoc) + predAbstractor) as TransFunc).getPtrTransFunc(isHavoc) return { s, a, p -> val (newSt, newAct) = s.apply(a) predTransFunc.getSuccStates(newSt.sGlobal, newAct, p.p.addVars( @@ -351,10 +295,8 @@ private fun getPredXcfaTransFunc(predAbstractor: PredAbstractors.PredAbstractor, } } -class PredXcfaAnalysis( - xcfa: XCFA, solver: Solver, predAbstractor: PredAbstractor, - partialOrd: PartialOrd>>, isHavoc: Boolean -) : +class PredXcfaAnalysis(xcfa: XCFA, solver: Solver, predAbstractor: PredAbstractor, + partialOrd: PartialOrd>>, isHavoc: Boolean) : XcfaAnalysis>( corePartialOrd = partialOrd, coreInitFunc = getPredXcfaInitFunc(xcfa, predAbstractor), diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaPrecRefiner.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaPrecRefiner.kt index 40cea2bc74..64e8984d4d 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaPrecRefiner.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaPrecRefiner.kt @@ -37,10 +37,8 @@ class XcfaPrecRefiner(refToPrec: Refuta private val refToPrec: RefutationToPrec, R> = Preconditions.checkNotNull(refToPrec) - override fun refine( - prec: XcfaPrec>, trace: Trace, XcfaAction>, - refutation: R - ): XcfaPrec> { + override fun refine(prec: XcfaPrec>, trace: Trace, XcfaAction>, + refutation: R): XcfaPrec> { Preconditions.checkNotNull(trace) Preconditions.checkNotNull(prec) Preconditions.checkNotNull(refutation) @@ -50,8 +48,7 @@ class XcfaPrecRefiner(refToPrec: Refuta it.foldVarLookup().map { Pair(it.value, it.key) } }.flatten().toMap() val reverseTempLookup = if (i > 0) getTempLookup( - trace.actions[i - 1].edge.label - ).entries.associateBy( + trace.actions[i - 1].edge.label).entries.associateBy( { it.value }) { it.key } else emptyMap() val precFromRef = refToPrec.toPrec(refutation, i).changeVars(reverseVarLookup + reverseTempLookup) runningPrec = refToPrec.join(runningPrec, precFromRef) @@ -86,12 +83,10 @@ fun

P.addVars(lookups: Collection, VarDecl<*>>>): P = else when (this) { is ExplPrec -> ExplPrec.of( - vars.map { lookups.map { lookup -> it.changeVars(lookup) } }.flatten() - ) as P + vars.map { lookups.map { lookup -> it.changeVars(lookup) } }.flatten()) as P is PredPrec -> PredPrec.of( - preds.map { lookups.map { lookup -> it.changeVars(lookup) } }.flatten() - ) as P + preds.map { lookups.map { lookup -> it.changeVars(lookup) } }.flatten()) as P is PtrPrec<*> -> PtrPrec(innerPrec.addVars(lookups)) as P diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaSingeExprTraceRefiner.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaSingeExprTraceRefiner.kt index 878e2a3964..ad0a385e5d 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaSingeExprTraceRefiner.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaSingeExprTraceRefiner.kt @@ -72,20 +72,15 @@ class XcfaSingleExprTraceRefiner, states: List, actions: List): Triple, List, List>, a: A -> + Triple(Pair(emptyMap(), 0), listOf(rawTrace.getState(0)), + listOf())) { i: Int, (wTripleCnt: Pair, states: List, actions: List): Triple, List, List>, a: A -> val (wTriple, cnt) = wTripleCnt val newA = (a as XcfaAction).withLastWrites(wTriple, cnt) val newState = (rawTrace.getState(i + 1) as XcfaState>).let { it.withState(PtrState(it.sGlobal.innerState.patch(newA.nextWriteTriples()))) } - Triple( - Pair(newA.nextWriteTriples(), newA.cnts.values.maxOrNull() ?: newA.inCnt), states + (newState as S), - actions + (newA as A) - ) + Triple(Pair(newA.nextWriteTriples(), newA.cnts.values.maxOrNull() ?: newA.inCnt), states + (newState as S), + actions + (newA as A)) } val traceToConcretize = Trace.of(states, actions) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaState.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaState.kt index c75bcefd8e..0054be37f2 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaState.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaState.kt @@ -52,10 +52,8 @@ data class XcfaState @JvmOverloads constructor( fun apply(a: XcfaAction): Pair, XcfaAction> { val changes: MutableList<(XcfaState) -> XcfaState> = ArrayList() - if (mutexes[""] != null && mutexes[""] != a.pid) return Pair( - copy(bottom = true), - a.withLabel(SequenceLabel(listOf(NopLabel))) - ) + if (mutexes[""] != null && mutexes[""] != a.pid) return Pair(copy(bottom = true), + a.withLabel(SequenceLabel(listOf(NopLabel)))) val processState = processes[a.pid] checkNotNull(processState) @@ -103,19 +101,12 @@ data class XcfaState @JvmOverloads constructor( is InvokeLabel -> { val proc = xcfa?.procedures?.find { proc -> proc.name == it.name } ?: error( - "No such method ${it.name}." - ) + "No such method ${it.name}.") val returnStmt = SequenceLabel( proc.params.withIndex().filter { it.value.second != ParamDirection.IN }.map { iVal -> - StmtLabel( - Assign( - cast( - (it.params[iVal.index] as RefExpr<*>).decl as VarDecl<*>, - iVal.value.first.type - ), cast(iVal.value.first.ref, iVal.value.first.type) - ), - metadata = it.metadata - ) + StmtLabel(Assign(cast((it.params[iVal.index] as RefExpr<*>).decl as VarDecl<*>, + iVal.value.first.type), cast(iVal.value.first.ref, iVal.value.first.type)), + metadata = it.metadata) }) changes.add { state -> state.invokeFunction(a.pid, proc, returnStmt, proc.params.toMap(), it.tempLookup) @@ -170,34 +161,20 @@ data class XcfaState @JvmOverloads constructor( val pid = pidCnt++ val lookup = XcfaProcessState.createLookup(procedure, "T$pid", "") newThreadLookup[startLabel.pidVar] = pid - newProcesses[pid] = XcfaProcessState( - LinkedList(listOf(procedure.initLoc)), prefix = "T$pid", + newProcesses[pid] = XcfaProcessState(LinkedList(listOf(procedure.initLoc)), prefix = "T$pid", varLookup = LinkedList(listOf(lookup)), returnStmts = LinkedList(listOf(returnStmt)), - paramStmts = LinkedList( - listOf( - Pair( - /* init */ - SequenceLabel(paramList.filter { it.value != ParamDirection.OUT }.map { - StmtLabel( - Assign( - cast(it.key.changeVars(lookup), it.key.type), - cast(it.key.changeVars(tempLookup).ref, it.key.type) - ) - ) - }), - /* deinit */ - SequenceLabel(paramList.filter { it.value != ParamDirection.IN }.map { - StmtLabel( - Assign( - cast(it.key.changeVars(tempLookup), it.key.type), - cast(it.key.changeVars(lookup).ref, it.key.type) - ) - ) - }), - ) - ) - ) - ) + paramStmts = LinkedList(listOf(Pair( + /* init */ + SequenceLabel(paramList.filter { it.value != ParamDirection.OUT }.map { + StmtLabel(Assign(cast(it.key.changeVars(lookup), it.key.type), + cast(it.key.changeVars(tempLookup).ref, it.key.type))) + }), + /* deinit */ + SequenceLabel(paramList.filter { it.value != ParamDirection.IN }.map { + StmtLabel(Assign(cast(it.key.changeVars(tempLookup), it.key.type), + cast(it.key.changeVars(lookup).ref, it.key.type))) + }), + )))) val newMutexes = LinkedHashMap(mutexes) newMutexes["$pid"] = pid @@ -212,10 +189,8 @@ data class XcfaState @JvmOverloads constructor( return copy(processes = newProcesses, mutexes = newMutexes) } - private fun invokeFunction( - pid: Int, proc: XcfaProcedure, returnStmt: XcfaLabel, - paramList: Map, ParamDirection>, tempLookup: Map, VarDecl<*>> - ): XcfaState { + private fun invokeFunction(pid: Int, proc: XcfaProcedure, returnStmt: XcfaLabel, + paramList: Map, ParamDirection>, tempLookup: Map, VarDecl<*>>): XcfaState { val newProcesses: MutableMap = LinkedHashMap(processes) newProcesses[pid] = checkNotNull(processes[pid]?.enterFunction(proc, returnStmt, paramList, tempLookup)) return copy(processes = newProcesses) @@ -255,12 +230,10 @@ data class XcfaState @JvmOverloads constructor( } } -data class XcfaProcessState( - val locs: LinkedList, val varLookup: LinkedList, VarDecl<*>>>, +data class XcfaProcessState(val locs: LinkedList, val varLookup: LinkedList, VarDecl<*>>>, val returnStmts: LinkedList = LinkedList(listOf(NopLabel)), val paramStmts: LinkedList> = LinkedList(listOf(Pair(NopLabel, NopLabel))), - val paramsInitialized: Boolean = false, val prefix: String = "" -) { + val paramsInitialized: Boolean = false, val prefix: String = "") { internal var popped: XcfaLocation? = null // stores if the stack was popped due to abstract stack covering @@ -277,10 +250,8 @@ data class XcfaProcessState( else -> "${locs.peek()!!} [${locs.size}], initilized=$paramsInitialized" } - fun enterFunction( - xcfaProcedure: XcfaProcedure, returnStmt: XcfaLabel, paramList: Map, ParamDirection>, - tempLookup: Map, VarDecl<*>> - ): XcfaProcessState { + fun enterFunction(xcfaProcedure: XcfaProcedure, returnStmt: XcfaLabel, paramList: Map, ParamDirection>, + tempLookup: Map, VarDecl<*>>): XcfaProcessState { val deque: LinkedList = LinkedList(locs) val varLookup: LinkedList, VarDecl<*>>> = LinkedList(varLookup) val returnStmts: LinkedList = LinkedList(returnStmts) @@ -289,32 +260,20 @@ data class XcfaProcessState( val lookup = createLookup(xcfaProcedure, prefix, "P${procCnt++}") varLookup.push(lookup) returnStmts.push(returnStmt) - paramStmts.push( - Pair( - /* init */ - SequenceLabel(paramList.filter { it.value != ParamDirection.OUT }.map { - StmtLabel( - Assign( - cast(it.key.changeVars(lookup), it.key.type), - cast(it.key.changeVars(tempLookup).ref, it.key.type) - ) - ) - }), - /* deinit */ - SequenceLabel(paramList.filter { it.value != ParamDirection.IN }.map { - StmtLabel( - Assign( - cast(it.key.changeVars(tempLookup), it.key.type), - cast(it.key.changeVars(lookup).ref, it.key.type) - ) - ) - }), - ) - ) - return copy( - locs = deque, varLookup = varLookup, returnStmts = returnStmts, paramStmts = paramStmts, - paramsInitialized = false - ) + paramStmts.push(Pair( + /* init */ + SequenceLabel(paramList.filter { it.value != ParamDirection.OUT }.map { + StmtLabel(Assign(cast(it.key.changeVars(lookup), it.key.type), + cast(it.key.changeVars(tempLookup).ref, it.key.type))) + }), + /* deinit */ + SequenceLabel(paramList.filter { it.value != ParamDirection.IN }.map { + StmtLabel(Assign(cast(it.key.changeVars(tempLookup), it.key.type), + cast(it.key.changeVars(lookup).ref, it.key.type))) + }), + )) + return copy(locs = deque, varLookup = varLookup, returnStmts = returnStmts, paramStmts = paramStmts, + paramsInitialized = false) } fun exitFunction(): XcfaProcessState { @@ -349,10 +308,8 @@ data class XcfaProcessState( companion object { - fun createLookup( - proc: XcfaProcedure, threadPrefix: String, - procPrefix: String - ): Map, VarDecl<*>> = listOf(proc.params.map { it.first }, proc.vars).flatten() + fun createLookup(proc: XcfaProcedure, threadPrefix: String, + procPrefix: String): Map, VarDecl<*>> = listOf(proc.params.map { it.first }, proc.vars).flatten() .associateWith { val sj = StringJoiner("::") if (threadPrefix != "") sj.add(threadPrefix) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateAdapter.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateAdapter.kt index 7b22edcdea..30d7147c72 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateAdapter.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateAdapter.kt @@ -61,14 +61,12 @@ class XcfaStateAdapter(val gsonSupplier: () -> Gson, val stateTypeSupplier: () - val bottom: Boolean = gson.fromJson(reader, Boolean::class.java) reader.endObject() - return XcfaState( - xcfa = null, + return XcfaState(xcfa = null, processes = processes, sGlobal = sGlobal, mutexes = mutexes, threadLookup = threadLookup, - bottom = bottom - ) + bottom = bottom) } private fun initGson() { diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaToMonolithicExpr.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaToMonolithicExpr.kt index 882ecae465..d91174ed82 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaToMonolithicExpr.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/XcfaToMonolithicExpr.kt @@ -52,16 +52,12 @@ fun XCFA.toMonolithicExpr(): MonolithicExpr { } val locVar = Decls.Var("__loc_", IntExprs.Int()) val tranList = proc.edges.map { (source, target, label): XcfaEdge -> - SequenceStmt.of( - listOf( - AssumeStmt.of(Eq(locVar.ref, IntExprs.Int(map[source]!!))), - label.toStmt(), - AssignStmt.of( - locVar, - IntExprs.Int(map[target]!!) - ) - ) - ) + SequenceStmt.of(listOf( + AssumeStmt.of(Eq(locVar.ref, IntExprs.Int(map[source]!!))), + label.toStmt(), + AssignStmt.of(locVar, + IntExprs.Int(map[target]!!)) + )) }.toList() val trans = NonDetStmt.of(tranList) val transUnfold = StmtUtils.toExpr(trans, VarIndexingFactory.indexing(0)) @@ -99,24 +95,16 @@ fun XCFA.valToState(val1: Valuation): XcfaState> { } return XcfaState( xcfa = this, - processes = mapOf( - Pair( - 0, XcfaProcessState( - locs = LinkedList( - listOf(map[(valMap[valMap.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()]) - ), - varLookup = LinkedList(), - ) - ) - ), + processes = mapOf(Pair(0, XcfaProcessState( + locs = LinkedList( + listOf(map[(valMap[valMap.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()])), + varLookup = LinkedList(), + ))), PtrState(ExplState.of( ImmutableValuation.from( val1.toMap() .filter { it.key.name != "__loc_" && !it.key.name.startsWith("__temp_") } - .map { Pair(Decls.Var("_" + "_" + it.key.name, it.key.type), it.value) }.toMap() - ) - ) - ), + .map { Pair(Decls.Var("_" + "_" + it.key.name, it.key.type), it.value) }.toMap()))), mutexes = emptyMap(), threadLookup = emptyMap(), bottom = false diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/coi/XcfaCoiMultiThread.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/coi/XcfaCoiMultiThread.kt index 6560d5ea82..0500b5d88b 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/coi/XcfaCoiMultiThread.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/coi/XcfaCoiMultiThread.kt @@ -90,10 +90,8 @@ class XcfaCoiMultiThread(xcfa: XCFA) : XcfaCoi(xcfa) { } } - private fun isObserved( - action: A, procedures: MutableList, - multipleProcedures: Set - ): Boolean { + private fun isObserved(action: A, procedures: MutableList, + multipleProcedures: Set): Boolean { val toVisit = edgeToProcedure.keys.filter { it.source == action.edge.source && it.target == action.edge.target }.toMutableList() diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcChecker.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcChecker.kt index 69c695ca39..6ffa9bc1fb 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcChecker.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcChecker.kt @@ -74,16 +74,14 @@ class XcfaOcChecker(xcfa: XCFA, decisionProcedure: OcDecisionProcedureType, priv private val rfs = mutableMapOf, MutableSet>() override fun check( - prec: XcfaPrec? - ): SafetyResult>, XcfaAction>> = let { + prec: XcfaPrec?): SafetyResult>, XcfaAction>> = let { if (xcfa.initProcedures.size > 1) error("Multiple entry points are not supported by OC checker.") logger.write(Logger.Level.MAINSTEP, "Adding constraints...\n") xcfa.initProcedures.forEach { processThread(Thread(it.first)) } addCrossThreadRelations() if (!addToSolver()) return@let SafetyResult.safe>, XcfaAction>>( - EmptyWitness.getInstance() - ) // no violations in the model + EmptyWitness.getInstance()) // no violations in the model logger.write(Logger.Level.MAINSTEP, "Start checking...\n") val status = ocChecker.check(events, pos, rfs) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcTraceExtractor.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcTraceExtractor.kt index ad96ab9606..05ff67fc9e 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcTraceExtractor.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/oc/XcfaOcTraceExtractor.kt @@ -75,10 +75,8 @@ internal class XcfaOcTraceExtractor( val nextEdge = eventTrace.getOrNull(index + 1)?.edge if (nextEdge != lastEdge) { - extend( - stateList.last(), event.pid, lastEdge.source, - explState.innerState - )?.let { (midActions, midStates) -> + extend(stateList.last(), event.pid, lastEdge.source, + explState.innerState)?.let { (midActions, midStates) -> actionList.addAll(midActions) stateList.addAll(midStates) } @@ -88,9 +86,9 @@ internal class XcfaOcTraceExtractor( stateList.add(state.copy(processes = state.processes.toMutableMap().apply { put( event.pid, XcfaProcessState( - locs = LinkedList(listOf(lastEdge.target)), - varLookup = LinkedList(emptyList()) - ) + locs = LinkedList(listOf(lastEdge.target)), + varLookup = LinkedList(emptyList()) + ) ) }, sGlobal = explState, mutexes = state.mutexes.update(lastEdge, event.pid))) lastEdge = nextEdge ?: break @@ -98,10 +96,8 @@ internal class XcfaOcTraceExtractor( } if (!stateList.last().processes[violation.pid]!!.locs.peek().error) { - extend( - stateList.last(), violation.pid, violation.errorLoc, - explState.innerState - )?.let { (midActions, midStates) -> + extend(stateList.last(), violation.pid, violation.errorLoc, + explState.innerState)?.let { (midActions, midStates) -> actionList.addAll(midActions) stateList.addAll(midStates) } @@ -167,9 +163,9 @@ internal class XcfaOcTraceExtractor( currentState = currentState.copy(processes = currentState.processes.toMutableMap().apply { put( stepPid, XcfaProcessState( - locs = LinkedList(listOf(edge.target)), - varLookup = LinkedList(emptyList()) - ) + locs = LinkedList(listOf(edge.target)), + varLookup = LinkedList(emptyList()) + ) ) }, sGlobal = PtrState(explState), mutexes = currentState.mutexes.update(edge, stepPid)) states.add(currentState) diff --git a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt index f454fd25e9..d036c61ecd 100644 --- a/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt +++ b/subprojects/xcfa/xcfa-analysis/src/main/java/hu/bme/mit/theta/xcfa/analysis/por/XcfaDporLts.kt @@ -200,8 +200,7 @@ open class XcfaDporLts(private val xcfa: XCFA) : LTS { val lastButOne = stack[stack.size - 2] val mutexNeverReleased = last.mutexLocks.containsKey( - "" - ) && (last.state.mutexes.keys subtract lastButOne.state.mutexes.keys).contains( + "") && (last.state.mutexes.keys subtract lastButOne.state.mutexes.keys).contains( "" ) if (last.node.explored.isEmpty() || mutexNeverReleased) { @@ -261,9 +260,7 @@ open class XcfaDporLts(private val xcfa: XCFA) : LTS { val action = node.inEdge.get().action if (relevantProcesses.contains(action.pid)) { if (newLastDependents.containsKey(action.pid) && index <= checkNotNull( - newLastDependents[action.pid] - ) - ) { + newLastDependents[action.pid])) { // there is an action a' such that action -> a' -> newaction (->: happens-before) relevantProcesses.remove(action.pid) } else if (dependent(newaction, action)) { diff --git a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaExplAnalysisTest.kt b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaExplAnalysisTest.kt index 8e01612ffa..b4aa758303 100644 --- a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaExplAnalysisTest.kt +++ b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaExplAnalysisTest.kt @@ -82,30 +82,23 @@ class XcfaExplAnalysisTest { val lts = getXcfaLts() - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, ExplPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToExplPrec()) - ) + ItpRefToPtrPrec(ItpRefToExplPrec())) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -134,30 +127,23 @@ class XcfaExplAnalysisTest { val lts = XcfaSporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, ExplPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToExplPrec()) - ) + ItpRefToPtrPrec(ItpRefToExplPrec())) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -187,30 +173,23 @@ class XcfaExplAnalysisTest { val lts = XcfaDporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, lts.waitlist, StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, ExplPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToExplPrec()) - ) + ItpRefToPtrPrec(ItpRefToExplPrec())) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, ConsoleLogger( - Logger.Level.DETAIL - ) - ) as Refiner>, XcfaAction, XcfaPrec>> + Logger.Level.DETAIL)) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -239,31 +218,24 @@ class XcfaExplAnalysisTest { val lts = XcfaAasporLts(xcfa, mutableMapOf()) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner, ExplPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToExplPrec()) - ) + ItpRefToPtrPrec(ItpRefToExplPrec())) val atomicNodePruner = AtomicNodePruner>, XcfaAction>() val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, NullLogger.getInstance(), - atomicNodePruner - ) as Refiner>, XcfaAction, XcfaPrec>> + atomicNodePruner) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, AasporRefiner.create(refiner, PruneStrategy.FULL, mutableMapOf())) @@ -293,26 +265,21 @@ class XcfaExplAnalysisTest { val lts = XcfaAadporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, lts.waitlist, StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner(ItpRefToPtrPrec(ItpRefToExplPrec())) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) diff --git a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaPredAnalysisTest.kt b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaPredAnalysisTest.kt index 88d068adf7..e398b5ed07 100644 --- a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaPredAnalysisTest.kt +++ b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaPredAnalysisTest.kt @@ -84,30 +84,23 @@ class XcfaPredAnalysisTest { val lts = getXcfaLts() - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, PredPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole())) - ) + ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole()))) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -137,30 +130,23 @@ class XcfaPredAnalysisTest { val lts = XcfaSporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, PredPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole())) - ) + ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole()))) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -191,30 +177,23 @@ class XcfaPredAnalysisTest { val lts = XcfaDporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, lts.waitlist, StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner>, PredPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole())) - ) + ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole()))) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, ConsoleLogger( - Logger.Level.DETAIL - ) - ) as Refiner>, XcfaAction, XcfaPrec>> + Logger.Level.DETAIL)) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) @@ -244,31 +223,24 @@ class XcfaPredAnalysisTest { val lts = XcfaAasporLts(xcfa, mutableMapOf()) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, PriorityWaitlist.create( - ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs()) - ), + ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), ArgNodeComparators.bfs())), StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner, PredPrec, ItpRefutation>( - ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole())) - ) + ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole()))) val atomicNodePruner = AtomicNodePruner>, XcfaAction>() val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, NullLogger.getInstance(), - atomicNodePruner - ) as Refiner>, XcfaAction, XcfaPrec>> + atomicNodePruner) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, AasporRefiner.create(refiner, PruneStrategy.FULL, mutableMapOf())) @@ -299,28 +271,22 @@ class XcfaPredAnalysisTest { val lts = XcfaAadporLts(xcfa) - val abstractor = getXcfaAbstractor( - analysis, + val abstractor = getXcfaAbstractor(analysis, lts.waitlist, StopCriterions.firstCex>, XcfaAction>(), ConsoleLogger(Logger.Level.DETAIL), lts, - ErrorDetection.ERROR_LOCATION - ) as Abstractor>, XcfaAction, XcfaPrec>> + ErrorDetection.ERROR_LOCATION) as Abstractor>, XcfaAction, XcfaPrec>> val precRefiner = XcfaPrecRefiner( - ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole())) - ) + ItpRefToPtrPrec(ItpRefToPredPrec(ExprSplitters.whole()))) val refiner = XcfaSingleExprTraceRefiner.create( - ExprTraceBwBinItpChecker.create( - BoolExprs.True(), BoolExprs.True(), - Z3LegacySolverFactory.getInstance().createItpSolver() - ), + ExprTraceBwBinItpChecker.create(BoolExprs.True(), BoolExprs.True(), + Z3LegacySolverFactory.getInstance().createItpSolver()), precRefiner, PruneStrategy.FULL, - NullLogger.getInstance() - ) as Refiner>, XcfaAction, XcfaPrec>> + NullLogger.getInstance()) as Refiner>, XcfaAction, XcfaPrec>> val cegarChecker = CegarChecker.create(abstractor, refiner) diff --git a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateLtsTest.kt b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateLtsTest.kt index d02b0687d3..b1a815104b 100644 --- a/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateLtsTest.kt +++ b/subprojects/xcfa/xcfa-analysis/src/test/java/hu/bme/mit/theta/xcfa/analysis/XcfaStateLtsTest.kt @@ -67,8 +67,7 @@ class XcfaStateLtsTest { initState = XcfaState( xcfa, mapOf( - Pair( - 0, + Pair(0, XcfaProcessState( locs = LinkedList(listOf(edges[1].source)), varLookup = LinkedList(listOf(createLookup(xcfa.initProcedures[0].first, "T0", "P0"))) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/ExecuteConfig.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/ExecuteConfig.kt index e835aaf239..9469c2eca3 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/ExecuteConfig.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/ExecuteConfig.kt @@ -176,15 +176,13 @@ fun frontend(config: XcfaConfig<*, *>, logger: Logger, uniqueLogger: Logger): Tr logger.write( Logger.Level.INFO, "Frontend finished: ${xcfa.name} (in ${ - stopwatch.elapsed(TimeUnit.MILLISECONDS) - } ms)\n" + stopwatch.elapsed(TimeUnit.MILLISECONDS) + } ms)\n" ) logger.write(RESULT, "ParsingResult Success\n") - logger.write( - RESULT, - "Alias graph size: ${xcfa.pointsToGraph.size} -> ${xcfa.pointsToGraph.values.map { it.size }.toList()}\n" - ) + logger.write(RESULT, + "Alias graph size: ${xcfa.pointsToGraph.size} -> ${xcfa.pointsToGraph.values.map { it.size }.toList()}\n") return Triple(xcfa, mcm, parseContext) } @@ -228,8 +226,8 @@ private fun backend( logger.write( Logger.Level.INFO, "Backend finished (in ${ - stopwatch.elapsed(TimeUnit.MILLISECONDS) - } ms)\n" + stopwatch.elapsed(TimeUnit.MILLISECONDS) + } ms)\n" ) logger.write(RESULT, result.toString() + "\n") @@ -333,10 +331,8 @@ private fun postVerificationLogging( traceFile.writeText(GraphvizWriter.getInstance().writeString(traceG)) val sequenceFile = File(resultFolder, "trace.plantuml") - writeSequenceTrace( - sequenceFile, - safetyResult.asUnsafe().cex as Trace, XcfaAction> - ) { (_, act) -> + writeSequenceTrace(sequenceFile, + safetyResult.asUnsafe().cex as Trace, XcfaAction>) { (_, act) -> act.label.getFlatLabels().map(XcfaLabel::toString) } @@ -367,10 +363,8 @@ private fun postVerificationLogging( } } -private fun writeSequenceTrace( - sequenceFile: File, trace: Trace, XcfaAction>, - printer: (Pair, XcfaAction>) -> List -) { +private fun writeSequenceTrace(sequenceFile: File, trace: Trace, XcfaAction>, + printer: (Pair, XcfaAction>) -> List) { sequenceFile.writeText("@startuml\n") var maxWidth = 0 trace.actions.forEachIndexed { i, it -> diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToBoundedChecker.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToBoundedChecker.kt index 7feaca22b7..18e0bd82ca 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToBoundedChecker.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToBoundedChecker.kt @@ -30,31 +30,23 @@ import hu.bme.mit.theta.xcfa.cli.params.XcfaConfig import hu.bme.mit.theta.xcfa.cli.utils.getSolver import hu.bme.mit.theta.xcfa.model.XCFA -fun getBoundedChecker( - xcfa: XCFA, mcm: MCM, +fun getBoundedChecker(xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, - logger: Logger -): SafetyChecker>, XcfaAction>, XcfaPrec<*>> { + logger: Logger): SafetyChecker>, XcfaAction>, XcfaPrec<*>> { val boundedConfig = config.backendConfig.specConfig as BoundedConfig return BoundedChecker( monolithicExpr = xcfa.toMonolithicExpr(), - bmcSolver = tryGetSolver( - boundedConfig.bmcConfig.bmcSolver, - boundedConfig.bmcConfig.validateBMCSolver - )?.createSolver(), + bmcSolver = tryGetSolver(boundedConfig.bmcConfig.bmcSolver, + boundedConfig.bmcConfig.validateBMCSolver)?.createSolver(), bmcEnabled = { !boundedConfig.bmcConfig.disable }, lfPathOnly = { !boundedConfig.bmcConfig.nonLfPath }, - itpSolver = tryGetSolver( - boundedConfig.itpConfig.itpSolver, - boundedConfig.itpConfig.validateItpSolver - )?.createItpSolver(), + itpSolver = tryGetSolver(boundedConfig.itpConfig.itpSolver, + boundedConfig.itpConfig.validateItpSolver)?.createItpSolver(), imcEnabled = { !boundedConfig.itpConfig.disable }, - indSolver = tryGetSolver( - boundedConfig.indConfig.indSolver, - boundedConfig.indConfig.validateIndSolver - )?.createSolver(), + indSolver = tryGetSolver(boundedConfig.indConfig.indSolver, + boundedConfig.indConfig.validateIndSolver)?.createSolver(), kindEnabled = { !boundedConfig.indConfig.disable }, valToState = { xcfa.valToState(it) }, biValToAction = { val1, val2 -> xcfa.valToAction(val1, val2) }, diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToCegarChecker.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToCegarChecker.kt index 6417f4e57c..8c39486021 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToCegarChecker.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToCegarChecker.kt @@ -43,20 +43,14 @@ import hu.bme.mit.theta.xcfa.cli.params.* import hu.bme.mit.theta.xcfa.cli.utils.getSolver import hu.bme.mit.theta.xcfa.model.XCFA -fun getCegarChecker( - xcfa: XCFA, mcm: MCM, +fun getCegarChecker(xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, - logger: Logger -): SafetyChecker, XcfaAction>, Trace>, XcfaAction>, XcfaPrec<*>> { + logger: Logger): SafetyChecker, XcfaAction>, Trace>, XcfaAction>, XcfaPrec<*>> { val cegarConfig = config.backendConfig.specConfig as CegarConfig - val abstractionSolverFactory: SolverFactory = getSolver( - cegarConfig.abstractorConfig.abstractionSolver, - cegarConfig.abstractorConfig.validateAbstractionSolver - ) - val refinementSolverFactory: SolverFactory = getSolver( - cegarConfig.refinerConfig.refinementSolver, - cegarConfig.refinerConfig.validateRefinementSolver - ) + val abstractionSolverFactory: SolverFactory = getSolver(cegarConfig.abstractorConfig.abstractionSolver, + cegarConfig.abstractorConfig.validateAbstractionSolver) + val refinementSolverFactory: SolverFactory = getSolver(cegarConfig.refinerConfig.refinementSolver, + cegarConfig.refinerConfig.validateRefinementSolver) val ignoredVarRegistry = mutableMapOf, MutableSet>() @@ -65,14 +59,12 @@ fun getCegarChecker( (cegarConfig.coi.porLts as XcfaDporLts).waitlist } else { PriorityWaitlist.create>, XcfaAction>>( - cegarConfig.abstractorConfig.search.getComp(xcfa) - ) + cegarConfig.abstractorConfig.search.getComp(xcfa)) } val abstractionSolverInstance = abstractionSolverFactory.createSolver() val globalStatePartialOrd: PartialOrd> = cegarConfig.abstractorConfig.domain.partialOrd( - abstractionSolverInstance - ) as PartialOrd> + abstractionSolverInstance) as PartialOrd> val corePartialOrd: PartialOrd>> = if (xcfa.isInlined) getPartialOrder(globalStatePartialOrd) else getStackPartialOrder(globalStatePartialOrd) @@ -99,23 +91,18 @@ fun getCegarChecker( val precRefiner: PrecRefiner = cegarConfig.abstractorConfig.domain.itpPrecRefiner(cegarConfig.refinerConfig.exprSplitter.exprSplitter) as PrecRefiner - val atomicNodePruner: NodePruner = - cegarConfig.abstractorConfig.domain.nodePruner as NodePruner + val atomicNodePruner: NodePruner = cegarConfig.abstractorConfig.domain.nodePruner as NodePruner val refiner: Refiner = if (cegarConfig.refinerConfig.refinement == Refinement.MULTI_SEQ) if (cegarConfig.porLevel == POR.AASPOR) - MultiExprTraceRefiner.create( - ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger, - atomicNodePruner - ) + MultiExprTraceRefiner.create(ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger, + atomicNodePruner) else MultiExprTraceRefiner.create(ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger) else if (cegarConfig.porLevel == POR.AASPOR) - XcfaSingleExprTraceRefiner.create( - ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger, - atomicNodePruner - ) + XcfaSingleExprTraceRefiner.create(ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger, + atomicNodePruner) else XcfaSingleExprTraceRefiner.create(ref, precRefiner, cegarConfig.refinerConfig.pruneStrategy, logger) @@ -138,11 +125,9 @@ fun getCegarChecker( return object : SafetyChecker, XcfaAction>, Trace>, XcfaAction>, XcfaPrec<*>> { override fun check( - prec: XcfaPrec<*>? - ): SafetyResult, XcfaAction>, Trace>, XcfaAction>> { + prec: XcfaPrec<*>?): SafetyResult, XcfaAction>, Trace>, XcfaAction>> { return cegarChecker.check( - prec - ) as SafetyResult, XcfaAction>, Trace>, XcfaAction>> + prec) as SafetyResult, XcfaAction>, Trace>, XcfaAction>> } override fun check(): SafetyResult, XcfaAction>, Trace>, XcfaAction>> { diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToChecker.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToChecker.kt index 2315b6405b..4bd2dce149 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToChecker.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToChecker.kt @@ -31,11 +31,9 @@ import hu.bme.mit.theta.xcfa.cli.params.Backend import hu.bme.mit.theta.xcfa.cli.params.XcfaConfig import hu.bme.mit.theta.xcfa.model.XCFA -fun getChecker( - xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, parseContext: ParseContext, +fun getChecker(xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, parseContext: ParseContext, logger: Logger, - uniqueLogger: Logger -): SafetyChecker<*, *, XcfaPrec<*>> = + uniqueLogger: Logger): SafetyChecker<*, *, XcfaPrec<*>> = if (config.backendConfig.inProcess) { InProcessChecker(xcfa, config, parseContext, logger) } else { diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToOcChecker.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToOcChecker.kt index 80cae60477..df14f6ee8f 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToOcChecker.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToOcChecker.kt @@ -31,18 +31,14 @@ import hu.bme.mit.theta.xcfa.cli.params.OcConfig import hu.bme.mit.theta.xcfa.cli.params.XcfaConfig import hu.bme.mit.theta.xcfa.model.XCFA -fun getOcChecker( - xcfa: XCFA, mcm: MCM, +fun getOcChecker(xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, - logger: Logger -): SafetyChecker>, XcfaAction>, XcfaPrec<*>> { + logger: Logger): SafetyChecker>, XcfaAction>, XcfaPrec<*>> { val ocChecker = XcfaOcChecker(xcfa, (config.backendConfig.specConfig as OcConfig).decisionProcedure, logger) return object : SafetyChecker>, XcfaAction>, XcfaPrec<*>> { override fun check( - prec: XcfaPrec<*>? - ): SafetyResult>, XcfaAction>> = check() + prec: XcfaPrec<*>?): SafetyResult>, XcfaAction>> = check() - override fun check(): SafetyResult>, XcfaAction>> = - ocChecker.check() + override fun check(): SafetyResult>, XcfaAction>> = ocChecker.check() } } \ No newline at end of file diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToPortfolio.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToPortfolio.kt index 0daeedf5e8..a105f36786 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToPortfolio.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/ConfigToPortfolio.kt @@ -40,52 +40,47 @@ import javax.script.ScriptEngine import javax.script.ScriptEngineManager import javax.script.SimpleBindings -fun getPortfolioChecker( - xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, +fun getPortfolioChecker(xcfa: XCFA, mcm: MCM, config: XcfaConfig<*, *>, parseContext: ParseContext, logger: Logger, - uniqueLogger: Logger -): SafetyChecker>, XcfaAction>, Trace>, XcfaAction>, XcfaPrec<*>> = - SafetyChecker { _ -> + uniqueLogger: Logger): SafetyChecker>, XcfaAction>, Trace>, XcfaAction>, XcfaPrec<*>> = SafetyChecker { _ -> - val sw = Stopwatch.createStarted() - val portfolioName = (config.backendConfig.specConfig as PortfolioConfig).portfolio + val sw = Stopwatch.createStarted() + val portfolioName = (config.backendConfig.specConfig as PortfolioConfig).portfolio - val portfolioStm = when (portfolioName) { - "STABLE", - "CEGAR", - "COMPLEX", - "COMPLEX24" -> complexPortfolio24(xcfa, mcm, parseContext, config, logger, uniqueLogger) + val portfolioStm = when (portfolioName) { + "STABLE", + "CEGAR", + "COMPLEX", + "COMPLEX24" -> complexPortfolio24(xcfa, mcm, parseContext, config, logger, uniqueLogger) - "COMPLEX23" -> complexPortfolio23(xcfa, mcm, parseContext, config, logger, uniqueLogger) + "COMPLEX23" -> complexPortfolio23(xcfa, mcm, parseContext, config, logger, uniqueLogger) - "EMERGENT", - "BOUNDED" -> boundedPortfolio(xcfa, mcm, parseContext, config, logger, uniqueLogger) + "EMERGENT", + "BOUNDED" -> boundedPortfolio(xcfa, mcm, parseContext, config, logger, uniqueLogger) - "TESTING", - "CHC", - "HORN" -> hornPortfolio(xcfa, mcm, parseContext, config, logger, uniqueLogger) + "TESTING", + "CHC", + "HORN" -> hornPortfolio(xcfa, mcm, parseContext, config, logger, uniqueLogger) - else -> { - if (File(portfolioName).exists()) { - val kotlinEngine: ScriptEngine = ScriptEngineManager().getEngineByExtension("kts") - val bindings: Bindings = SimpleBindings() - bindings["xcfa"] = xcfa - bindings["mcm"] = mcm - bindings["parseContext"] = parseContext - bindings["portfolioConfig"] = config - bindings["logger"] = logger - bindings["uniqueLogger"] = uniqueLogger - kotlinEngine.eval(FileReader(portfolioName), bindings) as STM - } else { - error("No such file or built-in config: $portfolioName") - } + else -> { + if (File(portfolioName).exists()) { + val kotlinEngine: ScriptEngine = ScriptEngineManager().getEngineByExtension("kts") + val bindings: Bindings = SimpleBindings() + bindings["xcfa"] = xcfa + bindings["mcm"] = mcm + bindings["parseContext"] = parseContext + bindings["portfolioConfig"] = config + bindings["logger"] = logger + bindings["uniqueLogger"] = uniqueLogger + kotlinEngine.eval(FileReader(portfolioName), bindings) as STM + } else { + error("No such file or built-in config: $portfolioName") } } + } - val result = portfolioStm.execute() as Pair, SafetyResult<*, *>> + val result = portfolioStm.execute() as Pair, SafetyResult<*, *>> - logger.write( - Logger.Level.RESULT, "Config ${result.first} succeeded in ${sw.elapsed(TimeUnit.MILLISECONDS)} ms\n" - ) - result.second as SafetyResult>, XcfaAction>, Trace>, XcfaAction>>? - } \ No newline at end of file + logger.write(Logger.Level.RESULT, "Config ${result.first} succeeded in ${sw.elapsed(TimeUnit.MILLISECONDS)} ms\n") + result.second as SafetyResult>, XcfaAction>, Trace>, XcfaAction>>? +} \ No newline at end of file diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/InProcessChecker.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/InProcessChecker.kt index 276f6455d8..a20d9a5aaf 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/InProcessChecker.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/checkers/InProcessChecker.kt @@ -47,8 +47,7 @@ class InProcessChecker( ) : SafetyChecker> { override fun check( - prec: XcfaPrec<*>? - ): SafetyResult { + prec: XcfaPrec<*>?): SafetyResult { return check() } @@ -81,18 +80,16 @@ class InProcessChecker( getGson(xcfa).toJson(processConfig) } - val pb = NuProcessBuilder( - listOf( - ProcessHandle.current().info().command().orElse("java"), - "-Xss120m", - "-Xmx14210m", - "-cp", - File(XcfaCli::class.java.protectionDomain.codeSource.location.toURI()).absolutePath, - XcfaCli::class.qualifiedName, - "-c", - configJson.absolutePath - ).filterNotNull() - ) + val pb = NuProcessBuilder(listOf( + ProcessHandle.current().info().command().orElse("java"), + "-Xss120m", + "-Xmx14210m", + "-cp", + File(XcfaCli::class.java.protectionDomain.codeSource.location.toURI()).absolutePath, + XcfaCli::class.qualifiedName, + "-c", + configJson.absolutePath + ).filterNotNull()) val processHandler = ProcessHandler() pb.setProcessListener(processHandler) val process: NuProcess = pb.start() @@ -105,10 +102,8 @@ class InProcessChecker( process.destroy(true) throw ErrorCodeException(ExitCodes.TIMEOUT.code) } else { - logger.write( - Logger.Level.RESULT, - "Config timed out but started writing result, trying to wait an additional 10%..." - ) + logger.write(Logger.Level.RESULT, + "Config timed out but started writing result, trying to wait an additional 10%...") val retCode = process.waitFor(config.backendConfig.timeoutMs / 10, TimeUnit.MILLISECONDS) if (retCode != 0) { throw ErrorCodeException(retCode) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ParamValues.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ParamValues.kt index 83dbae2747..ac5b3d3236 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ParamValues.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/ParamValues.kt @@ -116,10 +116,8 @@ enum class Domain( EXPL( abstractor = { a, b, c, d, e, f, g, h, i, j -> - getXcfaAbstractor( - ExplXcfaAnalysis(a, b, c, i as PartialOrd>>, j), d, - e, f, g, h - ) + getXcfaAbstractor(ExplXcfaAnalysis(a, b, c, i as PartialOrd>>, j), d, + e, f, g, h) }, itpPrecRefiner = { XcfaPrecRefiner, ExplPrec, ItpRefutation>(ItpRefToPtrPrec(ItpRefToExplPrec())) @@ -131,12 +129,8 @@ enum class Domain( ), PRED_BOOL( abstractor = { a, b, c, d, e, f, g, h, i, j -> - getXcfaAbstractor( - PredXcfaAnalysis( - a, b, PredAbstractors.booleanAbstractor(b), - i as PartialOrd>>, j - ), d, e, f, g, h - ) + getXcfaAbstractor(PredXcfaAnalysis(a, b, PredAbstractors.booleanAbstractor(b), + i as PartialOrd>>, j), d, e, f, g, h) }, itpPrecRefiner = { a -> XcfaPrecRefiner, PredPrec, ItpRefutation>(ItpRefToPtrPrec(ItpRefToPredPrec(a))) @@ -148,12 +142,8 @@ enum class Domain( ), PRED_CART( abstractor = { a, b, c, d, e, f, g, h, i, j -> - getXcfaAbstractor( - PredXcfaAnalysis( - a, b, PredAbstractors.cartesianAbstractor(b), - i as PartialOrd>>, j - ), d, e, f, g, h - ) + getXcfaAbstractor(PredXcfaAnalysis(a, b, PredAbstractors.cartesianAbstractor(b), + i as PartialOrd>>, j), d, e, f, g, h) }, itpPrecRefiner = { a -> XcfaPrecRefiner, PredPrec, ItpRefutation>(ItpRefToPtrPrec(ItpRefToPredPrec(a))) @@ -165,12 +155,8 @@ enum class Domain( ), PRED_SPLIT( abstractor = { a, b, c, d, e, f, g, h, i, j -> - getXcfaAbstractor( - PredXcfaAnalysis( - a, b, PredAbstractors.booleanSplitAbstractor(b), - i as PartialOrd>>, j - ), d, e, f, g, h - ) + getXcfaAbstractor(PredXcfaAnalysis(a, b, PredAbstractors.booleanSplitAbstractor(b), + i as PartialOrd>>, j), d, e, f, g, h) }, itpPrecRefiner = { a -> XcfaPrecRefiner, PredPrec, ItpRefutation>(ItpRefToPtrPrec(ItpRefToPredPrec(a))) @@ -294,19 +280,15 @@ enum class Search { BFS { override fun getComp(cfa: XCFA): ArgNodeComparator { - return ArgNodeComparators.combine( - ArgNodeComparators.targetFirst(), - ArgNodeComparators.bfs() - ) + return ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), + ArgNodeComparators.bfs()) } }, DFS { override fun getComp(cfa: XCFA): ArgNodeComparator { - return ArgNodeComparators.combine( - ArgNodeComparators.targetFirst(), - ArgNodeComparators.dfs() - ) + return ArgNodeComparators.combine(ArgNodeComparators.targetFirst(), + ArgNodeComparators.dfs()) } }, ERR { @@ -339,8 +321,7 @@ enum class InitPrec( ALLASSUMES( explPrec = { xcfa -> XcfaPrec( - PtrPrec(ExplPrec.of(xcfa.collectAssumes().flatMap(ExprUtils::getVars)), emptySet()) - ) + PtrPrec(ExplPrec.of(xcfa.collectAssumes().flatMap(ExprUtils::getVars)), emptySet())) }, predPrec = { xcfa -> XcfaPrec(PtrPrec(PredPrec.of(xcfa.collectAssumes()), emptySet())) }, ), diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/XcfaConfig.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/XcfaConfig.kt index 3a8e43940a..a52a05c957 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/XcfaConfig.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/params/XcfaConfig.kt @@ -70,22 +70,16 @@ data class InputConfig( @Parameter(names = ["--cat"], description = "Path of the cat model") var catFile: File? = null, - @Parameter( - names = ["--parse-ctx"], - description = "Path of the parse context JSON (may contain additional metadata)" - ) + @Parameter(names = ["--parse-ctx"], + description = "Path of the parse context JSON (may contain additional metadata)") var parseCtx: File? = null, - @Parameter( - names = ["--xcfa-w-ctx"], - description = "XCFA and ParseContext (will overwrite --input and --parse-ctx when given)" - ) + @Parameter(names = ["--xcfa-w-ctx"], + description = "XCFA and ParseContext (will overwrite --input and --parse-ctx when given)") var xcfaWCtx: Triple? = null, - @Parameter( - names = ["--property"], - description = "Path of the property file (will overwrite --property when given)" - ) + @Parameter(names = ["--property"], + description = "Path of the property file (will overwrite --property when given)") var propertyFile: File? = null, @Parameter(names = ["--property-value"], description = "Property") @@ -106,22 +100,16 @@ data class FrontendConfig( @Parameter(names = ["--static-coi"], description = "Enable static cone-of-influence") var staticCoi: Boolean = false, - @Parameter( - names = ["--unroll"], - description = "Max number of loop iterations to unroll (use -1 to unroll completely when possible)" - ) + @Parameter(names = ["--unroll"], + description = "Max number of loop iterations to unroll (use -1 to unroll completely when possible)") var loopUnroll: Int = 1000, - @Parameter( - names = ["--force-unroll"], - description = "Number of loop iteration to unroll even if the number of iterations is unknown; in case of such a bounded loop unrolling, the safety result cannot be safe (use -1 to disable)" - ) + @Parameter(names = ["--force-unroll"], + description = "Number of loop iteration to unroll even if the number of iterations is unknown; in case of such a bounded loop unrolling, the safety result cannot be safe (use -1 to disable)") var forceUnroll: Int = -1, - @Parameter( - names = ["--enable-few"], - description = "Enable the FetchExecuteWriteback pass, which introduces a local temp var for all memory accesses" - ) + @Parameter(names = ["--enable-few"], + description = "Enable the FetchExecuteWriteback pass, which introduces a local temp var for all memory accesses") var enableFew: Boolean = false, @Parameter(names = ["--input-type"], description = "Format of the input") @@ -218,28 +206,22 @@ data class CegarAbstractorConfig( @Parameter(names = ["--abstraction-solver"], description = "Abstraction solver name") var abstractionSolver: String = "Z3", - @Parameter( - names = ["--validate-abstraction-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-abstraction-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateAbstractionSolver: Boolean = false, @Parameter(names = ["--domain"], description = "Abstraction domain") var domain: Domain = Domain.EXPL, - @Parameter( - names = ["--maxenum"], - description = "How many successors to enumerate in a transition. Only relevant to the explicit domain. Use 0 for no limit." - ) + @Parameter(names = ["--maxenum"], + description = "How many successors to enumerate in a transition. Only relevant to the explicit domain. Use 0 for no limit.") var maxEnum: Int = 1, @Parameter(names = ["--search"], description = "Search strategy") var search: Search = Search.ERR, - @Parameter( - names = ["--havoc-memory"], - description = "HAVOC memory model (do not track pointers in transition function)" - ) + @Parameter(names = ["--havoc-memory"], + description = "HAVOC memory model (do not track pointers in transition function)") var havocMemory: Boolean = false ) : Config @@ -247,10 +229,8 @@ data class CegarRefinerConfig( @Parameter(names = ["--refinement-solver"], description = "Refinement solver name") var refinementSolver: String = "Z3", - @Parameter( - names = ["--validate-refinement-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-refinement-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateRefinementSolver: Boolean = false, @Parameter(names = ["--refinement"], description = "Refinement strategy") @@ -301,10 +281,8 @@ data class BMCConfig( @Parameter(names = ["--bmc-solver"], description = "BMC solver name") var bmcSolver: String = "Z3", - @Parameter( - names = ["--validate-bmc-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-bmc-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateBMCSolver: Boolean = false, ) : Config @@ -315,22 +293,16 @@ data class InductionConfig( @Parameter(names = ["--induction-solver", "--ind-solver"], description = "Induction solver name") var indSolver: String = "Z3", - @Parameter( - names = ["--validate-induction-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-induction-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateIndSolver: Boolean = false, - @Parameter( - names = ["--ind-min-bound"], - description = "Start induction after reaching this bound" - ) + @Parameter(names = ["--ind-min-bound"], + description = "Start induction after reaching this bound") var indMinBound: Int = 0, - @Parameter( - names = ["--ind-frequency"], - description = "Frequency of induction check" - ) + @Parameter(names = ["--ind-frequency"], + description = "Frequency of induction check") var indFreq: Int = 1, ) : Config @@ -341,10 +313,8 @@ data class InterpolationConfig( @Parameter(names = ["--interpolation-solver", "--itp-solver"], description = "Interpolation solver name") var itpSolver: String = "Z3", - @Parameter( - names = ["--validate-interpolation-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-interpolation-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateItpSolver: Boolean = false, ) : Config @@ -419,10 +389,8 @@ data class WitnessConfig( @Parameter(names = ["--cex-solver"], description = "Concretizer solver name") var concretizerSolver: String = "Z3", - @Parameter( - names = ["--validate-cex-solver"], - description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues." - ) + @Parameter(names = ["--validate-cex-solver"], + description = "Activates a wrapper, which validates the assertions in the solver in each (SAT) check. Filters some solver issues.") var validateConcretizerSolver: Boolean = false ) : Config @@ -441,15 +409,11 @@ data class DebugConfig( @Parameter(names = ["--loglevel"], description = "Detailedness of logging") var logLevel: Logger.Level = Logger.Level.MAINSTEP, - @Parameter( - names = ["--arg-debug"], - description = "ARG debug mode (use the web-based debugger for ARG visualization)" - ) + @Parameter(names = ["--arg-debug"], + description = "ARG debug mode (use the web-based debugger for ARG visualization)") var argdebug: Boolean = false, - @Parameter( - names = ["--arg-to-file"], - description = "Visualize the resulting file here: https://ftsrg-edu.github.io/student-sisak-argviz/" - ) + @Parameter(names = ["--arg-to-file"], + description = "Visualize the resulting file here: https://ftsrg-edu.github.io/student-sisak-argviz/") var argToFile: Boolean = false ) : Config \ No newline at end of file diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/bounded.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/bounded.kt index 2cb473abb9..787774d93f 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/bounded.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/bounded.kt @@ -38,8 +38,7 @@ fun boundedPortfolio( parseContext: ParseContext, portfolioConfig: XcfaConfig<*, *>, logger: Logger, - uniqueLogger: Logger -): STM { + uniqueLogger: Logger): STM { val checker = { config: XcfaConfig<*, *> -> runConfig(config, logger, uniqueLogger, true) } @@ -48,14 +47,12 @@ fun boundedPortfolio( input = null, xcfaWCtx = Triple(xcfa, mcm, parseContext), propertyFile = null, - property = portfolioConfig.inputConfig.property - ), + property = portfolioConfig.inputConfig.property), frontendConfig = FrontendConfig( lbeLevel = LbePass.level, loopUnroll = LoopUnrollPass.UNROLL_LIMIT, inputType = InputType.C, - specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient) - ), + specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient)), backendConfig = BackendConfig( backend = Backend.BOUNDED, solverHome = portfolioConfig.backendConfig.solverHome, @@ -65,8 +62,7 @@ fun boundedPortfolio( maxBound = 0, indConfig = InductionConfig(true), itpConfig = InterpolationConfig(true) - ) - ), + )), outputConfig = OutputConfig( versionInfo = false, resultFolder = Paths.get("./").toFile(), // cwd @@ -118,49 +114,40 @@ fun boundedPortfolio( timeoutMs: Long = 0, inProcess: Boolean = this.backendConfig.inProcess ): XcfaConfig<*, BoundedConfig> { - return copy( - backendConfig = backendConfig.copy( - timeoutMs = timeoutMs, - inProcess = inProcess, - specConfig = backendConfig.specConfig!!.copy( - bmcConfig = backendConfig.specConfig!!.bmcConfig.copy(disable = !bmcEnabled, bmcSolver = bmcSolver), - indConfig = backendConfig.specConfig!!.indConfig.copy(disable = !indEnabled, indSolver = indSolver), - itpConfig = backendConfig.specConfig!!.itpConfig.copy(disable = !itpEnabled, itpSolver = itpSolver), - ) + return copy(backendConfig = backendConfig.copy( + timeoutMs = timeoutMs, + inProcess = inProcess, + specConfig = backendConfig.specConfig!!.copy( + bmcConfig = backendConfig.specConfig!!.bmcConfig.copy(disable = !bmcEnabled, bmcSolver = bmcSolver), + indConfig = backendConfig.specConfig!!.indConfig.copy(disable = !indEnabled, indSolver = indSolver), + itpConfig = backendConfig.specConfig!!.itpConfig.copy(disable = !itpEnabled, itpSolver = itpSolver), ) - ) + )) } fun getStm(inProcess: Boolean): STM { val edges = LinkedHashSet() - val configBmcZ3 = ConfigNode( - "BmcZ3-$inProcess", + val configBmcZ3 = ConfigNode("BmcZ3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, bmcEnabled = true, timeoutMs = 30000 - ), checker - ) - val configBmcMathsat = ConfigNode( - "BmcMathsat-$inProcess", + ), checker) + val configBmcMathsat = ConfigNode("BmcMathsat-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, bmcSolver = "mathsat:5.6.10", bmcEnabled = true, timeoutMs = 30000 - ), checker - ) - val configIndZ3 = ConfigNode( - "IndZ3-$inProcess", + ), checker) + val configIndZ3 = ConfigNode("IndZ3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, bmcEnabled = true, indEnabled = true, timeoutMs = 300000 - ), checker - ) - val configIndMathsat = ConfigNode( - "IndMathsat-$inProcess", + ), checker) + val configIndMathsat = ConfigNode("IndMathsat-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, bmcSolver = "mathsat:5.6.10", @@ -168,54 +155,33 @@ fun boundedPortfolio( bmcEnabled = true, indEnabled = true, timeoutMs = 300000 - ), checker - ) - val configItpCvc5 = ConfigNode( - "ItpCvc5-$inProcess", + ), checker) + val configItpCvc5 = ConfigNode("ItpCvc5-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, itpEnabled = true, itpSolver = "cvc5:1.0.8", timeoutMs = 0 - ), checker - ) - val configItpMathsat = ConfigNode( - "ItpMathsat-$inProcess", + ), checker) + val configItpMathsat = ConfigNode("ItpMathsat-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, itpSolver = "mathsat:5.6.10", itpEnabled = true, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(configBmcZ3, configBmcMathsat, solverError)) - edges.add( - Edge( - configBmcZ3, configIndZ3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - configBmcMathsat, configIndMathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) + edges.add(Edge(configBmcZ3, configIndZ3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(configBmcMathsat, configIndMathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) edges.add(Edge(configIndZ3, configIndMathsat, solverError)) - edges.add( - Edge( - configIndZ3, configItpCvc5, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - configIndMathsat, configItpCvc5, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) + edges.add(Edge(configIndZ3, configItpCvc5, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(configIndMathsat, configItpCvc5, + if (inProcess) timeoutOrNotSolvableError else anyError)) edges.add(Edge(configItpCvc5, configItpMathsat, anyError)) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex23.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex23.kt index 9c62a7e047..c6901d3838 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex23.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex23.kt @@ -29,13 +29,11 @@ import hu.bme.mit.theta.xcfa.model.XCFA import hu.bme.mit.theta.xcfa.passes.LbePass import java.nio.file.Paths -fun complexPortfolio23( - xcfa: XCFA, mcm: MCM, +fun complexPortfolio23(xcfa: XCFA, mcm: MCM, parseContext: ParseContext, portfolioConfig: XcfaConfig<*, *>, logger: Logger, - uniqueLogger: Logger -): STM { + uniqueLogger: Logger): STM { val checker = { config: XcfaConfig<*, *> -> runConfig(config, logger, uniqueLogger, true) } @@ -44,14 +42,12 @@ fun complexPortfolio23( input = null, xcfaWCtx = Triple(xcfa, mcm, parseContext), propertyFile = null, - property = portfolioConfig.inputConfig.property - ), + property = portfolioConfig.inputConfig.property), frontendConfig = FrontendConfig( lbeLevel = LbePass.LbeLevel.LBE_SEQ, loopUnroll = 50, inputType = InputType.C, - specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient) - ), + specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient)), backendConfig = BackendConfig( backend = Backend.CEGAR, solverHome = portfolioConfig.backendConfig.solverHome, @@ -76,9 +72,7 @@ fun complexPortfolio23( refinement = Refinement.SEQ_ITP, exprSplitter = ExprSplitterOptions.WHOLE, pruneStrategy = PruneStrategy.FULL - ) - ) - ), + ))), outputConfig = OutputConfig( versionInfo = false, resultFolder = Paths.get("./").toFile(), // cwd @@ -98,8 +92,7 @@ fun complexPortfolio23( refinerConfig = baseCegarConfig.refinerConfig.copy(pruneStrategy = PruneStrategy.LAZY) ) baseConfig = baseConfig.copy( - backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig) - ) + backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig)) } val timeoutTrigger = ExceptionTrigger( @@ -130,25 +123,23 @@ fun complexPortfolio23( validateRefinementSolver: Boolean = this.backendConfig.specConfig!!.refinerConfig.validateRefinementSolver, inProcess: Boolean = this.backendConfig.inProcess ): XcfaConfig<*, CegarConfig> { - return copy( - backendConfig = backendConfig.copy( - timeoutMs = timeoutMs, - inProcess = inProcess, - specConfig = backendConfig.specConfig!!.copy( - initPrec = initPrec, - abstractorConfig = backendConfig.specConfig!!.abstractorConfig.copy( - abstractionSolver = abstractionSolver, - validateAbstractionSolver = validateAbstractionSolver, - domain = domain, - ), - refinerConfig = backendConfig.specConfig!!.refinerConfig.copy( - refinementSolver = refinementSolver, - validateRefinementSolver = validateRefinementSolver, - refinement = refinement, - ) + return copy(backendConfig = backendConfig.copy( + timeoutMs = timeoutMs, + inProcess = inProcess, + specConfig = backendConfig.specConfig!!.copy( + initPrec = initPrec, + abstractorConfig = backendConfig.specConfig!!.abstractorConfig.copy( + abstractionSolver = abstractionSolver, + validateAbstractionSolver = validateAbstractionSolver, + domain = domain, + ), + refinerConfig = backendConfig.specConfig!!.refinerConfig.copy( + refinementSolver = refinementSolver, + validateRefinementSolver = validateRefinementSolver, + refinement = refinement, ) ) - ) + )) } val quickExplConfig = baseConfig.adaptConfig(initPrec = InitPrec.ALLVARS, timeoutMs = 90_000) @@ -157,92 +148,50 @@ fun complexPortfolio23( fun integerStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_z3_4.10.1_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "z3:4.10.1", + val config_1_1 = ConfigNode("QuickFullExpl_z3_4.10.1_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_2_1 = ConfigNode( - "EmptyExpl_z3_4.10.1_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "z3:4.10.1", + refinement = Refinement.NWT_IT_WP), checker) + val config_2_1 = ConfigNode("EmptyExpl_z3_4.10.1_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "z3:4.10.1", refinementSolver = "z3:4.10.1", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_3_1 = ConfigNode( - "PredCart_z3_4.10.1_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "z3:4.10.1", - refinementSolver = "z3:4.10.1" - ), checker - ) - - val config_1_2 = ConfigNode( - "QuickFullExpl_Z3_$inProcess", - quickExplConfig.adaptConfig(inProcess = inProcess), checker - ) - val config_2_2 = ConfigNode( - "EmptyExpl_Z3_$inProcess", emptyExplConfig.adaptConfig(inProcess = inProcess), - checker - ) - val config_3_2 = ConfigNode( - "PredCart_Z3_$inProcess", predConfig.adaptConfig(inProcess = inProcess), - checker - ) - - val config_1_3 = ConfigNode( - "QuickFullExpl_princess_2022_07_01_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "princess:2022-07-01", - refinementSolver = "princess:2022-07-01" - ), - checker - ) - val config_2_3 = ConfigNode( - "EmptyExpl_princess_2022_07_01_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "princess:2022-07-01", - refinementSolver = "princess:2022-07-01" - ), - checker - ) - val config_3_3 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", - refinementSolver = "mathsat:5.6.8" - ), - checker - ) - - val config_1_4 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", - refinementSolver = "mathsat:5.6.8" - ), - checker - ) - val config_2_4 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", - refinementSolver = "mathsat:5.6.8" - ), - checker - ) - val config_3_4 = ConfigNode( - "PredCart_princess_2022_07_01_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "princess:2022-07-01", - refinementSolver = "princess:2022-07-01" - ), - checker - ) + refinement = Refinement.NWT_IT_WP), checker) + val config_3_1 = ConfigNode("PredCart_z3_4.10.1_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "z3:4.10.1", + refinementSolver = "z3:4.10.1"), checker) + + val config_1_2 = ConfigNode("QuickFullExpl_Z3_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess), checker) + val config_2_2 = ConfigNode("EmptyExpl_Z3_$inProcess", emptyExplConfig.adaptConfig(inProcess = inProcess), + checker) + val config_3_2 = ConfigNode("PredCart_Z3_$inProcess", predConfig.adaptConfig(inProcess = inProcess), + checker) + + val config_1_3 = ConfigNode("QuickFullExpl_princess_2022_07_01_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "princess:2022-07-01", + refinementSolver = "princess:2022-07-01"), + checker) + val config_2_3 = ConfigNode("EmptyExpl_princess_2022_07_01_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "princess:2022-07-01", + refinementSolver = "princess:2022-07-01"), + checker) + val config_3_3 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinementSolver = "mathsat:5.6.8"), + checker) + + val config_1_4 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinementSolver = "mathsat:5.6.8"), + checker) + val config_2_4 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinementSolver = "mathsat:5.6.8"), + checker) + val config_3_4 = ConfigNode("PredCart_princess_2022_07_01_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "princess:2022-07-01", + refinementSolver = "princess:2022-07-01"), + checker) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -254,23 +203,15 @@ fun complexPortfolio23( Edge(config_1_3, config_2_3, timeoutTrigger), Edge(config_2_3, config_3_1, timeoutTrigger), - Edge( - config_1_4, config_2_4, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), - Edge( - config_2_4, config_3_1, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), + Edge(config_1_4, config_2_4, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), + Edge(config_2_4, config_3_1, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), @@ -288,10 +229,8 @@ fun complexPortfolio23( return STM(config_1_1, timeouts union solverExceptions) } - val inProcess = HierarchicalNode( - "InProcess", - getStm(!portfolioConfig.debugConfig.debug) - ) // if not debug, then in process, else not in process + val inProcess = HierarchicalNode("InProcess", + getStm(!portfolioConfig.debugConfig.debug)) // if not debug, then in process, else not in process val notInProcess = HierarchicalNode("NotInprocess", getStm(false)) val fallbackEdge = Edge(inProcess, notInProcess, ExceptionTrigger(label = "Anything")) @@ -301,72 +240,40 @@ fun complexPortfolio23( fun bitwiseStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_Z3_$inProcess", - quickExplConfig.adaptConfig(inProcess = inProcess, refinement = Refinement.NWT_IT_WP), checker - ) - val config_2_1 = ConfigNode( - "EmptyExpl_Z3_$inProcess", + val config_1_1 = ConfigNode("QuickFullExpl_Z3_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, refinement = Refinement.NWT_IT_WP), checker) + val config_2_1 = ConfigNode("EmptyExpl_Z3_$inProcess", emptyExplConfig.adaptConfig(inProcess = inProcess, refinement = Refinement.NWT_IT_WP), - checker - ) - val config_3_1 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", - refinementSolver = "mathsat:5.6.8" - ), - checker - ) - - val config_1_2 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + checker) + val config_3_1 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinementSolver = "mathsat:5.6.8"), + checker) + + val config_1_2 = ConfigNode("QuickFullExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_2_2 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker) + val config_2_2 = ConfigNode("EmptyExpl_cvc5_1.0.2_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_3_2 = ConfigNode( - "PredCart_z3_4.10.1_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "z3:4.10.1", - refinementSolver = "z3:4.10.1" - ), checker - ) + refinement = Refinement.NWT_IT_WP), checker) + val config_3_2 = ConfigNode("PredCart_z3_4.10.1_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "z3:4.10.1", + refinementSolver = "z3:4.10.1"), checker) - val config_1_3 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + val config_1_3 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_2_3 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinement = Refinement.NWT_IT_WP), checker) + val config_2_3 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", - refinement = Refinement.SEQ_ITP - ), checker - ) - val config_3_3 = ConfigNode( - "PredCart_cvc5_1.0.2_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.SEQ_ITP), checker) + val config_3_3 = ConfigNode("PredCart_cvc5_1.0.2_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) + refinement = Refinement.NWT_IT_WP), checker) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -375,23 +282,15 @@ fun complexPortfolio23( Edge(config_1_2, config_2_2, timeoutTrigger), Edge(config_2_2, config_3_1, timeoutTrigger), - Edge( - config_1_3, config_2_3, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), - Edge( - config_2_3, config_3_1, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), + Edge(config_1_3, config_2_3, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), + Edge(config_2_3, config_3_1, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), @@ -406,10 +305,8 @@ fun complexPortfolio23( return STM(config_1_1, timeouts union solverExceptions) } - val inProcess = HierarchicalNode( - "InProcess", - getStm(!portfolioConfig.debugConfig.debug) - ) // if not debug, then in process, else not in process + val inProcess = HierarchicalNode("InProcess", + getStm(!portfolioConfig.debugConfig.debug)) // if not debug, then in process, else not in process val notInProcess = HierarchicalNode("NotInprocess", getStm(false)) val fallbackEdge = Edge(inProcess, notInProcess, ExceptionTrigger(label = "Anything")) @@ -419,134 +316,74 @@ fun complexPortfolio23( fun floatsStm(): STM { fun getStm(inProcess: Boolean): STM { - val config_1_1 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + val config_1_1 = ConfigNode("QuickFullExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_2_1 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker) + val config_2_1 = ConfigNode("EmptyExpl_cvc5_1.0.2_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_3_1 = ConfigNode( - "PredCart_mathsat_5.6.8_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", - refinementSolver = "mathsat:5.6.8" - ), - checker - ) - - val config_1_2 = ConfigNode( - "QuickFullExpl_cvc5_1.0.2_seq_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), checker) + val config_3_1 = ConfigNode("PredCart_mathsat_5.6.8_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinementSolver = "mathsat:5.6.8"), + checker) + + val config_1_2 = ConfigNode("QuickFullExpl_cvc5_1.0.2_seq_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.SEQ_ITP - ), checker - ) - val config_2_2 = ConfigNode( - "EmptyExpl_cvc5_1.0.2_seq_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.SEQ_ITP), checker) + val config_2_2 = ConfigNode("EmptyExpl_cvc5_1.0.2_seq_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.SEQ_ITP - ), checker - ) - val config_3_2 = ConfigNode( - "PredCart_bitwuzla_latest_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "bitwuzla:latest", + refinement = Refinement.SEQ_ITP), checker) + val config_3_2 = ConfigNode("PredCart_bitwuzla_latest_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "bitwuzla:latest", refinementSolver = "bitwuzla:latest", - refinement = Refinement.NWT_IT_WP - ), checker - ) + refinement = Refinement.NWT_IT_WP), checker) - val config_1_3 = ConfigNode( - "QuickFullExpl_mathsat_5.6.8_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + val config_1_3 = ConfigNode("QuickFullExpl_mathsat_5.6.8_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", validateAbstractionSolver = true, validateRefinementSolver = true, - refinement = Refinement.NWT_IT_WP - ), - checker - ) - val config_2_3 = ConfigNode( - "EmptyExpl_mathsat_5.6.8_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", + refinement = Refinement.NWT_IT_WP), + checker) + val config_2_3 = ConfigNode("EmptyExpl_mathsat_5.6.8_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:5.6.8", refinementSolver = "mathsat:5.6.8", validateAbstractionSolver = true, validateRefinementSolver = true, - refinement = Refinement.NWT_IT_WP - ), - checker - ) - val config_3_3 = ConfigNode( - "PredCart_cvc5_1.0.2_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", + refinement = Refinement.NWT_IT_WP), + checker) + val config_3_3 = ConfigNode("PredCart_cvc5_1.0.2_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "cvc5:1.0.2", refinementSolver = "cvc5:1.0.2", - refinement = Refinement.NWT_IT_WP - ), checker - ) + refinement = Refinement.NWT_IT_WP), checker) - val config_1_4 = ConfigNode( - "QuickFullExpl_mathsat_fp_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:fp", + val config_1_4 = ConfigNode("QuickFullExpl_mathsat_fp_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker - ) - val config_2_4 = ConfigNode( - "EmptyExpl_mathsat_fp_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:fp", + validateAbstractionSolver = true, validateRefinementSolver = true), checker) + val config_2_4 = ConfigNode("EmptyExpl_mathsat_fp_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker - ) - val config_3_4 = ConfigNode( - "PredCart_mathsat_fp_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "mathsat:fp", + validateAbstractionSolver = true, validateRefinementSolver = true), checker) + val config_3_4 = ConfigNode("PredCart_mathsat_fp_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "mathsat:fp", refinementSolver = "mathsat:fp", - validateAbstractionSolver = true, validateRefinementSolver = true - ), checker - ) + validateAbstractionSolver = true, validateRefinementSolver = true), checker) - val config_1_5 = ConfigNode( - "QuickFullExpl_Z3_$inProcess", - quickExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", + val config_1_5 = ConfigNode("QuickFullExpl_Z3_$inProcess", + quickExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, - validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_2_5 = ConfigNode( - "EmptyExpl_Z3_$inProcess", - emptyExplConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", + validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), checker) + val config_2_5 = ConfigNode("EmptyExpl_Z3_$inProcess", + emptyExplConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", validateAbstractionSolver = true, - validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP - ), checker - ) - val config_3_5 = ConfigNode( - "PredCart_Z3_$inProcess", - predConfig.adaptConfig( - inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", - refinement = Refinement.NWT_IT_WP - ), - checker - ) + validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP), checker) + val config_3_5 = ConfigNode("PredCart_Z3_$inProcess", + predConfig.adaptConfig(inProcess = inProcess, abstractionSolver = "Z3", refinementSolver = "Z3", + refinement = Refinement.NWT_IT_WP), + checker) val timeouts = setOf( Edge(config_1_1, config_2_1, timeoutTrigger), @@ -561,23 +398,15 @@ fun complexPortfolio23( Edge(config_1_4, config_2_4, timeoutTrigger), Edge(config_2_4, config_3_1, timeoutTrigger), - Edge( - config_1_5, config_2_5, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), - Edge( - config_2_5, config_3_1, - if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything") - ), + Edge(config_1_5, config_2_5, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), + Edge(config_2_5, config_3_1, + if (inProcess) timeoutOrSolverError else ExceptionTrigger(label = "Anything")), ) - val notTimeout = if (inProcess) ExceptionTrigger( - ErrorCodeException(ExitCodes.SOLVER_ERROR.code), - label = "SolverError" - ) else ExceptionTrigger( - fallthroughExceptions = timeoutTrigger.exceptions, - label = "AnythingButTimeout" - ) + val notTimeout = if (inProcess) ExceptionTrigger(ErrorCodeException(ExitCodes.SOLVER_ERROR.code), + label = "SolverError") else ExceptionTrigger(fallthroughExceptions = timeoutTrigger.exceptions, + label = "AnythingButTimeout") val solverExceptions = setOf( Edge(config_1_1, config_1_2, notTimeout), @@ -598,10 +427,8 @@ fun complexPortfolio23( return STM(config_1_1, timeouts union solverExceptions) } - val inProcess = HierarchicalNode( - "InProcess", - getStm(!portfolioConfig.debugConfig.debug) - ) // if not debug, then in process, else not in process + val inProcess = HierarchicalNode("InProcess", + getStm(!portfolioConfig.debugConfig.debug)) // if not debug, then in process, else not in process val notInProcess = HierarchicalNode("NotInprocess", getStm(false)) val fallbackEdge = Edge(inProcess, notInProcess, ExceptionTrigger(label = "Anything")) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex24.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex24.kt index 8a5c005c3e..ca6f147553 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex24.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/complex24.kt @@ -37,8 +37,7 @@ fun complexPortfolio24( parseContext: ParseContext, portfolioConfig: XcfaConfig<*, *>, logger: Logger, - uniqueLogger: Logger -): STM { + uniqueLogger: Logger): STM { val checker = { config: XcfaConfig<*, *> -> runConfig(config, logger, uniqueLogger, true) } @@ -47,14 +46,12 @@ fun complexPortfolio24( input = null, xcfaWCtx = Triple(xcfa, mcm, parseContext), propertyFile = null, - property = portfolioConfig.inputConfig.property - ), + property = portfolioConfig.inputConfig.property), frontendConfig = FrontendConfig( lbeLevel = LbePass.level, loopUnroll = LoopUnrollPass.UNROLL_LIMIT, inputType = InputType.C, - specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient) - ), + specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient)), backendConfig = BackendConfig( backend = Backend.CEGAR, solverHome = portfolioConfig.backendConfig.solverHome, @@ -78,9 +75,7 @@ fun complexPortfolio24( refinement = Refinement.SEQ_ITP, exprSplitter = ExprSplitterOptions.WHOLE, pruneStrategy = PruneStrategy.FULL - ) - ) - ), + ))), outputConfig = OutputConfig( versionInfo = false, resultFolder = Paths.get("./").toFile(), // cwd @@ -100,8 +95,7 @@ fun complexPortfolio24( abstractorConfig = baseCegarConfig.abstractorConfig.copy(search = Search.DFS), ) baseConfig = baseConfig.copy( - backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig) - ) + backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig)) } if (!xcfa.isInlined) { @@ -146,31 +140,28 @@ fun complexPortfolio24( validateRefinementSolver: Boolean = this.backendConfig.specConfig!!.refinerConfig.validateRefinementSolver, inProcess: Boolean = this.backendConfig.inProcess ): XcfaConfig<*, CegarConfig> { - return copy( - backendConfig = backendConfig.copy( - timeoutMs = timeoutMs, - inProcess = inProcess, - specConfig = backendConfig.specConfig!!.copy( - initPrec = initPrec, - abstractorConfig = backendConfig.specConfig!!.abstractorConfig.copy( - abstractionSolver = abstractionSolver, - validateAbstractionSolver = validateAbstractionSolver, - domain = domain, - ), - refinerConfig = backendConfig.specConfig!!.refinerConfig.copy( - refinementSolver = refinementSolver, - validateRefinementSolver = validateRefinementSolver, - refinement = refinement, - ) + return copy(backendConfig = backendConfig.copy( + timeoutMs = timeoutMs, + inProcess = inProcess, + specConfig = backendConfig.specConfig!!.copy( + initPrec = initPrec, + abstractorConfig = backendConfig.specConfig!!.abstractorConfig.copy( + abstractionSolver = abstractionSolver, + validateAbstractionSolver = validateAbstractionSolver, + domain = domain, + ), + refinerConfig = backendConfig.specConfig!!.refinerConfig.copy( + refinementSolver = refinementSolver, + validateRefinementSolver = validateRefinementSolver, + refinement = refinement, ) ) - ) + )) } fun getStm(trait: ArithmeticTrait, inProcess: Boolean): STM { val edges = LinkedHashSet() - val config_BITWISE_EXPL_NWT_IT_WP_cvc5 = ConfigNode( - "BITWISE_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", + val config_BITWISE_EXPL_NWT_IT_WP_cvc5 = ConfigNode("BITWISE_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -178,10 +169,8 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) - val config_BITWISE_EXPL_NWT_IT_WP_Z3 = ConfigNode( - "BITWISE_EXPL_NWT_IT_WP_Z3-$inProcess", + ), checker) + val config_BITWISE_EXPL_NWT_IT_WP_Z3 = ConfigNode("BITWISE_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -189,11 +178,9 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) + ), checker) edges.add(Edge(config_BITWISE_EXPL_NWT_IT_WP_cvc5, config_BITWISE_EXPL_NWT_IT_WP_Z3, solverError)) - val config_BITWISE_EXPL_NWT_IT_WP_mathsat = ConfigNode( - "BITWISE_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", + val config_BITWISE_EXPL_NWT_IT_WP_mathsat = ConfigNode("BITWISE_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -201,11 +188,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) + ), checker) edges.add(Edge(config_BITWISE_EXPL_NWT_IT_WP_Z3, config_BITWISE_EXPL_NWT_IT_WP_mathsat, solverError)) - val config_BITWISE_PRED_CART_SEQ_ITP_mathsat = ConfigNode( - "BITWISE_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_BITWISE_PRED_CART_SEQ_ITP_mathsat = ConfigNode("BITWISE_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -213,28 +198,14 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_BITWISE_EXPL_NWT_IT_WP_cvc5, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_BITWISE_EXPL_NWT_IT_WP_Z3, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_BITWISE_EXPL_NWT_IT_WP_mathsat, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_BITWISE_PRED_CART_SEQ_ITP_cvc5 = ConfigNode( - "BITWISE_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_BITWISE_EXPL_NWT_IT_WP_cvc5, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_BITWISE_EXPL_NWT_IT_WP_Z3, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_BITWISE_EXPL_NWT_IT_WP_mathsat, config_BITWISE_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) + val config_BITWISE_PRED_CART_SEQ_ITP_cvc5 = ConfigNode("BITWISE_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -242,11 +213,9 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_BITWISE_PRED_CART_SEQ_ITP_mathsat, config_BITWISE_PRED_CART_SEQ_ITP_cvc5, solverError)) - val config_BITWISE_EXPL_SEQ_ITP_mathsat = ConfigNode( - "BITWISE_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_BITWISE_EXPL_SEQ_ITP_mathsat = ConfigNode("BITWISE_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -254,22 +223,12 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_BITWISE_PRED_CART_SEQ_ITP_mathsat, config_BITWISE_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_BITWISE_PRED_CART_SEQ_ITP_cvc5, config_BITWISE_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_BITWISE_EXPL_SEQ_ITP_cvc5 = ConfigNode( - "BITWISE_EXPL_SEQ_ITP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_BITWISE_PRED_CART_SEQ_ITP_mathsat, config_BITWISE_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_BITWISE_PRED_CART_SEQ_ITP_cvc5, config_BITWISE_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) + val config_BITWISE_EXPL_SEQ_ITP_cvc5 = ConfigNode("BITWISE_EXPL_SEQ_ITP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -277,11 +236,9 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_BITWISE_EXPL_SEQ_ITP_mathsat, config_BITWISE_EXPL_SEQ_ITP_cvc5, solverError)) - val config_FLOAT_EXPL_NWT_IT_WP_cvc5 = ConfigNode( - "FLOAT_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", + val config_FLOAT_EXPL_NWT_IT_WP_cvc5 = ConfigNode("FLOAT_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -289,21 +246,17 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.NWT_IT_WP, timeoutMs = 200000 - ), checker - ) - val config_FLOAT_EXPL_NWT_IT_WP_Z3 = ConfigNode( - "FLOAT_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.EXPL, - abstractionSolver = "Z3", - refinementSolver = "Z3", - refinement = Refinement.NWT_IT_WP, - timeoutMs = 200000 - ), checker - ) + ), checker) + val config_FLOAT_EXPL_NWT_IT_WP_Z3 = ConfigNode("FLOAT_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( + inProcess = inProcess, + domain = Domain.EXPL, + abstractionSolver = "Z3", + refinementSolver = "Z3", + refinement = Refinement.NWT_IT_WP, + timeoutMs = 200000 + ), checker) edges.add(Edge(config_FLOAT_EXPL_NWT_IT_WP_cvc5, config_FLOAT_EXPL_NWT_IT_WP_Z3, solverError)) - val config_FLOAT_EXPL_NWT_IT_WP_mathsat = ConfigNode( - "FLOAT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", + val config_FLOAT_EXPL_NWT_IT_WP_mathsat = ConfigNode("FLOAT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -311,11 +264,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", validateRefinementSolver = true, refinement = Refinement.NWT_IT_WP, timeoutMs = 200000 - ), checker - ) + ), checker) edges.add(Edge(config_FLOAT_EXPL_NWT_IT_WP_Z3, config_FLOAT_EXPL_NWT_IT_WP_mathsat, solverError)) - val config_FLOAT_PRED_CART_SEQ_ITP_mathsat = ConfigNode( - "FLOAT_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_FLOAT_PRED_CART_SEQ_ITP_mathsat = ConfigNode("FLOAT_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -323,28 +274,14 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", validateRefinementSolver = true, refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_FLOAT_EXPL_NWT_IT_WP_cvc5, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_FLOAT_EXPL_NWT_IT_WP_Z3, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_FLOAT_EXPL_NWT_IT_WP_mathsat, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_FLOAT_PRED_CART_SEQ_ITP_cvc5 = ConfigNode( - "FLOAT_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_FLOAT_EXPL_NWT_IT_WP_cvc5, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_FLOAT_EXPL_NWT_IT_WP_Z3, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_FLOAT_EXPL_NWT_IT_WP_mathsat, config_FLOAT_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) + val config_FLOAT_PRED_CART_SEQ_ITP_cvc5 = ConfigNode("FLOAT_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -352,11 +289,9 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_FLOAT_PRED_CART_SEQ_ITP_mathsat, config_FLOAT_PRED_CART_SEQ_ITP_cvc5, solverError)) - val config_FLOAT_EXPL_SEQ_ITP_mathsat = ConfigNode( - "FLOAT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_FLOAT_EXPL_SEQ_ITP_mathsat = ConfigNode("FLOAT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -364,22 +299,12 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", validateRefinementSolver = true, refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_FLOAT_PRED_CART_SEQ_ITP_mathsat, config_FLOAT_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_FLOAT_PRED_CART_SEQ_ITP_cvc5, config_FLOAT_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_FLOAT_EXPL_SEQ_ITP_cvc5 = ConfigNode( - "FLOAT_EXPL_SEQ_ITP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_FLOAT_PRED_CART_SEQ_ITP_mathsat, config_FLOAT_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_FLOAT_PRED_CART_SEQ_ITP_cvc5, config_FLOAT_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) + val config_FLOAT_EXPL_SEQ_ITP_cvc5 = ConfigNode("FLOAT_EXPL_SEQ_ITP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -387,11 +312,9 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_FLOAT_EXPL_SEQ_ITP_mathsat, config_FLOAT_EXPL_SEQ_ITP_cvc5, solverError)) - val config_LIN_INT_EXPL_NWT_IT_WP_mathsat = ConfigNode( - "LIN_INT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", + val config_LIN_INT_EXPL_NWT_IT_WP_mathsat = ConfigNode("LIN_INT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -399,10 +322,8 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) - val config_LIN_INT_EXPL_NWT_IT_WP_Z3 = ConfigNode( - "LIN_INT_EXPL_NWT_IT_WP_Z3-$inProcess", + ), checker) + val config_LIN_INT_EXPL_NWT_IT_WP_Z3 = ConfigNode("LIN_INT_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -410,33 +331,21 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) + ), checker) edges.add(Edge(config_LIN_INT_EXPL_NWT_IT_WP_mathsat, config_LIN_INT_EXPL_NWT_IT_WP_Z3, solverError)) - val config_LIN_INT_EXPL_SEQ_ITP_Z3 = ConfigNode( - "LIN_INT_EXPL_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.EXPL, - abstractionSolver = "Z3", - refinementSolver = "Z3", - refinement = Refinement.SEQ_ITP, - timeoutMs = 300000 - ), checker - ) - edges.add( - Edge( - config_LIN_INT_EXPL_NWT_IT_WP_mathsat, config_LIN_INT_EXPL_SEQ_ITP_Z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_LIN_INT_EXPL_NWT_IT_WP_Z3, config_LIN_INT_EXPL_SEQ_ITP_Z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_LIN_INT_EXPL_SEQ_ITP_mathsat = ConfigNode( - "LIN_INT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_LIN_INT_EXPL_SEQ_ITP_Z3 = ConfigNode("LIN_INT_EXPL_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( + inProcess = inProcess, + domain = Domain.EXPL, + abstractionSolver = "Z3", + refinementSolver = "Z3", + refinement = Refinement.SEQ_ITP, + timeoutMs = 300000 + ), checker) + edges.add(Edge(config_LIN_INT_EXPL_NWT_IT_WP_mathsat, config_LIN_INT_EXPL_SEQ_ITP_Z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_LIN_INT_EXPL_NWT_IT_WP_Z3, config_LIN_INT_EXPL_SEQ_ITP_Z3, + if (inProcess) timeoutOrSolverError else anyError)) + val config_LIN_INT_EXPL_SEQ_ITP_mathsat = ConfigNode("LIN_INT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -444,11 +353,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 300000 - ), checker - ) + ), checker) edges.add(Edge(config_LIN_INT_EXPL_SEQ_ITP_Z3, config_LIN_INT_EXPL_SEQ_ITP_mathsat, solverError)) - val config_LIN_INT_PRED_CART_SEQ_ITP_Z3 = ConfigNode( - "LIN_INT_PRED_CART_SEQ_ITP_Z3-$inProcess", + val config_LIN_INT_PRED_CART_SEQ_ITP_Z3 = ConfigNode("LIN_INT_PRED_CART_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -456,22 +363,12 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_LIN_INT_EXPL_SEQ_ITP_Z3, config_LIN_INT_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_LIN_INT_EXPL_SEQ_ITP_mathsat, config_LIN_INT_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_LIN_INT_PRED_CART_SEQ_ITP_mathsat = ConfigNode( - "LIN_INT_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", + ), checker) + edges.add(Edge(config_LIN_INT_EXPL_SEQ_ITP_Z3, config_LIN_INT_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_LIN_INT_EXPL_SEQ_ITP_mathsat, config_LIN_INT_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrSolverError else anyError)) + val config_LIN_INT_PRED_CART_SEQ_ITP_mathsat = ConfigNode("LIN_INT_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -479,11 +376,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_LIN_INT_PRED_CART_SEQ_ITP_Z3, config_LIN_INT_PRED_CART_SEQ_ITP_mathsat, solverError)) - val config_LIN_INT_PRED_CART_SEQ_ITP_z3 = ConfigNode( - "LIN_INT_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", + val config_LIN_INT_PRED_CART_SEQ_ITP_z3 = ConfigNode("LIN_INT_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -491,11 +386,9 @@ fun complexPortfolio24( refinementSolver = "z3:4.12.2", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add(Edge(config_LIN_INT_PRED_CART_SEQ_ITP_mathsat, config_LIN_INT_PRED_CART_SEQ_ITP_z3, solverError)) - val config_NONLIN_INT_EXPL_NWT_IT_WP_Z3 = ConfigNode( - "NONLIN_INT_EXPL_NWT_IT_WP_Z3-$inProcess", + val config_NONLIN_INT_EXPL_NWT_IT_WP_Z3 = ConfigNode("NONLIN_INT_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -503,10 +396,8 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) - val config_NONLIN_INT_EXPL_NWT_IT_WP_mathsat = ConfigNode( - "NONLIN_INT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", + ), checker) + val config_NONLIN_INT_EXPL_NWT_IT_WP_mathsat = ConfigNode("NONLIN_INT_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -514,11 +405,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) + ), checker) edges.add(Edge(config_NONLIN_INT_EXPL_NWT_IT_WP_Z3, config_NONLIN_INT_EXPL_NWT_IT_WP_mathsat, solverError)) - val config_NONLIN_INT_EXPL_SEQ_ITP_Z3 = ConfigNode( - "NONLIN_INT_EXPL_SEQ_ITP_Z3-$inProcess", + val config_NONLIN_INT_EXPL_SEQ_ITP_Z3 = ConfigNode("NONLIN_INT_EXPL_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -526,22 +415,12 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.SEQ_ITP, timeoutMs = 100000 - ), checker - ) - edges.add( - Edge( - config_NONLIN_INT_EXPL_NWT_IT_WP_Z3, config_NONLIN_INT_EXPL_SEQ_ITP_Z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_NONLIN_INT_EXPL_NWT_IT_WP_mathsat, config_NONLIN_INT_EXPL_SEQ_ITP_Z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_NONLIN_INT_EXPL_SEQ_ITP_z3 = ConfigNode( - "NONLIN_INT_EXPL_SEQ_ITP_z3:4.12.2-$inProcess", + ), checker) + edges.add(Edge(config_NONLIN_INT_EXPL_NWT_IT_WP_Z3, config_NONLIN_INT_EXPL_SEQ_ITP_Z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_NONLIN_INT_EXPL_NWT_IT_WP_mathsat, config_NONLIN_INT_EXPL_SEQ_ITP_Z3, + if (inProcess) timeoutOrSolverError else anyError)) + val config_NONLIN_INT_EXPL_SEQ_ITP_z3 = ConfigNode("NONLIN_INT_EXPL_SEQ_ITP_z3:4.12.2-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -549,11 +428,9 @@ fun complexPortfolio24( refinementSolver = "z3:4.12.2", refinement = Refinement.SEQ_ITP, timeoutMs = 100000 - ), checker - ) + ), checker) edges.add(Edge(config_NONLIN_INT_EXPL_SEQ_ITP_Z3, config_NONLIN_INT_EXPL_SEQ_ITP_z3, solverError)) - val config_NONLIN_INT_EXPL_SEQ_ITP_mathsat = ConfigNode( - "NONLIN_INT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", + val config_NONLIN_INT_EXPL_SEQ_ITP_mathsat = ConfigNode("NONLIN_INT_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -561,38 +438,23 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 200000 - ), checker - ) - edges.add( - Edge( - config_NONLIN_INT_EXPL_SEQ_ITP_Z3, config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_NONLIN_INT_EXPL_SEQ_ITP_z3, config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) + ), checker) + edges.add(Edge(config_NONLIN_INT_EXPL_SEQ_ITP_Z3, config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_NONLIN_INT_EXPL_SEQ_ITP_z3, config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) val config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat = ConfigNode( "NONLIN_INT_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.PRED_CART, - abstractionSolver = "mathsat:5.6.10", - refinementSolver = "mathsat:5.6.10", - refinement = Refinement.SEQ_ITP, - timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3 = ConfigNode( - "NONLIN_INT_PRED_CART_SEQ_ITP_Z3-$inProcess", + inProcess = inProcess, + domain = Domain.PRED_CART, + abstractionSolver = "mathsat:5.6.10", + refinementSolver = "mathsat:5.6.10", + refinement = Refinement.SEQ_ITP, + timeoutMs = 0 + ), checker) + edges.add(Edge(config_NONLIN_INT_EXPL_SEQ_ITP_mathsat, config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, + if (inProcess) timeoutOrSolverError else anyError)) + val config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3 = ConfigNode("NONLIN_INT_PRED_CART_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -600,13 +462,10 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add( - Edge(config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3, solverError) - ) - val config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5 = ConfigNode( - "NONLIN_INT_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", + Edge(config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3, solverError)) + val config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5 = ConfigNode("NONLIN_INT_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -614,22 +473,12 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.NWT_IT_WP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3, config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_ARR_EXPL_NWT_IT_WP_cvc5 = ConfigNode( - "ARR_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_NONLIN_INT_PRED_CART_SEQ_ITP_mathsat, config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_NONLIN_INT_PRED_CART_SEQ_ITP_Z3, config_NONLIN_INT_EXPL_NWT_IT_WP_cvc5, + if (inProcess) timeoutOrSolverError else anyError)) + val config_ARR_EXPL_NWT_IT_WP_cvc5 = ConfigNode("ARR_EXPL_NWT_IT_WP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -637,43 +486,29 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.NWT_IT_WP, timeoutMs = 100000 - ), checker - ) - val config_ARR_EXPL_NWT_IT_WP_Z3 = ConfigNode( - "ARR_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.EXPL, - abstractionSolver = "Z3", - refinementSolver = "Z3", - refinement = Refinement.NWT_IT_WP, - timeoutMs = 100000 - ), checker - ) + ), checker) + val config_ARR_EXPL_NWT_IT_WP_Z3 = ConfigNode("ARR_EXPL_NWT_IT_WP_Z3-$inProcess", baseConfig.adaptConfig( + inProcess = inProcess, + domain = Domain.EXPL, + abstractionSolver = "Z3", + refinementSolver = "Z3", + refinement = Refinement.NWT_IT_WP, + timeoutMs = 100000 + ), checker) edges.add(Edge(config_ARR_EXPL_NWT_IT_WP_cvc5, config_ARR_EXPL_NWT_IT_WP_Z3, solverError)) - val config_ARR_PRED_CART_SEQ_ITP_Z3 = ConfigNode( - "ARR_PRED_CART_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.PRED_CART, - abstractionSolver = "Z3", - refinementSolver = "Z3", - refinement = Refinement.SEQ_ITP, - timeoutMs = 300000 - ), checker - ) - edges.add( - Edge( - config_ARR_EXPL_NWT_IT_WP_cvc5, config_ARR_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_ARR_EXPL_NWT_IT_WP_Z3, config_ARR_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_ARR_PRED_CART_SEQ_ITP_z3 = ConfigNode( - "ARR_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", + val config_ARR_PRED_CART_SEQ_ITP_Z3 = ConfigNode("ARR_PRED_CART_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( + inProcess = inProcess, + domain = Domain.PRED_CART, + abstractionSolver = "Z3", + refinementSolver = "Z3", + refinement = Refinement.SEQ_ITP, + timeoutMs = 300000 + ), checker) + edges.add(Edge(config_ARR_EXPL_NWT_IT_WP_cvc5, config_ARR_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_ARR_EXPL_NWT_IT_WP_Z3, config_ARR_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrSolverError else anyError)) + val config_ARR_PRED_CART_SEQ_ITP_z3 = ConfigNode("ARR_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -681,11 +516,9 @@ fun complexPortfolio24( refinementSolver = "z3:4.12.2", refinement = Refinement.SEQ_ITP, timeoutMs = 300000 - ), checker - ) + ), checker) edges.add(Edge(config_ARR_PRED_CART_SEQ_ITP_Z3, config_ARR_PRED_CART_SEQ_ITP_z3, solverError)) - val config_ARR_PRED_CART_SEQ_ITP_princess = ConfigNode( - "ARR_PRED_CART_SEQ_ITP_princess:2023-06-19-$inProcess", + val config_ARR_PRED_CART_SEQ_ITP_princess = ConfigNode("ARR_PRED_CART_SEQ_ITP_princess:2023-06-19-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -693,22 +526,12 @@ fun complexPortfolio24( refinementSolver = "princess:2023-06-19", refinement = Refinement.SEQ_ITP, timeoutMs = 500000 - ), checker - ) - edges.add( - Edge( - config_ARR_PRED_CART_SEQ_ITP_Z3, config_ARR_PRED_CART_SEQ_ITP_princess, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_ARR_PRED_CART_SEQ_ITP_z3, config_ARR_PRED_CART_SEQ_ITP_princess, - if (inProcess) timeoutOrSolverError else anyError - ) - ) - val config_ARR_PRED_CART_SEQ_ITP_cvc5 = ConfigNode( - "ARR_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", + ), checker) + edges.add(Edge(config_ARR_PRED_CART_SEQ_ITP_Z3, config_ARR_PRED_CART_SEQ_ITP_princess, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_ARR_PRED_CART_SEQ_ITP_z3, config_ARR_PRED_CART_SEQ_ITP_princess, + if (inProcess) timeoutOrSolverError else anyError)) + val config_ARR_PRED_CART_SEQ_ITP_cvc5 = ConfigNode("ARR_PRED_CART_SEQ_ITP_cvc5:1.0.8-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -716,11 +539,9 @@ fun complexPortfolio24( refinementSolver = "cvc5:1.0.8", refinement = Refinement.SEQ_ITP, timeoutMs = 500000 - ), checker - ) + ), checker) edges.add(Edge(config_ARR_PRED_CART_SEQ_ITP_princess, config_ARR_PRED_CART_SEQ_ITP_cvc5, solverError)) - val config_MULTITHREAD_EXPL_SEQ_ITP_Z3 = ConfigNode( - "MULTITHREAD_EXPL_SEQ_ITP_Z3-$inProcess", + val config_MULTITHREAD_EXPL_SEQ_ITP_Z3 = ConfigNode("MULTITHREAD_EXPL_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -728,10 +549,8 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.SEQ_ITP, timeoutMs = 150000 - ), checker - ) - val config_MULTITHREAD_EXPL_SEQ_ITP_mathsat = ConfigNode( - "MULTITHREAD_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", + ), checker) + val config_MULTITHREAD_EXPL_SEQ_ITP_mathsat = ConfigNode("MULTITHREAD_EXPL_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -739,11 +558,9 @@ fun complexPortfolio24( refinementSolver = "mathsat:5.6.10", refinement = Refinement.SEQ_ITP, timeoutMs = 150000 - ), checker - ) + ), checker) edges.add(Edge(config_MULTITHREAD_EXPL_SEQ_ITP_Z3, config_MULTITHREAD_EXPL_SEQ_ITP_mathsat, solverError)) - val config_MULTITHREAD_EXPL_NWT_IT_WP_z3 = ConfigNode( - "MULTITHREAD_EXPL_NWT_IT_WP_z3:4.12.2-$inProcess", + val config_MULTITHREAD_EXPL_NWT_IT_WP_z3 = ConfigNode("MULTITHREAD_EXPL_NWT_IT_WP_z3:4.12.2-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.EXPL, @@ -751,33 +568,22 @@ fun complexPortfolio24( refinementSolver = "z3:4.12.2", refinement = Refinement.NWT_IT_WP, timeoutMs = 300000 - ), checker - ) - edges.add( - Edge( - config_MULTITHREAD_EXPL_SEQ_ITP_Z3, config_MULTITHREAD_EXPL_NWT_IT_WP_z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_MULTITHREAD_EXPL_SEQ_ITP_mathsat, config_MULTITHREAD_EXPL_NWT_IT_WP_z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) + ), checker) + edges.add(Edge(config_MULTITHREAD_EXPL_SEQ_ITP_Z3, config_MULTITHREAD_EXPL_NWT_IT_WP_z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_MULTITHREAD_EXPL_SEQ_ITP_mathsat, config_MULTITHREAD_EXPL_NWT_IT_WP_z3, + if (inProcess) timeoutOrSolverError else anyError)) val config_MULTITHREAD_EXPL_NWT_IT_WP_mathsat = ConfigNode( "MULTITHREAD_EXPL_NWT_IT_WP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.EXPL, - abstractionSolver = "mathsat:5.6.10", - refinementSolver = "mathsat:5.6.10", - refinement = Refinement.NWT_IT_WP, - timeoutMs = 300000 - ), checker - ) + inProcess = inProcess, + domain = Domain.EXPL, + abstractionSolver = "mathsat:5.6.10", + refinementSolver = "mathsat:5.6.10", + refinement = Refinement.NWT_IT_WP, + timeoutMs = 300000 + ), checker) edges.add(Edge(config_MULTITHREAD_EXPL_NWT_IT_WP_z3, config_MULTITHREAD_EXPL_NWT_IT_WP_mathsat, solverError)) - val config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3 = ConfigNode( - "MULTITHREAD_PRED_CART_SEQ_ITP_Z3-$inProcess", + val config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3 = ConfigNode("MULTITHREAD_PRED_CART_SEQ_ITP_Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -785,35 +591,23 @@ fun complexPortfolio24( refinementSolver = "Z3", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) - edges.add( - Edge( - config_MULTITHREAD_EXPL_NWT_IT_WP_z3, config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrNotSolvableError else anyError - ) - ) - edges.add( - Edge( - config_MULTITHREAD_EXPL_NWT_IT_WP_mathsat, config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, - if (inProcess) timeoutOrSolverError else anyError - ) - ) + ), checker) + edges.add(Edge(config_MULTITHREAD_EXPL_NWT_IT_WP_z3, config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrNotSolvableError else anyError)) + edges.add(Edge(config_MULTITHREAD_EXPL_NWT_IT_WP_mathsat, config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, + if (inProcess) timeoutOrSolverError else anyError)) val config_MULTITHREAD_PRED_CART_SEQ_ITP_mathsat = ConfigNode( "MULTITHREAD_PRED_CART_SEQ_ITP_mathsat:5.6.10-$inProcess", baseConfig.adaptConfig( - inProcess = inProcess, - domain = Domain.PRED_CART, - abstractionSolver = "mathsat:5.6.10", - refinementSolver = "mathsat:5.6.10", - refinement = Refinement.SEQ_ITP, - timeoutMs = 0 - ), checker - ) + inProcess = inProcess, + domain = Domain.PRED_CART, + abstractionSolver = "mathsat:5.6.10", + refinementSolver = "mathsat:5.6.10", + refinement = Refinement.SEQ_ITP, + timeoutMs = 0 + ), checker) edges.add( - Edge(config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, config_MULTITHREAD_PRED_CART_SEQ_ITP_mathsat, solverError) - ) - val config_MULTITHREAD_PRED_CART_SEQ_ITP_z3 = ConfigNode( - "MULTITHREAD_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", + Edge(config_MULTITHREAD_PRED_CART_SEQ_ITP_Z3, config_MULTITHREAD_PRED_CART_SEQ_ITP_mathsat, solverError)) + val config_MULTITHREAD_PRED_CART_SEQ_ITP_z3 = ConfigNode("MULTITHREAD_PRED_CART_SEQ_ITP_z3:4.12.2-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, domain = Domain.PRED_CART, @@ -821,11 +615,9 @@ fun complexPortfolio24( refinementSolver = "z3:4.12.2", refinement = Refinement.SEQ_ITP, timeoutMs = 0 - ), checker - ) + ), checker) edges.add( - Edge(config_MULTITHREAD_PRED_CART_SEQ_ITP_mathsat, config_MULTITHREAD_PRED_CART_SEQ_ITP_z3, solverError) - ) + Edge(config_MULTITHREAD_PRED_CART_SEQ_ITP_mathsat, config_MULTITHREAD_PRED_CART_SEQ_ITP_z3, solverError)) if (trait == ArithmeticTrait.BITWISE) { return STM(config_BITWISE_EXPL_NWT_IT_WP_cvc5, edges) } diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/horn.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/horn.kt index 1a56abd89c..5a3933b59c 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/horn.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/horn.kt @@ -34,8 +34,7 @@ fun hornPortfolio( parseContext: ParseContext, portfolioConfig: XcfaConfig<*, *>, logger: Logger, - uniqueLogger: Logger -): STM { + uniqueLogger: Logger): STM { val checker = { config: XcfaConfig<*, *> -> runConfig(config, logger, uniqueLogger, true) } @@ -44,14 +43,12 @@ fun hornPortfolio( input = null, xcfaWCtx = Triple(xcfa, mcm, parseContext), propertyFile = null, - property = portfolioConfig.inputConfig.property - ), + property = portfolioConfig.inputConfig.property), frontendConfig = FrontendConfig( lbeLevel = LbePass.level, loopUnroll = LoopUnrollPass.UNROLL_LIMIT, inputType = InputType.C, - specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient) - ), + specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient)), backendConfig = BackendConfig( backend = Backend.CHC, solverHome = portfolioConfig.backendConfig.solverHome, @@ -59,8 +56,7 @@ fun hornPortfolio( specConfig = HornConfig( solver = "z3:4.13.0", validateSolver = false - ) - ), + )), outputConfig = OutputConfig( versionInfo = false, resultFolder = Paths.get("./").toFile(), // cwd @@ -107,42 +103,34 @@ fun hornPortfolio( timeoutMs: Long = 0, inProcess: Boolean = this.backendConfig.inProcess ): XcfaConfig<*, HornConfig> { - return copy( - backendConfig = backendConfig.copy( - timeoutMs = timeoutMs, - inProcess = inProcess, - specConfig = backendConfig.specConfig!!.copy( - solver = solver, - ) + return copy(backendConfig = backendConfig.copy( + timeoutMs = timeoutMs, + inProcess = inProcess, + specConfig = backendConfig.specConfig!!.copy( + solver = solver, ) - ) + )) } fun getStm(inProcess: Boolean): STM { val edges = LinkedHashSet() - val configZ3 = ConfigNode( - "Z3-$inProcess", + val configZ3 = ConfigNode("Z3-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, timeoutMs = 100_000 - ), checker - ) - val configEldarica = ConfigNode( - "Eldarica-$inProcess", + ), checker) + val configEldarica = ConfigNode("Eldarica-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, solver = "eldarica:2.1", timeoutMs = 500_000 - ), checker - ) - val configGolem = ConfigNode( - "Golem-$inProcess", + ), checker) + val configGolem = ConfigNode("Golem-$inProcess", baseConfig.adaptConfig( inProcess = inProcess, solver = "golem:0.5.0", timeoutMs = 300_000 - ), checker - ) + ), checker) edges.add(Edge(configZ3, configEldarica, anyError)) edges.add(Edge(configEldarica, configGolem, anyError)) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/stm.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/stm.kt index 27d08a1c2b..d98b44e8f9 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/stm.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/portfolio/stm.kt @@ -36,10 +36,8 @@ ${innerSTM.visualize()} }""".trimIndent() } -class ConfigNode( - name: String, private val config: XcfaConfig<*, *>, - private val check: (config: XcfaConfig<*, *>) -> SafetyResult<*, *> -) : Node(name) { +class ConfigNode(name: String, private val config: XcfaConfig<*, *>, + private val check: (config: XcfaConfig<*, *>) -> SafetyResult<*, *>) : Node(name) { override fun execute(): Pair { println("Current configuration: $config") @@ -50,12 +48,10 @@ class ConfigNode( .map { "state ${name.replace(Regex("[:\\.-]+"), "_")}: $it" }.reduce { a, b -> "$a\n$b" } } -data class Edge( - val source: Node, +data class Edge(val source: Node, val target: Node, val trigger: (Throwable) -> Boolean, - val guard: (Node, Edge) -> Boolean = { _, _ -> true } -) { + val guard: (Node, Edge) -> Boolean = { _, _ -> true }) { init { source.outEdges.add(this) @@ -74,10 +70,8 @@ class ExceptionTrigger( val label: String? = null ) : (Throwable) -> Boolean { - constructor(vararg exceptions: Throwable, label: String? = null) : this( - exceptions.toSet(), - label = label - ) + constructor(vararg exceptions: Throwable, label: String? = null) : this(exceptions.toSet(), + label = label) override fun invoke(e: Throwable): Boolean = if (exceptions.isNotEmpty()) @@ -95,8 +89,7 @@ data class STM(val initNode: Node, val edges: Set) { val nodes = edges.map { listOf(it.source, it.target) }.flatten().toSet() nodes.forEach { check( - it.parent == null || it.parent === this - ) { "Edges to behave encapsulated (offender: $it)" } + it.parent == null || it.parent === this) { "Edges to behave encapsulated (offender: $it)" } it.parent = this } } @@ -123,11 +116,9 @@ ${edges.map { it.visualize() }.reduce { a, b -> "$a\n$b" }} println("Handling exception as ${edge.trigger}") currentNode = edge.target } else { - println( - "Could not handle trigger $e (Available triggers: ${ - currentNode.outEdges.map { it.trigger }.toList() - })" - ) + println("Could not handle trigger $e (Available triggers: ${ + currentNode.outEdges.map { it.trigger }.toList() + })") throw e } } diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/GsonUtils.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/GsonUtils.kt index 8ef9ed0318..ad9011bd82 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/GsonUtils.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/GsonUtils.kt @@ -76,40 +76,30 @@ private fun traceHelper(stateType: java.lang.reflect.Type): java.lang.reflect.Ty ).type @JvmOverloads -internal fun getGson( - xcfa: XCFA, domain: () -> Domain = { error("Domain needs to be specified.") }, - solver: () -> Solver = { error("Solver is necessary.") } -): Gson { +internal fun getGson(xcfa: XCFA, domain: () -> Domain = { error("Domain needs to be specified.") }, + solver: () -> Solver = { error("Solver is necessary.") }): Gson { val (scope, env) = xcfa.getSymbols() return getGson(scope, env, false, domain, solver) } @JvmOverloads -internal fun getGson( - domain: () -> Domain = { error("Domain needs to be specified.") }, - solver: () -> Solver = { error("Solver is necessary.") } -): Gson { +internal fun getGson(domain: () -> Domain = { error("Domain needs to be specified.") }, + solver: () -> Solver = { error("Solver is necessary.") }): Gson { return getGson(XcfaScope(SymbolTable()), Env(), true, domain, solver) } -private fun getGson( - scope: XcfaScope, env: Env, newScope: Boolean, domain: () -> Domain, - solver: () -> Solver -): Gson { +private fun getGson(scope: XcfaScope, env: Env, newScope: Boolean, domain: () -> Domain, + solver: () -> Solver): Gson { val gsonBuilder = GsonBuilder() lateinit var gson: Gson gsonBuilder.registerTypeHierarchyAdapter(FrontendConfig::class.java, SpecFrontendConfigTypeAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(BackendConfig::class.java, SpecBackendConfigTypeAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(File::class.java, StringTypeAdapter { File(it) }) - gsonBuilder.registerTypeHierarchyAdapter( - XcfaLocation::class.java, - StringTypeAdapter(xcfaLocationAdapter) - ) + gsonBuilder.registerTypeHierarchyAdapter(XcfaLocation::class.java, + StringTypeAdapter(xcfaLocationAdapter)) gsonBuilder.registerTypeHierarchyAdapter(XCFA::class.java, XcfaAdapter { gson }) - gsonBuilder.registerTypeHierarchyAdapter( - VarDecl::class.java, - VarDeclAdapter({ gson }, scope, env, !newScope) - ) + gsonBuilder.registerTypeHierarchyAdapter(VarDecl::class.java, + VarDeclAdapter({ gson }, scope, env, !newScope)) gsonBuilder.registerTypeHierarchyAdapter(Stmt::class.java, StringTypeAdapter { StatementWrapper(it, scope).instantiate(env) }) gsonBuilder.registerTypeHierarchyAdapter(Expr::class.java, @@ -119,14 +109,10 @@ private fun getGson( gsonBuilder.registerTypeHierarchyAdapter(VarIndexing::class.java, StringTypeAdapter { BasicVarIndexing.fromString(it, scope, env) }) gsonBuilder.registerTypeHierarchyAdapter(ExplState::class.java, ExplStateAdapter(scope, env)) - gsonBuilder.registerTypeHierarchyAdapter( - PredState::class.java, - PredStateAdapter({ gson }, scope, env) - ) - gsonBuilder.registerTypeHierarchyAdapter( - XcfaLabel::class.java, - XcfaLabelAdapter(scope, env, { gson }) - ) + gsonBuilder.registerTypeHierarchyAdapter(PredState::class.java, + PredStateAdapter({ gson }, scope, env)) + gsonBuilder.registerTypeHierarchyAdapter(XcfaLabel::class.java, + XcfaLabelAdapter(scope, env, { gson })) gsonBuilder.registerTypeHierarchyAdapter(MetaData::class.java, MetaDataAdapter()) gsonBuilder.registerTypeHierarchyAdapter(Pair::class.java, PairAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(Optional::class.java, OptionalAdapter { gson }) @@ -134,19 +120,15 @@ private fun getGson( XcfaStateAdapter({ gson }) { domain().stateType }) gsonBuilder.registerTypeHierarchyAdapter(XcfaAction::class.java, XcfaActionAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(Trace::class.java, TraceAdapter({ gson }, { - TypeToken.getParameterized( - TypeToken.get(XcfaState::class.java).type, - domain().stateType - ).type + TypeToken.getParameterized(TypeToken.get(XcfaState::class.java).type, + domain().stateType).type }, TypeToken.get(XcfaAction::class.java).type)) gsonBuilder.registerTypeHierarchyAdapter(ARG::class.java, ArgAdapter({ gson }, { domain().partialOrd(solver()) }, - { argAdapterHelper(domain().stateType) }) - ) + { argAdapterHelper(domain().stateType) })) gsonBuilder.registerTypeHierarchyAdapter(SafetyResult::class.java, SafetyResultAdapter({ gson }, { argHelper(domain().stateType) }, - { traceHelper(domain().stateType) }) - ) + { traceHelper(domain().stateType) })) gsonBuilder.registerTypeHierarchyAdapter(ParseContext::class.java, ParseContextAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(FrontendMetadata::class.java, diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/PropertyUtils.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/PropertyUtils.kt index cc3c24338d..c053280a14 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/PropertyUtils.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/PropertyUtils.kt @@ -36,10 +36,8 @@ fun determineProperty(config: XcfaConfig<*, *>, logger: Logger): ErrorDetection } else -> { - logger.write( - Logger.Level.INFO, - "Unknown property $propertyFile, using full state space exploration (no refinement)\n" - ) + logger.write(Logger.Level.INFO, + "Unknown property $propertyFile, using full state space exploration (no refinement)\n") ErrorDetection.NO_ERROR } } diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaParser.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaParser.kt index a987f153d7..cb18d5c237 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaParser.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaParser.kt @@ -46,17 +46,13 @@ fun getXcfa(config: XcfaConfig<*, *>, parseContext: ParseContext, logger: Logger when (config.frontendConfig.inputType) { InputType.CHC -> { val chcConfig = config.frontendConfig.specConfig as CHCFrontendConfig - parseChc( - config.inputConfig.input!!, chcConfig.chcTransformation, parseContext, logger, - uniqueWarningLogger - ) + parseChc(config.inputConfig.input!!, chcConfig.chcTransformation, parseContext, logger, + uniqueWarningLogger) } InputType.C -> { - parseC( - config.inputConfig.input!!, config.inputConfig.property, parseContext, logger, - uniqueWarningLogger - ) + parseC(config.inputConfig.input!!, config.inputConfig.property, parseContext, logger, + uniqueWarningLogger) } InputType.LLVM -> XcfaUtils.fromFile(config.inputConfig.input!!, ArithmeticType.efficient) @@ -80,65 +76,48 @@ fun getXcfa(config: XcfaConfig<*, *>, parseContext: ParseContext, logger: Logger exitProcess(ExitCodes.FRONTEND_FAILED.code) } -private fun parseC( - input: File, explicitProperty: ErrorDetection, parseContext: ParseContext, logger: Logger, - uniqueWarningLogger: Logger -): XCFA { +private fun parseC(input: File, explicitProperty: ErrorDetection, parseContext: ParseContext, logger: Logger, + uniqueWarningLogger: Logger): XCFA { val xcfaFromC = try { val stream = FileInputStream(input) - getXcfaFromC( - stream, parseContext, false, - explicitProperty == ErrorDetection.OVERFLOW, uniqueWarningLogger - ).first + getXcfaFromC(stream, parseContext, false, + explicitProperty == ErrorDetection.OVERFLOW, uniqueWarningLogger).first } catch (e: Throwable) { if (parseContext.arithmetic == ArchitectureConfig.ArithmeticType.efficient) { parseContext.arithmetic = ArchitectureConfig.ArithmeticType.bitvector logger.write(Logger.Level.INFO, "Retrying parsing with bitvector arithmetic...\n") val stream = FileInputStream(input) - val xcfa = getXcfaFromC( - stream, parseContext, false, - explicitProperty == ErrorDetection.OVERFLOW, uniqueWarningLogger - ).first + val xcfa = getXcfaFromC(stream, parseContext, false, + explicitProperty == ErrorDetection.OVERFLOW, uniqueWarningLogger).first parseContext.addArithmeticTrait(ArithmeticTrait.BITWISE) xcfa } else { throw e } } - logger.write( - Logger.Level.RESULT, - "Arithmetic: ${parseContext.arithmeticTraits}\n" - ) + logger.write(Logger.Level.RESULT, + "Arithmetic: ${parseContext.arithmeticTraits}\n") return xcfaFromC } -private fun parseChc( - input: File, chcTransformation: ChcFrontend.ChcTransformation, parseContext: ParseContext, - logger: Logger, uniqueWarningLogger: Logger -): XCFA { +private fun parseChc(input: File, chcTransformation: ChcFrontend.ChcTransformation, parseContext: ParseContext, + logger: Logger, uniqueWarningLogger: Logger): XCFA { var chcFrontend: ChcFrontend - val xcfaBuilder = - if (chcTransformation == ChcFrontend.ChcTransformation.PORTFOLIO) { // try forward, fallback to backward - chcFrontend = ChcFrontend(ChcFrontend.ChcTransformation.FORWARD) - try { - chcFrontend.buildXcfa( - CharStreams.fromStream(FileInputStream(input)), - ChcPasses(parseContext, uniqueWarningLogger) - ) - } catch (e: UnsupportedOperationException) { - logger.write(Logger.Level.INFO, "Non-linear CHC found, retrying using backward transformation...\n") - chcFrontend = ChcFrontend(ChcFrontend.ChcTransformation.BACKWARD) - chcFrontend.buildXcfa( - CharStreams.fromStream(FileInputStream(input)), - ChcPasses(parseContext, uniqueWarningLogger) - ) - } - } else { - chcFrontend = ChcFrontend(chcTransformation) - chcFrontend.buildXcfa( - CharStreams.fromStream(FileInputStream(input)), - ChcPasses(parseContext, uniqueWarningLogger) - ) + val xcfaBuilder = if (chcTransformation == ChcFrontend.ChcTransformation.PORTFOLIO) { // try forward, fallback to backward + chcFrontend = ChcFrontend(ChcFrontend.ChcTransformation.FORWARD) + try { + chcFrontend.buildXcfa(CharStreams.fromStream(FileInputStream(input)), + ChcPasses(parseContext, uniqueWarningLogger)) + } catch (e: UnsupportedOperationException) { + logger.write(Logger.Level.INFO, "Non-linear CHC found, retrying using backward transformation...\n") + chcFrontend = ChcFrontend(ChcFrontend.ChcTransformation.BACKWARD) + chcFrontend.buildXcfa(CharStreams.fromStream(FileInputStream(input)), + ChcPasses(parseContext, uniqueWarningLogger)) } + } else { + chcFrontend = ChcFrontend(chcTransformation) + chcFrontend.buildXcfa(CharStreams.fromStream(FileInputStream(input)), + ChcPasses(parseContext, uniqueWarningLogger)) + } return xcfaBuilder.build() } \ No newline at end of file diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaWitnessWriter.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaWitnessWriter.kt index 5ad00f3717..722fa7d91d 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaWitnessWriter.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/utils/XcfaWitnessWriter.kt @@ -47,8 +47,7 @@ class XcfaWitnessWriter { if (safetyResult.isUnsafe && safetyResult.asUnsafe().cex is Trace<*, *>) { val concrTrace: Trace, XcfaAction> = XcfaTraceConcretizer.concretize( safetyResult.asUnsafe().cex as Trace>, XcfaAction>?, cexSolverFactory, - parseContext - ) + parseContext) val witnessTrace = traceToWitness(trace = concrTrace, parseContext = parseContext) val witness = Witness(witnessTrace, inputFile) @@ -58,93 +57,63 @@ class XcfaWitnessWriter { val taskHash = WitnessWriter.createTaskHash(inputFile.absolutePath) val dummyWitness = StringBuilder() dummyWitness.append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "false" - ).append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "" - ) + "false").append(System.lineSeparator()).append( + "").append(System.lineSeparator()).append( + "") .append(System.lineSeparator()).append( - "false" - ).append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "" - ) + "false").append(System.lineSeparator()).append( + "").append(System.lineSeparator()).append( + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ) + "") .append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "correctness_witness" - ) + "").append(System.lineSeparator()).append( + "correctness_witness") .append(System.lineSeparator()).append( - "theta" - ).append(System.lineSeparator()).append( - "CHECK( init(main()), LTL(G ! call(reach_error())) )" - ) + "theta").append(System.lineSeparator()).append( + "CHECK( init(main()), LTL(G ! call(reach_error())) )") .append(System.lineSeparator()).append( - "C" - ).append(System.lineSeparator()).append( - "32bit" - ).append(System.lineSeparator()) + "C").append(System.lineSeparator()).append( + "32bit").append(System.lineSeparator()) .append( - "" - ) + "") dummyWitness.append(taskHash) dummyWitness.append("").append(System.lineSeparator()).append( - "" - ) + "") val tz: TimeZone = TimeZone.getTimeZone("UTC") val df: DateFormat = SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss'Z'" - ) // Quoted "Z" to indicate UTC, no timezone offset + "yyyy-MM-dd'T'HH:mm:ss'Z'") // Quoted "Z" to indicate UTC, no timezone offset df.timeZone = tz val isoDate: String = df.format(Date()) dummyWitness.append(isoDate) dummyWitness.append("").append(System.lineSeparator()).append( - "" - ) + "") dummyWitness.append(inputFile.name) dummyWitness.append("").append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "true" - ).append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "" - ).append(System.lineSeparator()).append( - "" - ) + "").append(System.lineSeparator()).append( + "true").append(System.lineSeparator()).append( + "").append(System.lineSeparator()).append( + "").append(System.lineSeparator()).append( + "") try { BufferedWriter(FileWriter(witnessfile)).use { bw -> diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/TraceToWitness.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/TraceToWitness.kt index d6848feffe..38ab39f52b 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/TraceToWitness.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/TraceToWitness.kt @@ -46,10 +46,8 @@ fun traceToWitness( val newStates = ArrayList() val newActions = ArrayList() - var lastNode = WitnessNode( - id = "N${newStates.size}", entry = true, sink = false, - violation = false - ) + var lastNode = WitnessNode(id = "N${newStates.size}", entry = true, sink = false, + violation = false) newStates.add(lastNode) for (i in 0 until trace.length()) { @@ -69,10 +67,8 @@ fun traceToWitness( ) if (node != WitnessNode(id = "N${newStates.size}")) { newStates.add(node) - val edge = WitnessEdge( - sourceId = lastNode.id, targetId = node.id, - threadId = trace.actions[i].pid.toString() - ) + val edge = WitnessEdge(sourceId = lastNode.id, targetId = node.id, + threadId = trace.actions[i].pid.toString()) newActions.add(edge) lastNode = node } @@ -80,14 +76,10 @@ fun traceToWitness( val action = trace.actions[i] val flattenedSequence = flattenSequence(action.edge.label) for (xcfaLabel in flattenedSequence) { - val node = WitnessNode( - id = "N${newStates.size}", entry = false, sink = false, - violation = false - ) - var edge = labelToEdge( - lastNode, node, xcfaLabel, action.pid, - nextState.sGlobal.getVal(), parseContext - ) + val node = WitnessNode(id = "N${newStates.size}", entry = false, sink = false, + violation = false) + var edge = labelToEdge(lastNode, node, xcfaLabel, action.pid, + nextState.sGlobal.getVal(), parseContext) if (newThreads.isNotEmpty() && xcfaLabel is StartLabel) { edge = edge.copy(createThread = newThreads.joinToString(",")) } @@ -128,10 +120,8 @@ fun shouldInclude(edge: WitnessEdge, verbosity: Verbosity): Boolean = } -private fun labelToEdge( - lastNode: WitnessNode, node: WitnessNode, xcfaLabel: XcfaLabel, pid: Int, - valuation: Valuation, parseContext: ParseContext -): WitnessEdge = +private fun labelToEdge(lastNode: WitnessNode, node: WitnessNode, xcfaLabel: XcfaLabel, pid: Int, + valuation: Valuation, parseContext: ParseContext): WitnessEdge = WitnessEdge( sourceId = lastNode.id, targetId = node.id, @@ -200,17 +190,14 @@ private fun printLit(litExpr: LitExpr<*>): String? { for (i in boolList.indices) { if (i % 4 == 0 && i > 0) { if (aggregate < 10) hexDigits.add( - ('0'.code + aggregate).toChar() - ) else hexDigits.add( - ('A'.code - 10 + aggregate).toChar() - ) + ('0'.code + aggregate).toChar()) else hexDigits.add( + ('A'.code - 10 + aggregate).toChar()) aggregate = 0 } if (boolList[i]) aggregate += 1 shl i % 4 } if (aggregate < 10) hexDigits.add(('0'.code + aggregate).toChar()) else hexDigits.add( - ('A'.code - 10 + aggregate).toChar() - ) + ('A'.code - 10 + aggregate).toChar()) val stringBuilder = StringBuilder("0x") for (character in Lists.reverse(hexDigits)) { stringBuilder.append(character) diff --git a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/Witness.kt b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/Witness.kt index 4bcbcc99bb..4569a1b557 100644 --- a/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/Witness.kt +++ b/subprojects/xcfa/xcfa-cli/src/main/java/hu/bme/mit/theta/xcfa/cli/witnesses/Witness.kt @@ -59,12 +59,8 @@ class Witness(private val trace: Trace, programFile: F attributes.add(WitnessAttribute("assumption", "string", "edge", "assumption")) attributes.add(WitnessAttribute("assumption.scope", "string", "edge", "assumption.scope")) - attributes.add( - WitnessAttribute( - "assumption.resultfunction", "string", "edge", - "assumption.resultfunction" - ) - ) + attributes.add(WitnessAttribute("assumption.resultfunction", "string", "edge", + "assumption.resultfunction")) attributes.add(WitnessAttribute("control", "string", "edge", "control")) attributes.add(WitnessAttribute("startline", "string", "edge", "startline")) attributes.add(WitnessAttribute("endline", "string", "edge", "endline")) @@ -73,8 +69,7 @@ class Witness(private val trace: Trace, programFile: F attributes.add(WitnessAttribute("enterLoopHead", "string", "edge", "enterLoopHead")) attributes.add(WitnessAttribute("enterFunction", "string", "edge", "enterFunction")) attributes.add( - WitnessAttribute("returnFromFunction", "string", "edge", "returnFromFunction") - ) + WitnessAttribute("returnFromFunction", "string", "edge", "returnFromFunction")) attributes.add(WitnessAttribute("threadId", "string", "edge", "threadId")) attributes.add(WitnessAttribute("createThread", "string", "edge", "createThread")) attributes.add(WitnessAttribute("stmt", "string", "edge", "stmt")) @@ -276,8 +271,7 @@ private fun bytesToHex(hash: ByteArray): String { private fun getIsoDate(): String { val tz: TimeZone = TimeZone.getTimeZone("UTC") val df: DateFormat = SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss'Z'" - ) // Quoted "Z" to indicate UTC, no timezone offset + "yyyy-MM-dd'T'HH:mm:ss'Z'") // Quoted "Z" to indicate UTC, no timezone offset df.timeZone = tz return df.format(Date()) @@ -287,8 +281,7 @@ private fun getIsoDate(): String { private fun prettyFormat(input: String, indent: Int): String { return try { val xmlInput: Source = StreamSource( - StringReader(input.replace(Regex("( )|[\\t\\n\\r]"), "")) - ) + StringReader(input.replace(Regex("( )|[\\t\\n\\r]"), ""))) val stringWriter = StringWriter() val xmlOutput = StreamResult(stringWriter) val transformerFactory: TransformerFactory = TransformerFactory.newInstance() diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt index d886fe23dd..a6aa6b8bb5 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliParseTest.kt @@ -169,14 +169,12 @@ class XcfaCliParseTest { @ParameterizedTest @MethodSource("cFiles") fun testCParse(filePath: String) { - main( - arrayOf( - "--input-type", "C", - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "C", + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", "--stacktrace", + "--debug" + )) } // @ParameterizedTest @@ -194,71 +192,61 @@ class XcfaCliParseTest { @ParameterizedTest @MethodSource("chcFiles") fun testCHCParse(filePath: String, chcTransformation: ChcFrontend.ChcTransformation) { - main( - arrayOf( - "--input-type", "CHC", - "--chc-transformation", chcTransformation.toString(), - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", - "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "CHC", + "--chc-transformation", chcTransformation.toString(), + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", + "--stacktrace", + "--debug" + )) } @ParameterizedTest @MethodSource("dslFiles") fun testDSLParse(filePath: String) { - main( - arrayOf( - "--input-type", "DSL", - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", - "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "DSL", + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", + "--stacktrace", + "--debug" + )) } @ParameterizedTest @MethodSource("jsonFiles") fun testJSONParse(filePath: String) { - main( - arrayOf( - "--input-type", "JSON", - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", - "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "JSON", + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", + "--stacktrace", + "--debug" + )) } @ParameterizedTest @MethodSource("cFiles") fun testJSONParseRoundTrip(filePath: String) { val temp = createTempDirectory() - main( - arrayOf( - "--enable-output", - "--input-type", "C", - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", - "--stacktrace", - "--output-directory", temp.toAbsolutePath().toString(), - "--debug" - ) - ) + main(arrayOf( + "--enable-output", + "--input-type", "C", + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", + "--stacktrace", + "--output-directory", temp.toAbsolutePath().toString(), + "--debug" + )) val xcfaJson = temp.resolve("xcfa.json").toFile() - main( - arrayOf( - "--input-type", "JSON", - "--input", xcfaJson.absolutePath.toString(), - "--backend", "NONE", - "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "JSON", + "--input", xcfaJson.absolutePath.toString(), + "--backend", "NONE", + "--stacktrace", + "--debug" + )) temp.toFile().deleteRecursively() } @@ -266,28 +254,24 @@ class XcfaCliParseTest { @MethodSource("simpleCFiles") fun testCParseRoundTrip(filePath: String) { val temp = createTempDirectory() - main( - arrayOf( - "--enable-output", - "--input-type", "C", - "--input", javaClass.getResource(filePath)!!.path, - "--backend", "NONE", - "--stacktrace", - "--output-directory", temp.toAbsolutePath().toString(), - "--debug" - ) - ) + main(arrayOf( + "--enable-output", + "--input-type", "C", + "--input", javaClass.getResource(filePath)!!.path, + "--backend", "NONE", + "--stacktrace", + "--output-directory", temp.toAbsolutePath().toString(), + "--debug" + )) val xcfaC = temp.resolve("xcfa.c").toFile() checkState(xcfaC.exists(), "File does not exist: $xcfaC") - main( - arrayOf( - "--input-type", "C", - "--input", xcfaC.absolutePath.toString(), - "--backend", "NONE", - "--stacktrace", - "--debug" - ) - ) + main(arrayOf( + "--input-type", "C", + "--input", xcfaC.absolutePath.toString(), + "--backend", "NONE", + "--stacktrace", + "--debug" + )) temp.toFile().deleteRecursively() } diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliPortfolioTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliPortfolioTest.kt index d7838c0403..9d9dc0e0f2 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliPortfolioTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliPortfolioTest.kt @@ -63,23 +63,17 @@ class XcfaCliPortfolioTest { @ParameterizedTest @MethodSource("portfolios") - fun testPortfolio( - portfolio: ( - xcfa: XCFA, - mcm: MCM, - parseContext: ParseContext, - portfolioConfig: XcfaConfig<*, *>, - logger: Logger, - uniqueLogger: Logger - ) -> STM - ) { + fun testPortfolio(portfolio: (xcfa: XCFA, + mcm: MCM, + parseContext: ParseContext, + portfolioConfig: XcfaConfig<*, *>, + logger: Logger, + uniqueLogger: Logger) -> STM) { for (value in ArithmeticTrait.values()) { - val stm = portfolio( - XCFA("name", setOf()), emptySet(), ParseContext(), - XcfaConfig(), NullLogger.getInstance(), NullLogger.getInstance() - ) + val stm = portfolio(XCFA("name", setOf()), emptySet(), ParseContext(), + XcfaConfig(), NullLogger.getInstance(), NullLogger.getInstance()) Assertions.assertTrue(stm.visualize().isNotEmpty()) } diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliVerifyTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliVerifyTest.kt index 8b1c73b540..c5fb4dbb56 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliVerifyTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliVerifyTest.kt @@ -144,10 +144,8 @@ class XcfaCliVerifyTest { fun chcFiles(): Stream { return Stream.of( Arguments.of("/chc/chc-LIA-Lin_000.smt2", ChcFrontend.ChcTransformation.FORWARD, "--domain PRED_CART"), - Arguments.of( - "/chc/chc-LIA-Arrays_000.smt2", ChcFrontend.ChcTransformation.BACKWARD, - "--domain PRED_CART --search BFS" - ), + Arguments.of("/chc/chc-LIA-Arrays_000.smt2", ChcFrontend.ChcTransformation.BACKWARD, + "--domain PRED_CART --search BFS"), ) } } @@ -245,16 +243,14 @@ class XcfaCliVerifyTest { @ParameterizedTest @MethodSource("chcFiles") fun testCHCVerify(filePath: String, chcTransformation: ChcFrontend.ChcTransformation, extraArgs: String?) { - main( - arrayOf( - "--input-type", "CHC", - "--chc-transformation", chcTransformation.toString(), - "--input", javaClass.getResource(filePath)!!.path, - "--stacktrace", - *(extraArgs?.split(" ")?.toTypedArray() ?: emptyArray()), - "--debug" - ) - ) + main(arrayOf( + "--input-type", "CHC", + "--chc-transformation", chcTransformation.toString(), + "--input", javaClass.getResource(filePath)!!.path, + "--stacktrace", + *(extraArgs?.split(" ")?.toTypedArray() ?: emptyArray()), + "--debug" + )) } @ParameterizedTest diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliWitnessTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliWitnessTest.kt index 8405c761ae..bc5657f5ba 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliWitnessTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaCliWitnessTest.kt @@ -39,28 +39,24 @@ class XcfaCliWitnessTest { @JvmStatic fun cFiles(): Stream { return Stream.of( - Arguments.of( - "/c/litmustest/singlethread/witness_test.c", null, listOf( - WitnessEdge( - startlineRange = Pair(5, 5), - endlineRange = Pair(5, 5), - startoffsetRange = Pair(100, 130), - endoffsetRange = Pair(100, 130), - assumption = Regex("i *== *-1"), - ), - ) - ), - Arguments.of( - "/c/litmustest/singlethread/witness_test.c", "--backend BOUNDED", listOf( - WitnessEdge( - startlineRange = Pair(5, 5), - endlineRange = Pair(5, 5), - startoffsetRange = Pair(100, 130), - endoffsetRange = Pair(100, 130), - assumption = Regex("i *== *-1"), - ), - ) - ), + Arguments.of("/c/litmustest/singlethread/witness_test.c", null, listOf( + WitnessEdge( + startlineRange = Pair(5, 5), + endlineRange = Pair(5, 5), + startoffsetRange = Pair(100, 130), + endoffsetRange = Pair(100, 130), + assumption = Regex("i *== *-1"), + ), + )), + Arguments.of("/c/litmustest/singlethread/witness_test.c", "--backend BOUNDED", listOf( + WitnessEdge( + startlineRange = Pair(5, 5), + endlineRange = Pair(5, 5), + startoffsetRange = Pair(100, 130), + endoffsetRange = Pair(100, 130), + assumption = Regex("i *== *-1"), + ), + )), ) } diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaDslTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaDslTest.kt index 8fb8f64b90..53d5ba6130 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaDslTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaDslTest.kt @@ -88,23 +88,18 @@ class XcfaDslTest { fun verifyXcfa() { SolverManager.registerSolverManager(Z3SolverManager.create()) val config = XcfaConfig( - backendConfig = BackendConfig(backend = Backend.CEGAR, specConfig = CegarConfig()) - ) + backendConfig = BackendConfig(backend = Backend.CEGAR, specConfig = CegarConfig())) run { val xcfa = getSyncXcfa() - val checker = getChecker( - xcfa, emptySet(), config, ParseContext(), NullLogger.getInstance(), - NullLogger.getInstance() - ) + val checker = getChecker(xcfa, emptySet(), config, ParseContext(), NullLogger.getInstance(), + NullLogger.getInstance()) val safetyResult = checker.check() Assert.assertTrue(safetyResult.isSafe) } run { val xcfa = getAsyncXcfa() - val checker = getChecker( - xcfa, emptySet(), config, ParseContext(), NullLogger.getInstance(), - NullLogger.getInstance() - ) + val checker = getChecker(xcfa, emptySet(), config, ParseContext(), NullLogger.getInstance(), + NullLogger.getInstance()) val safetyResult = checker.check() Assert.assertTrue(safetyResult.isUnsafe) } diff --git a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaToCTest.kt b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaToCTest.kt index fc7783b64f..51372ee26d 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaToCTest.kt +++ b/subprojects/xcfa/xcfa-cli/src/test/java/hu/bme/mit/theta/xcfa/cli/XcfaToCTest.kt @@ -55,17 +55,11 @@ class XcfaToCTest { val chcFrontend = ChcFrontend(chcTransformation) val xcfa = chcFrontend.buildXcfa( CharStreams.fromStream(FileInputStream(javaClass.getResource(filePath)!!.path)), ChcPasses( - ParseContext(), NullLogger.getInstance() - ) - ).build() + ParseContext(), NullLogger.getInstance())).build() val temp = createTempDirectory() val file = temp.resolve("${filePath.split("/").last()}.c").also { - it.toFile().writeText( - xcfa.toC( - ParseContext(), - true, false, false - ) - ) + it.toFile().writeText(xcfa.toC(ParseContext(), + true, false, false)) } System.err.println(file) } diff --git a/subprojects/xcfa/xcfa-cli/src/test/resources/simple.kts b/subprojects/xcfa/xcfa-cli/src/test/resources/simple.kts index 2a8aaae312..fb98c7344d 100644 --- a/subprojects/xcfa/xcfa-cli/src/test/resources/simple.kts +++ b/subprojects/xcfa/xcfa-cli/src/test/resources/simple.kts @@ -34,8 +34,7 @@ fun portfolio( parseContext: ParseContext, portfolioConfig: XcfaConfig<*, *>, logger: Logger, - uniqueLogger: Logger -): STM { + uniqueLogger: Logger): STM { val checker = { config: XcfaConfig<*, *> -> runConfig(config, logger, uniqueLogger, true) } @@ -44,14 +43,12 @@ fun portfolio( input = null, xcfaWCtx = Triple(xcfa, mcm, parseContext), propertyFile = null, - property = portfolioConfig.inputConfig.property - ), + property = portfolioConfig.inputConfig.property), frontendConfig = FrontendConfig( lbeLevel = LbePass.LbeLevel.LBE_SEQ, loopUnroll = 50, inputType = InputType.C, - specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient) - ), + specConfig = CFrontendConfig(arithmetic = ArchitectureConfig.ArithmeticType.efficient)), backendConfig = BackendConfig( backend = Backend.CEGAR, solverHome = portfolioConfig.backendConfig.solverHome, @@ -75,9 +72,7 @@ fun portfolio( refinement = Refinement.SEQ_ITP, exprSplitter = ExprSplitterOptions.WHOLE, pruneStrategy = PruneStrategy.FULL - ) - ) - ), + ))), outputConfig = OutputConfig( versionInfo = false, resultFolder = Paths.get("./").toFile(), // cwd @@ -96,8 +91,7 @@ fun portfolio( abstractorConfig = baseCegarConfig.abstractorConfig.copy(search = Search.DFS), ) baseConfig = baseConfig.copy( - backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig) - ) + backendConfig = baseConfig.backendConfig.copy(specConfig = multiThreadedCegarConfig)) } if (!xcfa.isInlined) { diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/Utils.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/Utils.kt index 924f0f7a24..cc6f24571b 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/Utils.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/Utils.kt @@ -453,35 +453,27 @@ fun XcfaLabel.simplify(valuation: MutableValuation, parseContext: ParseContext): is MemoryAssignStmt<*, *, *> -> { simplified as MemoryAssignStmt<*, *, *> if (parseContext.metadata.getMetadataValue(stmt.expr, "cType").isPresent) - parseContext.metadata.create( - simplified.expr, "cType", - CComplexType.getType(stmt.expr, parseContext) - ) + parseContext.metadata.create(simplified.expr, "cType", + CComplexType.getType(stmt.expr, parseContext)) if (parseContext.metadata.getMetadataValue(stmt.deref, "cType").isPresent) - parseContext.metadata.create( - simplified.deref, "cType", - CComplexType.getType(stmt.deref, parseContext) - ) + parseContext.metadata.create(simplified.deref, "cType", + CComplexType.getType(stmt.deref, parseContext)) StmtLabel(simplified, metadata = metadata) } is AssignStmt<*> -> { simplified as AssignStmt<*> if (parseContext.metadata.getMetadataValue(stmt.expr, "cType").isPresent) - parseContext.metadata.create( - simplified.expr, "cType", - CComplexType.getType(stmt.expr, parseContext) - ) + parseContext.metadata.create(simplified.expr, "cType", + CComplexType.getType(stmt.expr, parseContext)) StmtLabel(simplified, metadata = metadata) } is AssumeStmt -> { simplified as AssumeStmt if (parseContext.metadata.getMetadataValue(stmt.cond, "cType").isPresent) { - parseContext.metadata.create( - simplified.cond, "cType", - CComplexType.getType(stmt.cond, parseContext) - ) + parseContext.metadata.create(simplified.cond, "cType", + CComplexType.getType(stmt.cond, parseContext)) } parseContext.metadata.create(simplified, "cTruth", stmt.cond is NeqExpr<*>) StmtLabel(simplified, metadata = metadata, choiceType = choiceType) @@ -528,10 +520,8 @@ val XCFA.lazyPointsToGraph: Lazy, Set>>> .filter { (i, pair) -> pair.second != ParamDirection.IN && it.params[i] is RefExpr<*> } .map { (i, pair) -> val (param, _) = pair - Assign( - cast((it.params[i] as RefExpr<*>).decl as VarDecl<*>, param.type), - cast(param.ref, param.type) - ) + Assign(cast((it.params[i] as RefExpr<*>).decl as VarDecl<*>, param.type), + cast(param.ref, param.type)) } } ?: listOf() } @@ -544,10 +534,8 @@ val XCFA.lazyPointsToGraph: Lazy, Set>>> Assign(cast(param, param.type), cast(it.params[i], param.type)) } + proc.params.filter { it.second != ParamDirection.IN }.mapIndexed { i, (param, _) -> - Assign( - cast((it.params[i] as RefExpr<*>).decl as VarDecl<*>, param.type), - cast(param.ref, param.type) - ) + Assign(cast((it.params[i] as RefExpr<*>).decl as VarDecl<*>, param.type), + cast(param.ref, param.type)) } } ?: listOf() } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/XcfaToC.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/XcfaToC.kt index 0114015fc1..6eacb8f086 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/XcfaToC.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/XcfaToC.kt @@ -57,10 +57,8 @@ import hu.bme.mit.theta.xcfa.model.* private const val arraySize = 10; -fun XCFA.toC( - parseContext: ParseContext, arraySupport: Boolean, exactArraySupport: Boolean, - intRangeConstraint: Boolean -): String = """ +fun XCFA.toC(parseContext: ParseContext, arraySupport: Boolean, exactArraySupport: Boolean, + intRangeConstraint: Boolean): String = """ extern void abort(); extern unsigned short __VERIFIER_nondet_ushort(); extern short __VERIFIER_nondet_short(); diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaAdapter.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaAdapter.kt index 338ff8d66d..9cf2736445 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaAdapter.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaAdapter.kt @@ -111,8 +111,7 @@ class XcfaAdapter(val gsonSupplier: () -> Gson) : TypeAdapter() { private fun parseInitProcedures( reader: JsonReader, - procedures: Map - ): List>>> { + procedures: Map): List>>> { reader.beginArray() val ret = ArrayList>>>() val paramsType = object : TypeToken>>() {}.type @@ -191,11 +190,9 @@ class XcfaAdapter(val gsonSupplier: () -> Gson) : TypeAdapter() { } } } - ret[name] = XcfaProcedure( - name, params, vars, locs.values.toSet(), edges, initLoc, + ret[name] = XcfaProcedure(name, params, vars, locs.values.toSet(), edges, initLoc, Optional.ofNullable(finalLoc), - Optional.ofNullable(errorLoc) - ).also { it.parent = xcfa } + Optional.ofNullable(errorLoc)).also { it.parent = xcfa } reader.endObject() } reader.endArray() diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaLabelAdapter.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaLabelAdapter.kt index a06254cf5b..eeebe05881 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaLabelAdapter.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/gson/XcfaLabelAdapter.kt @@ -80,14 +80,11 @@ class XcfaLabelAdapter(val scope: Scope, val env: Env, val gsonSupplier: () -> G checkNotNull(constructor) { "${clazz.simpleName} has no fromString() method." } val obj = try { - constructor.call( - clazz.companionObject!!.objectInstance, content, scope, env, - metadata - ) + constructor.call(clazz.companionObject!!.objectInstance, content, scope, env, + metadata) } catch (e: Exception) { System.err.println( - "Could not parse $content\nscope: ${scope}\nenv: $env\ntype: ${clazz.simpleName}" - ) + "Could not parse $content\nscope: ${scope}\nenv: $env\ntype: ${clazz.simpleName}") throw e } check(obj is XcfaLabel) diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Dsl.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Dsl.kt index e3885b34b8..b146c7d4f9 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Dsl.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Dsl.kt @@ -39,14 +39,10 @@ class VarContext(val builder: XcfaBuilder, private val local: Boolean) { infix fun Pair.init(initValue: String): VarDecl { val varDecl = Var(first, second) builder.addVar( - XcfaGlobalVar( - varDecl, + XcfaGlobalVar(varDecl, ExpressionWrapper(SimpleScope(SymbolTable()), initValue).instantiate( - Env() - ) as LitExpr<*>, - local - ) - ) + Env()) as LitExpr<*>, + local)) return varDecl } } @@ -93,8 +89,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { fun start(vararg expr: Any) { val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } builder.parent.addEntryPoint(builder, exprs) } @@ -117,8 +112,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { infix fun String.assign(to: String): SequenceLabel { val lhs: VarDecl = this@XcfaProcedureBuilderContext.builder.lookup( - this - ) as VarDecl + this) as VarDecl val rhs: Expr = this@XcfaProcedureBuilderContext.builder.parse(to) as Expr val label = StmtLabel(Assign(lhs, rhs)) labelList.add(label) @@ -134,8 +128,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { infix fun String.assign(to: Expr<*>): SequenceLabel { val lhs: VarDecl = this@XcfaProcedureBuilderContext.builder.lookup( - this - ) as VarDecl + this) as VarDecl val rhs: Expr = to as Expr val label = StmtLabel(Assign(lhs, rhs)) labelList.add(label) @@ -178,8 +171,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { operator fun XcfaProcedureBuilderContext.invoke(vararg expr: Any): SequenceLabel { val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = InvokeLabel(this.builder.name, exprs, EmptyMetaData) this@SequenceLabelContext.labelList.add(label) @@ -189,8 +181,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { operator fun String.invoke(vararg expr: Any): SequenceLabel { val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = InvokeLabel(this, exprs, EmptyMetaData) this@SequenceLabelContext.labelList.add(label) @@ -201,8 +192,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { val lhs = this@XcfaProcedureBuilderContext.builder.lookup(this) val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = StartLabel(ctx.builder.name, exprs, lhs, EmptyMetaData) labelList.add(label) @@ -212,8 +202,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { fun VarDecl<*>.start(ctx: XcfaProcedureBuilderContext, vararg expr: Any): SequenceLabel { val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = StartLabel(ctx.builder.name, exprs, this, EmptyMetaData) labelList.add(label) @@ -224,8 +213,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { val lhs = this@XcfaProcedureBuilderContext.builder.lookup(this) val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = StartLabel(ctx, exprs, lhs, EmptyMetaData) labelList.add(label) @@ -235,8 +223,7 @@ class XcfaProcedureBuilderContext(val builder: XcfaProcedureBuilder) { fun VarDecl<*>.start(ctx: String, vararg expr: Any): SequenceLabel { val exprs = expr.map { if (it is Expr<*>) it else if (it is String) this@XcfaProcedureBuilderContext.builder.parse( - it - ) else error("Bad type") + it) else error("Bad type") } val label = StartLabel(ctx, exprs, this, EmptyMetaData) labelList.add(label) @@ -314,10 +301,8 @@ fun XcfaBuilder.threadlocal(lambda: VarContext.() -> Unit) { context.apply(lambda) } -fun XcfaBuilder.procedure( - name: String, passManager: ProcedurePassManager, - lambda: XcfaProcedureBuilderContext.() -> Unit -): XcfaProcedureBuilderContext { +fun XcfaBuilder.procedure(name: String, passManager: ProcedurePassManager, + lambda: XcfaProcedureBuilderContext.() -> Unit): XcfaProcedureBuilderContext { val builder = XcfaProcedureBuilder(name, passManager) builder.parent = this val procBuilder = XcfaProcedureBuilderContext(builder).apply(lambda) @@ -325,9 +310,7 @@ fun XcfaBuilder.procedure( return procBuilder } -fun XcfaBuilder.procedure( - name: String, - lambda: XcfaProcedureBuilderContext.() -> Unit -): XcfaProcedureBuilderContext { +fun XcfaBuilder.procedure(name: String, + lambda: XcfaProcedureBuilderContext.() -> Unit): XcfaProcedureBuilderContext { return procedure(name, ProcedurePassManager(), lambda) } \ No newline at end of file diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Visualizer.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Visualizer.kt index 4080379efa..177c75758d 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Visualizer.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/Visualizer.kt @@ -37,8 +37,7 @@ fun XcfaProcedure.toDot(edgeLabelCustomizer: ((XcfaEdge) -> String)?): String { locs.forEach { builder.appendLine("${it.name}[];") } edges.forEach { builder.appendLine( - "${it.source.name} -> ${it.target.name} [label=\"${it.label} ${edgeLabelCustomizer?.invoke(it) ?: ""}\"];" - ) + "${it.source.name} -> ${it.target.name} [label=\"${it.label} ${edgeLabelCustomizer?.invoke(it) ?: ""}\"];") } return builder.toString() } \ No newline at end of file diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/XcfaLabel.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/XcfaLabel.kt index 519a9d8627..93f636b306 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/XcfaLabel.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/model/XcfaLabel.kt @@ -50,11 +50,9 @@ data class InvokeLabel @JvmOverloads constructor( fun fromString(s: String, scope: Scope, env: Env, metadata: MetaData): XcfaLabel { val (name, params) = Regex("([^\\(]*)\\((.*)\\)").matchEntire(s)!!.destructured - return InvokeLabel( - name, + return InvokeLabel(name, params.split(",").map { ExpressionWrapper(scope, it).instantiate(env) }, - metadata = metadata - ) + metadata = metadata) } } } @@ -89,14 +87,11 @@ data class StartLabel( fun fromString(s: String, scope: Scope, env: Env, metadata: MetaData): XcfaLabel { val (pidVarName, pidVarType, name, params) = Regex( - "\\(var (.*) (.*)\\) = start (.*)\\((.*)\\)" - ).matchEntire(s)!!.destructured + "\\(var (.*) (.*)\\) = start (.*)\\((.*)\\)").matchEntire(s)!!.destructured val pidVar = env.eval(scope.resolve(pidVarName).orElseThrow()) as VarDecl<*> - return StartLabel( - name, + return StartLabel(name, params.split(",").map { ExpressionWrapper(scope, it).instantiate(env) }, pidVar, - metadata = metadata - ) + metadata = metadata) } } } @@ -114,8 +109,7 @@ data class JoinLabel( fun fromString(s: String, scope: Scope, env: Env, metadata: MetaData): XcfaLabel { val (pidVarName, pidVarType) = Regex("join \\(var (.*) (.*)\\)").matchEntire( - s - )!!.destructured + s)!!.destructured val pidVar = env.eval(scope.resolve(pidVarName).orElseThrow()) as VarDecl<*> return JoinLabel(pidVar, metadata = metadata) } @@ -136,8 +130,7 @@ data class StmtLabel @JvmOverloads constructor( init { check( - stmt !is NonDetStmt && stmt !is SequenceStmt - ) { "NonDetStmt and SequenceStmt are not supported in XCFA. Use the corresponding labels instead." } + stmt !is NonDetStmt && stmt !is SequenceStmt) { "NonDetStmt and SequenceStmt are not supported in XCFA. Use the corresponding labels instead." } } override fun toStmt(): Stmt = stmt @@ -154,15 +147,11 @@ data class StmtLabel @JvmOverloads constructor( val matchResult = Regex("\\((.*)\\)\\[choiceType=(.*)]").matchEntire(s) if (matchResult != null) { val (stmt, choiceTypeStr) = matchResult.destructured - return StmtLabel( - StatementWrapper(stmt, scope).instantiate(env), - choiceType = ChoiceType.valueOf(choiceTypeStr), metadata = metadata - ) + return StmtLabel(StatementWrapper(stmt, scope).instantiate(env), + choiceType = ChoiceType.valueOf(choiceTypeStr), metadata = metadata) } else { - return StmtLabel( - StatementWrapper(s, scope).instantiate(env), - choiceType = ChoiceType.NONE, metadata = metadata - ) + return StmtLabel(StatementWrapper(s, scope).instantiate(env), + choiceType = ChoiceType.NONE, metadata = metadata) } } } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AssumeFalseRemovalPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AssumeFalseRemovalPass.kt index 7db5191f4b..17bbdde26e 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AssumeFalseRemovalPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AssumeFalseRemovalPass.kt @@ -29,8 +29,7 @@ class AssumeFalseRemovalPass : ProcedurePass { override fun run(builder: XcfaProcedureBuilder): XcfaProcedureBuilder { builder.getEdges().toSet().forEach { edge -> if (edge.getFlatLabels() - .any { it is StmtLabel && it.stmt is AssumeStmt && it.stmt.cond is FalseExpr } - ) { + .any { it is StmtLabel && it.stmt is AssumeStmt && it.stmt.cond is FalseExpr }) { builder.removeEdge(edge) } } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AtomicReadsOneWritePass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AtomicReadsOneWritePass.kt index 5366595cc5..d4927ebaad 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AtomicReadsOneWritePass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/AtomicReadsOneWritePass.kt @@ -160,12 +160,9 @@ class AtomicReadsOneWritePass : ProcedurePass { private fun XcfaLabel.replaceAccesses(localVersions: Map, VarDecl<*>>): XcfaLabel { return when (this) { is StmtLabel -> when (val stmt = stmt) { - is AssignStmt<*> -> StmtLabel( - AssignStmt.of( - cast(localVersions[stmt.varDecl] ?: stmt.varDecl, stmt.varDecl.type), - cast(stmt.expr.replace(localVersions), stmt.varDecl.type) - ) - ) + is AssignStmt<*> -> StmtLabel(AssignStmt.of( + cast(localVersions[stmt.varDecl] ?: stmt.varDecl, stmt.varDecl.type), + cast(stmt.expr.replace(localVersions), stmt.varDecl.type))) is AssumeStmt -> StmtLabel(AssumeStmt.of(stmt.cond.replace(localVersions))) is HavocStmt<*> -> StmtLabel(HavocStmt.of(localVersions[stmt.varDecl] ?: stmt.varDecl)) diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/CLibraryFunctionsPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/CLibraryFunctionsPass.kt index 9fddf43123..7803f1daaf 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/CLibraryFunctionsPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/CLibraryFunctionsPass.kt @@ -71,13 +71,9 @@ class CLibraryFunctionsPass : ProcedurePass { val param = invokeLabel.params[4] - listOf( - StartLabel( - (funcptr as RefExpr).decl.name, - listOf(Int(0), param), // int(0) to solve StartLabel not handling return params - (handle as RefExpr).decl as VarDecl<*>, metadata - ) - ) + listOf(StartLabel((funcptr as RefExpr).decl.name, + listOf(Int(0), param), // int(0) to solve StartLabel not handling return params + (handle as RefExpr).decl as VarDecl<*>, metadata)) } "pthread_mutex_lock" -> { @@ -105,10 +101,8 @@ class CLibraryFunctionsPass : ProcedurePass { check(handle is RefExpr && (handle as RefExpr).decl is VarDecl) listOf( - FenceLabel( - setOf("start_cond_wait(${cond.decl.name},${handle.decl.name})"), - metadata - ), + FenceLabel(setOf("start_cond_wait(${cond.decl.name},${handle.decl.name})"), + metadata), FenceLabel(setOf("cond_wait(${cond.decl.name},${handle.decl.name})"), metadata) ) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ErrorLocationPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ErrorLocationPass.kt index 6dd64e2b45..d539cb6240 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ErrorLocationPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ErrorLocationPass.kt @@ -29,16 +29,13 @@ class ErrorLocationPass(private val checkOverflow: Boolean) : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { if (builder.errorLoc.isEmpty) builder.createErrorLoc() builder.addEdge( - XcfaEdge(it.source, builder.errorLoc.get(), SequenceLabel(listOf())) - ) + XcfaEdge(it.source, builder.errorLoc.get(), SequenceLabel(listOf()))) } else { builder.addEdge(it) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FetchExecuteWriteback.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FetchExecuteWriteback.kt index 894f89ccb2..0ed1eee7a1 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FetchExecuteWriteback.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FetchExecuteWriteback.kt @@ -73,44 +73,29 @@ class FetchExecuteWriteback(val parseContext: ParseContext) : ProcedurePass { is InvokeLabel -> { val lut = getDerefLut(dereferences, builder) SequenceLabel(lut.map { - StmtLabel( - Assign( - cast(it.value, it.value.type), - cast(it.key.map { it.replaceDerefs(lut) }, it.value.type) - ) - ) - } + InvokeLabel( - this.name, this.params.map { it.replaceDerefs(lut) }, metadata, - tempLookup - ), metadata - ) + StmtLabel(Assign(cast(it.value, it.value.type), + cast(it.key.map { it.replaceDerefs(lut) }, it.value.type))) + } + InvokeLabel(this.name, this.params.map { it.replaceDerefs(lut) }, metadata, + tempLookup), metadata) } is StartLabel -> { val lut = getDerefLut(dereferences, builder) SequenceLabel(lut.map { - StmtLabel( - Assign( - cast(it.value, it.value.type), - cast(it.key.map { it.replaceDerefs(lut) }, it.value.type) - ) - ) + StmtLabel(Assign(cast(it.value, it.value.type), + cast(it.key.map { it.replaceDerefs(lut) }, it.value.type))) } + StartLabel(name, params.map { it.replaceDerefs(lut) }, pidVar, metadata, tempLookup), metadata) } - is StmtLabel -> SequenceLabel( - stmt.replaceDerefs(builder).map { StmtLabel(it, choiceType, metadata) }, - metadata - ) + is StmtLabel -> SequenceLabel(stmt.replaceDerefs(builder).map { StmtLabel(it, choiceType, metadata) }, + metadata) else -> error("Not implemented for ${this.javaClass.simpleName}") } } else this - private fun getDerefLut( - dereferences: List>, - builder: XcfaProcedureBuilder - ) = dereferences.associateWith { + private fun getDerefLut(dereferences: List>, + builder: XcfaProcedureBuilder) = dereferences.associateWith { val tmpVar = Var("__THETA_heap_tmp_$cnt", it.type) builder.addVar(tmpVar) tmpVar @@ -133,24 +118,15 @@ class FetchExecuteWriteback(val parseContext: ParseContext) : ProcedurePass { val ret = ArrayList() val accessType = dereferencesWithAccessTypes.filter { dereferences.contains(it.first) } for (dereference in accessType.filter { it.second.isRead }.map { it.first }) { - ret.add( - Assign( - cast(lut[dereference]!!, dereference.type), - cast(dereference.map { it.replaceDerefs(lut.filter { it.key != dereference }) }, dereference.type) - ) - ) + ret.add(Assign(cast(lut[dereference]!!, dereference.type), + cast(dereference.map { it.replaceDerefs(lut.filter { it.key != dereference }) }, dereference.type))) } ret.add(stmt) for (dereference in accessType.filter { it.second.isWritten }.map { it.first }) { - ret.add( - MemoryAssign( - cast( - dereference.map { it.replaceDerefs(lut.filter { it.key != dereference }) }, - dereference.type - ) as Dereference<*, *, Type>, - cast(lut[dereference]!!, dereference.type).ref - ) - ) + ret.add(MemoryAssign( + cast(dereference.map { it.replaceDerefs(lut.filter { it.key != dereference }) }, + dereference.type) as Dereference<*, *, Type>, + cast(lut[dereference]!!, dereference.type).ref)) } return ret } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FinalLocationPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FinalLocationPass.kt index e586621cad..987722b622 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FinalLocationPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FinalLocationPass.kt @@ -31,23 +31,15 @@ class FinalLocationPass(private val checkOverflow: Boolean) : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { if (builder.finalLoc.isEmpty) builder.createFinalLoc() - builder.addEdge( - XcfaEdge( - it.source, builder.finalLoc.get(), SequenceLabel( - listOf( - StmtLabel(Stmts.Assume(BoolExprs.False()), metadata = it.metadata) - ), - metadata = it.metadata - ) - ) - ) + builder.addEdge(XcfaEdge(it.source, builder.finalLoc.get(), SequenceLabel( + listOf( + StmtLabel(Stmts.Assume(BoolExprs.False()), metadata = it.metadata)), + metadata = it.metadata))) } else { builder.addEdge(it) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FpFunctionsToExprsPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FpFunctionsToExprsPass.kt index 8cabaf35e0..8a05f0ef2b 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FpFunctionsToExprsPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/FpFunctionsToExprsPass.kt @@ -57,78 +57,44 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { } private val handlers: MutableMap> = LinkedHashMap() - private fun addHandler( - names: Array, - handler: BiFunction - ) { + private fun addHandler(names: Array, + handler: BiFunction) { for (name in names) { handlers[name] = handler } } init { - addHandler( - arrayOf( - "fabs", "fabsf", - "fabsl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("fabs", "fabsf", + "fabsl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFabs(builder, callStmt) } - addHandler( - arrayOf( - "floor", "floorf", - "floorl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("floor", "floorf", + "floorl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFloor(builder, callStmt) } - addHandler( - arrayOf( - "fmax", "fmaxf", - "fmaxl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("fmax", "fmaxf", + "fmaxl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFmax(builder, callStmt) } - addHandler( - arrayOf( - "fmin", "fminf", - "fminl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("fmin", "fminf", + "fminl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFmin(builder, callStmt) } - addHandler( - arrayOf( - "fmod", "fmodf", - "fmodl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("fmod", "fmodf", + "fmodl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFmod(builder, callStmt) } - addHandler( - arrayOf( - "sqrt", "sqrtf", - "sqrtl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("sqrt", "sqrtf", + "sqrtl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleSqrt(builder, callStmt) } - addHandler( - arrayOf( - "round", "roundf", - "roundl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("round", "roundf", + "roundl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleRound(builder, callStmt) } - addHandler( - arrayOf( - "isnan", "__isnan", "isnanf", "__isnanf", "isnanl", - "__isnanl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("isnan", "__isnan", "isnanf", "__isnanf", "isnanl", + "__isnanl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleIsnan(builder, callStmt) } addHandler(arrayOf("trunc")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> @@ -137,37 +103,22 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { addHandler(arrayOf("ceil")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleCeil(builder, callStmt) } - addHandler( - arrayOf( - "isnormal" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf( + "isnormal")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleIsnormal(builder, callStmt) } - addHandler( - arrayOf( - "isinf", "__isinf", "__isinff", "isinff", - "__isinfl", "isinfl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("isinf", "__isinf", "__isinff", "isinff", + "__isinfl", "isinfl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleIsinf(builder, callStmt) } - addHandler( - arrayOf( - "isfinite", "finite", "isfinitef", "finitef", "isfinite", "finitel", "__finite", "__finitef", - "__finitel", - "__isfinite", - "__isfinitef", "__isfinitel" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf( + "isfinite", "finite", "isfinitef", "finitef", "isfinite", "finitel", "__finite", "__finitef", "__finitel", + "__isfinite", + "__isfinitef", "__isfinitel")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleIsfinite(builder, callStmt) } - addHandler( - arrayOf( - "__fpclassify", "__fpclassifyf", - "__fpclassifyl" - ) - ) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> + addHandler(arrayOf("__fpclassify", "__fpclassifyf", + "__fpclassifyl")) { builder: XcfaProcedureBuilder, callStmt: InvokeLabel -> handleFpclassify(builder, callStmt) } } @@ -176,16 +127,10 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpRoundToIntegralExpr.of( - FpRoundingMode.RTZ, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpRoundToIntegralExpr.of(FpRoundingMode.RTZ, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -196,16 +141,10 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpRoundToIntegralExpr.of( - FpRoundingMode.RTP, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpRoundToIntegralExpr.of(FpRoundingMode.RTP, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -219,54 +158,38 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { val type = CSignedInt(null, parseContext) val assign: AssignStmt<*> = Stmts.Assign( TypeUtils.cast((expr as RefExpr<*>).decl as VarDecl<*>, type.smtType), - TypeUtils.cast( - AbstractExprs.Ite( - FpIsInfiniteExpr.of(callStmt.params[1] as Expr), - type.unitValue, type.nullValue - ), - type.smtType - ) - ) + TypeUtils.cast(AbstractExprs.Ite( + FpIsInfiniteExpr.of(callStmt.params[1] as Expr), + type.unitValue, type.nullValue), + type.smtType)) parseContext.metadata.create(assign.expr, "cType", type) return StmtLabel(assign, metadata = callStmt.metadata) } - private fun handleIsfinite( - builder: XcfaProcedureBuilder, - callStmt: InvokeLabel - ): XcfaLabel { + private fun handleIsfinite(builder: XcfaProcedureBuilder, + callStmt: InvokeLabel): XcfaLabel { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) val type = CSignedInt(null, parseContext) val assign: AssignStmt<*> = Stmts.Assign( TypeUtils.cast((expr as RefExpr<*>).decl as VarDecl<*>, type.smtType), - TypeUtils.cast( - AbstractExprs.Ite( - Or( - FpIsInfiniteExpr.of(callStmt.params[1] as Expr), - FpIsNanExpr.of(callStmt.params[1] as Expr) - ), - type.nullValue, type.unitValue - ), - type.smtType - ) - ) + TypeUtils.cast(AbstractExprs.Ite( + Or(FpIsInfiniteExpr.of(callStmt.params[1] as Expr), + FpIsNanExpr.of(callStmt.params[1] as Expr)), + type.nullValue, type.unitValue), + type.smtType)) parseContext.metadata.create(assign.expr, "cType", type) return StmtLabel(assign, metadata = callStmt.metadata) } - private fun handleIsnormal( - builder: XcfaProcedureBuilder, - callStmt: InvokeLabel - ): XcfaLabel { + private fun handleIsnormal(builder: XcfaProcedureBuilder, + callStmt: InvokeLabel): XcfaLabel { throw UnsupportedOperationException() } - private fun handleFpclassify( - builder: XcfaProcedureBuilder, - callStmt: InvokeLabel - ): XcfaLabel { + private fun handleFpclassify(builder: XcfaProcedureBuilder, + callStmt: InvokeLabel): XcfaLabel { throw UnsupportedOperationException() } @@ -281,10 +204,7 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { TypeUtils.cast( AbstractExprs.Ite( FpIsNanExpr.of(callStmt.params[1] as Expr), - type.unitValue, type.nullValue - ), type.smtType - ) - ) + type.unitValue, type.nullValue), type.smtType)) parseContext.metadata.create(assign.expr, "cType", type) return StmtLabel(assign, metadata = callStmt.metadata) } else { @@ -296,16 +216,10 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpRoundToIntegralExpr.of( - FpRoundingMode.RNA, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpRoundToIntegralExpr.of(FpRoundingMode.RNA, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -316,16 +230,10 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpSqrtExpr.of( - FpRoundingMode.RNE, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpSqrtExpr.of(FpRoundingMode.RNE, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -337,25 +245,15 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { } private fun handleFmin(builder: XcfaProcedureBuilder, callStmt: InvokeLabel): XcfaLabel { - Preconditions.checkState( - callStmt.params.size == 3, - "Function is presumed to be binary!" - ) + Preconditions.checkState(callStmt.params.size == 3, + "Function is presumed to be binary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpMinExpr.of( - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[2]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpMinExpr.of(TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[2]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -363,25 +261,15 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { } private fun handleFmax(builder: XcfaProcedureBuilder, callStmt: InvokeLabel): XcfaLabel { - Preconditions.checkState( - callStmt.params.size == 3, - "Function is presumed to be binary!" - ) + Preconditions.checkState(callStmt.params.size == 3, + "Function is presumed to be binary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpMaxExpr.of( - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[2]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpMaxExpr.of(TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[2]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -392,16 +280,10 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpRoundToIntegralExpr.of( - FpRoundingMode.RTN, - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpRoundToIntegralExpr.of(FpRoundingMode.RTN, + TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } @@ -412,15 +294,9 @@ class FpFunctionsToExprsPass(val parseContext: ParseContext) : ProcedurePass { Preconditions.checkState(callStmt.params.size == 2, "Function is presumed to be unary!") val expr = callStmt.params[0] Preconditions.checkState(expr is RefExpr<*>) - val assign = Stmts.Assign( - (expr as RefExpr<*>).decl as VarDecl, - FpAbsExpr.of( - TypeUtils.cast( - CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), - CComplexType.getType(expr, parseContext).smtType - ) as Expr - ) - ) + val assign = Stmts.Assign((expr as RefExpr<*>).decl as VarDecl, + FpAbsExpr.of(TypeUtils.cast(CComplexType.getType(expr, parseContext).castTo(callStmt.params[1]), + CComplexType.getType(expr, parseContext).smtType) as Expr)) if (parseContext.metadata.getMetadataValue(expr, "cType").isPresent) { parseContext.metadata.create(assign.expr, "cType", CComplexType.getType(expr, parseContext)) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/HavocPromotionAndRange.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/HavocPromotionAndRange.kt index b1fb46146a..7b0b3eccfa 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/HavocPromotionAndRange.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/HavocPromotionAndRange.kt @@ -75,8 +75,7 @@ class HavocPromotionAndRange(val parseContext: ParseContext) : ProcedurePass { // val type = CComplexType.getType(((edge.label.labels[index + 1] as StmtLabel).stmt as AssignStmt<*>).expr, parseContext) val havoc = Havoc(varDecl) newLabels.add( - StmtLabel(havoc, metadata = edge.label.labels[index].metadata) - ) + StmtLabel(havoc, metadata = edge.label.labels[index].metadata)) // newLabels.add(StmtLabel(type.limit(varDecl.ref))) } else if (index == indices[offset] + 1) { offset++ @@ -99,15 +98,11 @@ class HavocPromotionAndRange(val parseContext: ParseContext) : ProcedurePass { for ((index, value) in reversed) { val varDecl = ((value as StmtLabel).stmt as HavocStmt<*>).varDecl if (parseContext.metadata.getMetadataValue(varDecl.ref, "cType").isPresent) { - val type = CComplexType.getType( - varDecl.ref, - parseContext - ) // TODO: what to do when no info is available? + val type = CComplexType.getType(varDecl.ref, + parseContext) // TODO: what to do when no info is available? if (type !is CVoid) { - list.add( - index + 1, - StmtLabel(type.limit(varDecl.ref), metadata = value.metadata) - ) + list.add(index + 1, + StmtLabel(type.limit(varDecl.ref), metadata = value.metadata)) } } } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/InlineProceduresPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/InlineProceduresPass.kt index c4656380c5..48114fc020 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/InlineProceduresPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/InlineProceduresPass.kt @@ -63,34 +63,25 @@ class InlineProceduresPass(val parseContext: ParseContext) : ProcedurePass { procedure.getVars().forEach { builder.addVar(it) } procedure.getParams().forEach { builder.addVar(it.first) } procedure.getEdges().forEach { - builder.addEdge( - it.withSource(checkNotNull(newLocs[it.source])) - .withTarget(checkNotNull(newLocs[it.target])) - ) + builder.addEdge(it.withSource(checkNotNull(newLocs[it.source])) + .withTarget(checkNotNull(newLocs[it.target]))) } val inStmts: MutableList = ArrayList() val outStmts: MutableList = ArrayList() for ((i, param) in procedure.getParams().withIndex()) { if (param.second != ParamDirection.OUT) { - val stmt = AssignStmt.of( - cast(param.first, param.first.type), - cast( - CComplexType.getType(param.first.ref, parseContext) - .castTo(invokeLabel.params[i]), param.first.type - ) - ) + val stmt = AssignStmt.of(cast(param.first, param.first.type), + cast(CComplexType.getType(param.first.ref, parseContext) + .castTo(invokeLabel.params[i]), param.first.type)) inStmts.add(StmtLabel(stmt, metadata = invokeLabel.metadata)) } if (param.second != ParamDirection.IN) { val varDecl = (invokeLabel.params[i] as RefExpr<*>).decl as VarDecl<*> - val stmt = AssignStmt.of( - cast(varDecl, param.first.type), cast( - CComplexType.getType(varDecl.ref, parseContext).castTo(param.first.ref), - param.first.type - ) - ) + val stmt = AssignStmt.of(cast(varDecl, param.first.type), cast( + CComplexType.getType(varDecl.ref, parseContext).castTo(param.first.ref), + param.first.type)) outStmts.add(StmtLabel(stmt, metadata = invokeLabel.metadata)) } } @@ -101,20 +92,13 @@ class InlineProceduresPass(val parseContext: ParseContext) : ProcedurePass { builder.addEdge(XcfaEdge(source, checkNotNull(newLocs[initLoc]), SequenceLabel(inStmts))) if (finalLoc.isPresent) - builder.addEdge( - XcfaEdge( - checkNotNull(newLocs[finalLoc.get()]), target, - SequenceLabel(outStmts) - ) - ) + builder.addEdge(XcfaEdge(checkNotNull(newLocs[finalLoc.get()]), target, + SequenceLabel(outStmts))) if (errorLoc.isPresent) { if (builder.errorLoc.isEmpty) builder.createErrorLoc() builder.addEdge( - XcfaEdge( - checkNotNull(newLocs[errorLoc.get()]), builder.errorLoc.get(), - SequenceLabel(listOf()) - ) - ) + XcfaEdge(checkNotNull(newLocs[errorLoc.get()]), builder.errorLoc.get(), + SequenceLabel(listOf()))) } } else { builder.addEdge(e) diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LbePass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LbePass.kt index 8e37818330..bc745cfe67 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LbePass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/LbePass.kt @@ -145,10 +145,8 @@ class LbePass(val parseContext: ParseContext) : ProcedurePass { * @param strict If true, cascade collapsing is limited to locations in locationsToVisit. * @return Returns the list of removed locations. */ - private fun collapseParallelsAndSnakes( - locationsToVisit: List, - strict: Boolean - ): List { + private fun collapseParallelsAndSnakes(locationsToVisit: List, + strict: Boolean): List { val editedLocationsToVisit = locationsToVisit.toMutableList() val removedLocations = mutableListOf() while (editedLocationsToVisit.isNotEmpty()) { @@ -202,10 +200,8 @@ class LbePass(val parseContext: ParseContext) : ProcedurePass { * @param locationsToVisit Adds the targets of parallel edges to this list (new parallel edges and snakes * can appear in these locations) */ - private fun collapseParallelEdges( - location: XcfaLocation, - locationsToVisit: MutableList - ) { + private fun collapseParallelEdges(location: XcfaLocation, + locationsToVisit: MutableList) { val edgesByTarget = mutableMapOf>() for (edge in location.outgoingEdges) { val edgesToTarget = edgesByTarget.getOrDefault(edge.target, ArrayList()) @@ -239,10 +235,8 @@ class LbePass(val parseContext: ParseContext) : ProcedurePass { * added to this list * @param removedLocations The list of removed locations: the collapsed location is added to this list */ - private fun collapsePartOfSnake( - location: XcfaLocation, - locationsToVisit: MutableList, removedLocations: MutableList - ) { + private fun collapsePartOfSnake(location: XcfaLocation, + locationsToVisit: MutableList, removedLocations: MutableList) { if (location.incomingEdges.size == 1 && location.outgoingEdges.size == 1) { val previousLocation = location.incomingEdges.first().source val removed = removeMiddleLocation(location) diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/MallocFunctionPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/MallocFunctionPass.kt index 638bee932d..07a1b62bb9 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/MallocFunctionPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/MallocFunctionPass.kt @@ -45,9 +45,7 @@ class MallocFunctionPass(val parseContext: ParseContext) : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { @@ -56,21 +54,15 @@ class MallocFunctionPass(val parseContext: ParseContext) : ProcedurePass { val mallocVar = builder.parent.malloc if (builder.parent.getVars().none { it.wrappedVar == mallocVar }) { // initial creation builder.parent.addVar( - XcfaGlobalVar(mallocVar, CComplexType.getType(ret, parseContext).nullValue) - ) + XcfaGlobalVar(mallocVar, CComplexType.getType(ret, parseContext).nullValue)) val initProc = builder.parent.getInitProcedures().map { it.first } checkState(initProc.size == 1, "Multiple start procedure are not handled well") initProc.forEach { - val initAssign = StmtLabel( - Assign( - cast(mallocVar, mallocVar.type), - cast(CComplexType.getType(ret, parseContext).nullValue, mallocVar.type) - ) - ) + val initAssign = StmtLabel(Assign(cast(mallocVar, mallocVar.type), + cast(CComplexType.getType(ret, parseContext).nullValue, mallocVar.type))) val newEdges = it.initLoc.outgoingEdges.map { it.withLabel( - SequenceLabel(listOf(initAssign) + it.label.getFlatLabels(), it.label.metadata) - ) + SequenceLabel(listOf(initAssign) + it.label.getFlatLabels(), it.label.metadata)) } it.initLoc.outgoingEdges.forEach(it::removeEdge) newEdges.forEach(it::addEdge) @@ -78,24 +70,14 @@ class MallocFunctionPass(val parseContext: ParseContext) : ProcedurePass { } val assign1 = AssignStmt.of( cast(mallocVar, ret.type), - cast( - Add(mallocVar.ref, CComplexType.getType(ret, parseContext).getValue("3")), - ret.type - ) - ) + cast(Add(mallocVar.ref, CComplexType.getType(ret, parseContext).getValue("3")), + ret.type)) val assign2 = AssignStmt.of( - cast(ret.decl as VarDecl<*>, ret.type), cast(mallocVar.ref, ret.type) - ) - builder.addEdge( - XcfaEdge( - it.source, it.target, SequenceLabel( - listOf( - StmtLabel(assign1, metadata = invokeLabel.metadata), - StmtLabel(assign2, metadata = invokeLabel.metadata) - ) - ) - ) - ) + cast(ret.decl as VarDecl<*>, ret.type), cast(mallocVar.ref, ret.type)) + builder.addEdge(XcfaEdge(it.source, it.target, SequenceLabel( + listOf( + StmtLabel(assign1, metadata = invokeLabel.metadata), + StmtLabel(assign2, metadata = invokeLabel.metadata))))) } else { builder.addEdge(it) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NoSideEffectPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NoSideEffectPass.kt index cf88e7314b..ffcda3e8bb 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NoSideEffectPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NoSideEffectPass.kt @@ -30,9 +30,7 @@ class NoSideEffectPass(val parseContext: ParseContext) : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NondetFunctionPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NondetFunctionPass.kt index b5b4eb8faf..fd7dfcb847 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NondetFunctionPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NondetFunctionPass.kt @@ -32,23 +32,15 @@ class NondetFunctionPass : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { val invokeLabel = it.label.labels[0] as InvokeLabel val havoc = HavocStmt.of( - (invokeLabel.params[0] as RefExpr<*>).decl as VarDecl<*> - ) - builder.addEdge( - XcfaEdge( - it.source, it.target, SequenceLabel( - listOf(StmtLabel(havoc, metadata = invokeLabel.metadata)) - ) - ) - ) + (invokeLabel.params[0] as RefExpr<*>).decl as VarDecl<*>) + builder.addEdge(XcfaEdge(it.source, it.target, SequenceLabel( + listOf(StmtLabel(havoc, metadata = invokeLabel.metadata))))) } else { builder.addEdge(it) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NormalizePass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NormalizePass.kt index db22bd7169..418090364d 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NormalizePass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/NormalizePass.kt @@ -65,9 +65,7 @@ class NormalizePass : ProcedurePass { is NopLabel -> {} is StmtLabel -> if (!(label.stmt is AssumeStmt && label.stmt.cond.equals( - True() - )) - ) collector.forEach { it.add(label) } + True()))) collector.forEach { it.add(label) } else -> collector.forEach { it.add(label) } } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt index 836a01d635..02cb00683e 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ProcedurePassManager.kt @@ -78,28 +78,26 @@ class CPasses(checkOverflow: Boolean, parseContext: ParseContext, uniqueWarningL ) ) -class ChcPasses(parseContext: ParseContext, uniqueWarningLogger: Logger) : ProcedurePassManager( - listOf( - // formatting - NormalizePass(), - DeterministicPass(), - // removing redundant elements - EmptyEdgeRemovalPass(), - UnusedLocRemovalPass(), - // optimizing - SimplifyExprsPass(parseContext), - ), listOf( - // trying to inline procedures - InlineProceduresPass(parseContext), - RemoveDeadEnds(), - EliminateSelfLoops(), - // handling remaining function calls - LbePass(parseContext), - NormalizePass(), // needed after lbe, TODO - DeterministicPass(), // needed after lbe, TODO - // Final cleanup - UnusedVarPass(uniqueWarningLogger), - ) -) +class ChcPasses(parseContext: ParseContext, uniqueWarningLogger: Logger) : ProcedurePassManager(listOf( + // formatting + NormalizePass(), + DeterministicPass(), + // removing redundant elements + EmptyEdgeRemovalPass(), + UnusedLocRemovalPass(), + // optimizing + SimplifyExprsPass(parseContext), +), listOf( + // trying to inline procedures + InlineProceduresPass(parseContext), + RemoveDeadEnds(), + EliminateSelfLoops(), + // handling remaining function calls + LbePass(parseContext), + NormalizePass(), // needed after lbe, TODO + DeterministicPass(), // needed after lbe, TODO + // Final cleanup + UnusedVarPass(uniqueWarningLogger), +)) class LitmusPasses : ProcedurePassManager() \ No newline at end of file diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ReferenceElimination.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ReferenceElimination.kt index b216917361..e06e7ce39f 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ReferenceElimination.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/ReferenceElimination.kt @@ -60,12 +60,8 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { val lit = CComplexType.getType(varDecl.ref, parseContext).getValue("$cnt") builder.parent.addVar(XcfaGlobalVar(varDecl, lit)) parseContext.metadata.create(varDecl.ref, "cType", ptrType) - val assign = StmtLabel( - AssignStmt.of( - cast(varDecl, varDecl.type), - cast(lit, varDecl.type) - ) - ) + val assign = StmtLabel(AssignStmt.of(cast(varDecl, varDecl.type), + cast(lit, varDecl.type))) Pair(varDecl, assign) } } @@ -81,12 +77,8 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { val varDecl = Var(it.name + "*", ptrType.smtType) builder.addVar(varDecl) parseContext.metadata.create(varDecl.ref, "cType", ptrType) - val assign = StmtLabel( - AssignStmt.of( - cast(varDecl, varDecl.type), - cast(CComplexType.getType(varDecl.ref, parseContext).getValue("$cnt"), varDecl.type) - ) - ) + val assign = StmtLabel(AssignStmt.of(cast(varDecl, varDecl.type), + cast(CComplexType.getType(varDecl.ref, parseContext).getValue("$cnt"), varDecl.type))) Pair(varDecl, assign) } + globalReferredVars @@ -114,37 +106,25 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { } @JvmOverloads - fun XcfaLabel.changeReferredVars( - varLut: Map, Pair, StmtLabel>>, - parseContext: ParseContext? = null - ): XcfaLabel = + fun XcfaLabel.changeReferredVars(varLut: Map, Pair, StmtLabel>>, + parseContext: ParseContext? = null): XcfaLabel = if (varLut.isNotEmpty()) when (this) { - is InvokeLabel -> InvokeLabel( - name, params.map { it.changeReferredVars(varLut, parseContext) }, - metadata = metadata - ) - - is NondetLabel -> NondetLabel( - labels.map { it.changeReferredVars(varLut, parseContext) }.toSet(), - metadata = metadata - ) - - is SequenceLabel -> SequenceLabel( - labels.map { it.changeReferredVars(varLut, parseContext) }, - metadata = metadata - ) - - is StartLabel -> StartLabel( - name, params.map { it.changeReferredVars(varLut, parseContext) }, - pidVar, metadata = metadata - ) + is InvokeLabel -> InvokeLabel(name, params.map { it.changeReferredVars(varLut, parseContext) }, + metadata = metadata) + + is NondetLabel -> NondetLabel(labels.map { it.changeReferredVars(varLut, parseContext) }.toSet(), + metadata = metadata) + + is SequenceLabel -> SequenceLabel(labels.map { it.changeReferredVars(varLut, parseContext) }, + metadata = metadata) + + is StartLabel -> StartLabel(name, params.map { it.changeReferredVars(varLut, parseContext) }, + pidVar, metadata = metadata) is StmtLabel -> SequenceLabel(stmt.changeReferredVars(varLut, parseContext).map { - StmtLabel( - it, metadata = metadata, - choiceType = this.choiceType - ) + StmtLabel(it, metadata = metadata, + choiceType = this.choiceType) }).let { if (it.labels.size == 1) it.labels[0] else it } else -> this @@ -152,10 +132,8 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { else this @JvmOverloads - fun Stmt.changeReferredVars( - varLut: Map, Pair, StmtLabel>>, - parseContext: ParseContext? = null - ): List { + fun Stmt.changeReferredVars(varLut: Map, Pair, StmtLabel>>, + parseContext: ParseContext? = null): List { val stmts = when (this) { is AssignStmt<*> -> if (this.varDecl in varLut.keys) { val newVar = varLut[this.varDecl]!!.first @@ -164,31 +142,20 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { Dereference( cast(newVar.ref, newVar.type), cast(CComplexType.getSignedLong(parseContext).nullValue, newVar.type), - this.expr.type - ), - this.expr.changeReferredVars(varLut, parseContext) - ) - ) + this.expr.type), + this.expr.changeReferredVars(varLut, parseContext))) } else { - listOf( - AssignStmt.of( - cast(this.varDecl, this.varDecl.type), - cast(this.expr.changeReferredVars(varLut, parseContext), this.varDecl.type) - ) - ) + listOf(AssignStmt.of(cast(this.varDecl, this.varDecl.type), + cast(this.expr.changeReferredVars(varLut, parseContext), this.varDecl.type))) } is MemoryAssignStmt<*, *, *> -> listOf( - MemoryAssignStmt.create( - deref.changeReferredVars(varLut, parseContext) as Dereference<*, *, *>, - expr.changeReferredVars(varLut, parseContext) - ) - ) + MemoryAssignStmt.create(deref.changeReferredVars(varLut, parseContext) as Dereference<*, *, *>, + expr.changeReferredVars(varLut, parseContext))) is AssumeStmt -> listOf(AssumeStmt.of(cond.changeReferredVars(varLut, parseContext))) is SequenceStmt -> listOf( - SequenceStmt.of(this.stmts.flatMap { it.changeReferredVars(varLut, parseContext) }) - ) + SequenceStmt.of(this.stmts.flatMap { it.changeReferredVars(varLut, parseContext) })) is SkipStmt -> listOf(this) else -> TODO("Not yet implemented ($this)") @@ -203,10 +170,8 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { } @JvmOverloads - fun Expr.changeReferredVars( - varLut: Map, Pair, StmtLabel>>, - parseContext: ParseContext? = null - ): Expr = + fun Expr.changeReferredVars(varLut: Map, Pair, StmtLabel>>, + parseContext: ParseContext? = null): Expr = if (this is RefExpr) { (decl as VarDecl).changeReferredVars(varLut) } else if (this is Reference<*, *> && this.expr is RefExpr<*> && (this.expr as RefExpr<*>).decl in varLut.keys) { @@ -220,13 +185,10 @@ class ReferenceElimination(val parseContext: ParseContext) : ProcedurePass { } fun VarDecl.changeReferredVars( - varLut: Map, Pair, StmtLabel>> - ): Expr = + varLut: Map, Pair, StmtLabel>>): Expr = varLut[this]?.first?.let { - Dereference( - cast(it.ref, it.type), cast(CComplexType.getSignedInt(parseContext).nullValue, it.type), - this.type - ) as Expr + Dereference(cast(it.ref, it.type), cast(CComplexType.getSignedInt(parseContext).nullValue, it.type), + this.type) as Expr } ?: this.ref } \ No newline at end of file diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/SvCompIntrinsicsPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/SvCompIntrinsicsPass.kt index c92d5f08ee..46933ea4e9 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/SvCompIntrinsicsPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/SvCompIntrinsicsPass.kt @@ -40,8 +40,7 @@ class SvCompIntrinsicsPass : ProcedurePass { builder.addEdge(outgoingEdge.withLabel(SequenceLabel(labels))) } for (incomingEdge in ArrayList( - builder.finalLoc.getOrNull()?.incomingEdges ?: listOf() - )) { + builder.finalLoc.getOrNull()?.incomingEdges ?: listOf())) { builder.removeEdge(incomingEdge) val labels = ArrayList((incomingEdge.label as SequenceLabel).labels) labels.add(FenceLabel(setOf("ATOMIC_END"), metadata = incomingEdge.metadata)) @@ -51,24 +50,18 @@ class SvCompIntrinsicsPass : ProcedurePass { for (edge in ArrayList(builder.getEdges())) { val edges = edge.splitIf(this::predicate) if (edges.size > 1 || (edges.size == 1 && predicate( - (edges[0].label as SequenceLabel).labels[0] - )) - ) { + (edges[0].label as SequenceLabel).labels[0]))) { builder.removeEdge(edge) val labels: MutableList = ArrayList() edges.forEach { if (predicate((it.label as SequenceLabel).labels[0])) { val invokeLabel = it.label.labels[0] as InvokeLabel val fence = when (invokeLabel.name) { - "__VERIFIER_atomic_begin" -> FenceLabel( - setOf("ATOMIC_BEGIN"), - metadata = invokeLabel.metadata - ) + "__VERIFIER_atomic_begin" -> FenceLabel(setOf("ATOMIC_BEGIN"), + metadata = invokeLabel.metadata) - "__VERIFIER_atomic_end" -> FenceLabel( - setOf("ATOMIC_END"), - metadata = invokeLabel.metadata - ) + "__VERIFIER_atomic_end" -> FenceLabel(setOf("ATOMIC_END"), + metadata = invokeLabel.metadata) else -> invokeLabel } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/UnusedVarPass.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/UnusedVarPass.kt index c8ed0b0c27..1f88251fab 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/UnusedVarPass.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/UnusedVarPass.kt @@ -62,11 +62,9 @@ class UnusedVarPass(private val uniqueWarningLogger: Logger) : ProcedurePass { val allVars = Sets.union(builder.getVars(), builder.parent.getVars().map { it.wrappedVar }.toSet()) val varsAndParams = Sets.union(allVars, builder.getParams().map { it.first }.toSet()) if (!varsAndParams.containsAll(usedVars)) { - uniqueWarningLogger.write( - Logger.Level.INFO, + uniqueWarningLogger.write(Logger.Level.INFO, "WARNING: There are some used variables not present as declarations: " + - "${usedVars.filter { it !in varsAndParams }}\n" - ) + "${usedVars.filter { it !in varsAndParams }}\n") } builder.getVars().filter { it !in usedVars }.forEach { builder.removeVar(it) } diff --git a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/Utils.kt b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/Utils.kt index 55ae7e42e0..cb5c74b8cb 100644 --- a/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/Utils.kt +++ b/subprojects/xcfa/xcfa/src/main/java/hu/bme/mit/theta/xcfa/passes/Utils.kt @@ -76,41 +76,27 @@ fun Stmt.flatten(): List { fun XcfaLabel.changeVars(varLut: Map, VarDecl<*>>, parseContext: ParseContext? = null): XcfaLabel = if (varLut.isNotEmpty()) when (this) { - is InvokeLabel -> InvokeLabel( - name, params.map { it.changeVars(varLut, parseContext) }, - metadata = metadata - ) + is InvokeLabel -> InvokeLabel(name, params.map { it.changeVars(varLut, parseContext) }, + metadata = metadata) is JoinLabel -> JoinLabel(pidVar.changeVars(varLut), metadata = metadata) - is NondetLabel -> NondetLabel( - labels.map { it.changeVars(varLut, parseContext) }.toSet(), - metadata = metadata - ) - - is ReadLabel -> ReadLabel( - local.changeVars(varLut), global.changeVars(varLut), labels, - metadata = metadata - ) - - is SequenceLabel -> SequenceLabel( - labels.map { it.changeVars(varLut, parseContext) }, - metadata = metadata - ) - - is StartLabel -> StartLabel( - name, params.map { it.changeVars(varLut, parseContext) }, - pidVar.changeVars(varLut), metadata = metadata - ) - - is StmtLabel -> StmtLabel( - stmt.changeVars(varLut, parseContext), metadata = metadata, - choiceType = this.choiceType - ) - - is WriteLabel -> WriteLabel( - local.changeVars(varLut), global.changeVars(varLut), labels, - metadata = metadata - ) + is NondetLabel -> NondetLabel(labels.map { it.changeVars(varLut, parseContext) }.toSet(), + metadata = metadata) + + is ReadLabel -> ReadLabel(local.changeVars(varLut), global.changeVars(varLut), labels, + metadata = metadata) + + is SequenceLabel -> SequenceLabel(labels.map { it.changeVars(varLut, parseContext) }, + metadata = metadata) + + is StartLabel -> StartLabel(name, params.map { it.changeVars(varLut, parseContext) }, + pidVar.changeVars(varLut), metadata = metadata) + + is StmtLabel -> StmtLabel(stmt.changeVars(varLut, parseContext), metadata = metadata, + choiceType = this.choiceType) + + is WriteLabel -> WriteLabel(local.changeVars(varLut), global.changeVars(varLut), labels, + metadata = metadata) is ReturnLabel -> ReturnLabel(enclosedLabel.changeVars(varLut)) @@ -121,15 +107,11 @@ fun XcfaLabel.changeVars(varLut: Map, VarDecl<*>>, parseContext: Par @JvmOverloads fun Stmt.changeVars(varLut: Map, VarDecl<*>>, parseContext: ParseContext? = null): Stmt { val stmt = when (this) { - is AssignStmt<*> -> AssignStmt.of( - cast(varDecl.changeVars(varLut), varDecl.type), - cast(expr.changeVars(varLut, parseContext), varDecl.type) - ) - - is MemoryAssignStmt<*, *, *> -> MemoryAssignStmt.create( - deref.changeVars(varLut) as Dereference, - expr.changeVars(varLut) - ) + is AssignStmt<*> -> AssignStmt.of(cast(varDecl.changeVars(varLut), varDecl.type), + cast(expr.changeVars(varLut, parseContext), varDecl.type)) + + is MemoryAssignStmt<*, *, *> -> MemoryAssignStmt.create(deref.changeVars(varLut) as Dereference, + expr.changeVars(varLut)) is HavocStmt<*> -> HavocStmt.of(varDecl.changeVars(varLut)) is AssumeStmt -> AssumeStmt.of(cond.changeVars(varLut, parseContext)) diff --git a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/gson/GsonTest.kt b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/gson/GsonTest.kt index b7b48eb5a4..65a89e0533 100644 --- a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/gson/GsonTest.kt +++ b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/gson/GsonTest.kt @@ -46,15 +46,11 @@ class GsonTest { private fun getGson(scope: XcfaScope, env: Env, newScope: Boolean): Gson { val gsonBuilder = GsonBuilder() lateinit var gson: Gson - gsonBuilder.registerTypeHierarchyAdapter( - XcfaLocation::class.java, - StringTypeAdapter(xcfaLocationAdapter) - ) + gsonBuilder.registerTypeHierarchyAdapter(XcfaLocation::class.java, + StringTypeAdapter(xcfaLocationAdapter)) gsonBuilder.registerTypeHierarchyAdapter(XCFA::class.java, XcfaAdapter { gson }) - gsonBuilder.registerTypeHierarchyAdapter( - VarDecl::class.java, - VarDeclAdapter({ gson }, scope, env, !newScope) - ) + gsonBuilder.registerTypeHierarchyAdapter(VarDecl::class.java, + VarDeclAdapter({ gson }, scope, env, !newScope)) gsonBuilder.registerTypeHierarchyAdapter(Stmt::class.java, StringTypeAdapter { StatementWrapper(it, scope).instantiate(env) }) gsonBuilder.registerTypeHierarchyAdapter(Expr::class.java, @@ -63,10 +59,8 @@ class GsonTest { StringTypeAdapter { TypeWrapper(it).instantiate() }) gsonBuilder.registerTypeHierarchyAdapter(VarIndexing::class.java, StringTypeAdapter { BasicVarIndexing.fromString(it, scope, env) }) - gsonBuilder.registerTypeHierarchyAdapter( - XcfaLabel::class.java, - XcfaLabelAdapter(scope, env, { gson }) - ) + gsonBuilder.registerTypeHierarchyAdapter(XcfaLabel::class.java, + XcfaLabelAdapter(scope, env, { gson })) gsonBuilder.registerTypeHierarchyAdapter(MetaData::class.java, MetaDataAdapter()) gsonBuilder.registerTypeHierarchyAdapter(Pair::class.java, PairAdapter { gson }) gsonBuilder.registerTypeHierarchyAdapter(Optional::class.java, OptionalAdapter { gson }) @@ -118,10 +112,8 @@ class GsonTest { val env = Env() val gson = getGson(symbolTable, env, true) - assertEquals( - parseContext.metadata.lookupKeyValue, - gson.fromJson(gson.toJson(parseContext), ParseContext::class.java).metadata.lookupKeyValue - ) + assertEquals(parseContext.metadata.lookupKeyValue, + gson.fromJson(gson.toJson(parseContext), ParseContext::class.java).metadata.lookupKeyValue) } diff --git a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/PassTests.kt b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/PassTests.kt index e1084b1fab..570ab2b126 100644 --- a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/PassTests.kt +++ b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/PassTests.kt @@ -45,8 +45,7 @@ class PassTests { global: VarContext.() -> Unit, input: XcfaProcedureBuilderContext.() -> Unit, output: (XcfaProcedureBuilderContext.() -> Unit)?, - val passes: List - ) : Arguments { + val passes: List) : Arguments { private val builder = XcfaBuilder("").also { it.global(global) } private val inputBuilder = builder.procedure("", input).builder @@ -333,13 +332,11 @@ class PassTests { } (init to final) { "y".assign( - "(ite (isinfinite x) #b00000000000000000000000000000001 #b00000000000000000000000000000000)" - ) + "(ite (isinfinite x) #b00000000000000000000000000000001 #b00000000000000000000000000000000)") } (init to final) { "y".assign( - "(ite (or (isinfinite x) (fpisnan x)) #b00000000000000000000000000000000 #b00000000000000000000000000000001)" - ) + "(ite (or (isinfinite x) (fpisnan x)) #b00000000000000000000000000000000 #b00000000000000000000000000000001)") } }, ), @@ -375,8 +372,7 @@ class PassTests { "y".assign("x").also { parseContext.metadata.create( ((it.labels.last() as StmtLabel).stmt as AssignStmt<*>).varDecl.ref, "cType", - CSignedInt(null, parseContext) - ) + CSignedInt(null, parseContext)) } } }, @@ -535,10 +531,8 @@ class PassTests { @ParameterizedTest @MethodSource("getData") - fun testPass( - input: XcfaProcedureBuilder, output: XcfaProcedureBuilder?, - passes: List - ) { + fun testPass(input: XcfaProcedureBuilder, output: XcfaProcedureBuilder?, + passes: List) { println("Trying to run $passes on input...") val actualOutput = passes.fold(input) { acc, procedurePass -> procedurePass.run(acc) } .build(dummyXcfa) @@ -568,15 +562,10 @@ class PassTests { @Test fun testInline() { val xcfaSource = xcfa("example") { - procedure( - "main", ProcedurePassManager( - listOf( - NormalizePass(), - DeterministicPass(), - InlineProceduresPass(parseContext) - ) - ) - ) { + procedure("main", ProcedurePassManager(listOf( + NormalizePass(), + DeterministicPass(), + InlineProceduresPass(parseContext)))) { (init to final) { "proc1"() } diff --git a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/UtilsTest.kt b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/UtilsTest.kt index f2f25a473a..77c48dc44e 100644 --- a/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/UtilsTest.kt +++ b/subprojects/xcfa/xcfa/src/test/java/hu/bme/mit/theta/xcfa/passes/UtilsTest.kt @@ -39,37 +39,25 @@ class UtilsTest { @JvmStatic fun getLabels(): List = listOf( - Arguments.of( - InvokeLabel("", listOf(x.ref, y.ref), EmptyMetaData), - InvokeLabel("", listOf(xPrime.ref, y.ref), EmptyMetaData) - ), + Arguments.of(InvokeLabel("", listOf(x.ref, y.ref), EmptyMetaData), + InvokeLabel("", listOf(xPrime.ref, y.ref), EmptyMetaData)), Arguments.of(JoinLabel(x, EmptyMetaData), JoinLabel(xPrime, EmptyMetaData)), Arguments.of(NondetLabel(setOf(NopLabel), EmptyMetaData), NondetLabel(setOf(NopLabel), EmptyMetaData)), - Arguments.of( - SequenceLabel(listOf(NopLabel), EmptyMetaData), - SequenceLabel(listOf(NopLabel), EmptyMetaData) - ), + Arguments.of(SequenceLabel(listOf(NopLabel), EmptyMetaData), + SequenceLabel(listOf(NopLabel), EmptyMetaData)), Arguments.of(ReadLabel(x, y, setOf(), EmptyMetaData), ReadLabel(xPrime, y, setOf(), EmptyMetaData)), Arguments.of(WriteLabel(x, y, setOf(), EmptyMetaData), WriteLabel(xPrime, y, setOf(), EmptyMetaData)), Arguments.of(FenceLabel(setOf(), EmptyMetaData), FenceLabel(setOf(), EmptyMetaData)), - Arguments.of( - StartLabel("", listOf(x.ref), y, EmptyMetaData), - StartLabel("", listOf(xPrime.ref), y, EmptyMetaData) - ), + Arguments.of(StartLabel("", listOf(x.ref), y, EmptyMetaData), + StartLabel("", listOf(xPrime.ref), y, EmptyMetaData)), Arguments.of(ReturnLabel(JoinLabel(x, EmptyMetaData)), ReturnLabel(JoinLabel(xPrime, EmptyMetaData))), - Arguments.of( - StmtLabel(Assign(x, y.ref)), - StmtLabel(Assign(xPrime, y.ref)) - ), - Arguments.of( - StmtLabel(Havoc(x)), - StmtLabel(Havoc(xPrime)) - ), - Arguments.of( - StmtLabel(Assume(Eq(x.ref, y.ref))), - StmtLabel(Assume(Eq(xPrime.ref, y.ref))) - ), + Arguments.of(StmtLabel(Assign(x, y.ref)), + StmtLabel(Assign(xPrime, y.ref))), + Arguments.of(StmtLabel(Havoc(x)), + StmtLabel(Havoc(xPrime))), + Arguments.of(StmtLabel(Assume(Eq(x.ref, y.ref))), + StmtLabel(Assume(Eq(xPrime.ref, y.ref)))), Arguments.of(StmtLabel(Skip()), StmtLabel(Skip())), ) } diff --git a/subprojects/xcfa/xcfa2chc/src/test/java/hu/bme/mit/theta/xcfa2chc/TestChcUtils.kt b/subprojects/xcfa/xcfa2chc/src/test/java/hu/bme/mit/theta/xcfa2chc/TestChcUtils.kt index 63d339aeb7..487a206379 100644 --- a/subprojects/xcfa/xcfa2chc/src/test/java/hu/bme/mit/theta/xcfa2chc/TestChcUtils.kt +++ b/subprojects/xcfa/xcfa2chc/src/test/java/hu/bme/mit/theta/xcfa2chc/TestChcUtils.kt @@ -139,47 +139,27 @@ class TestChcUtils { val init = Relation("init", i2i, i2i, i2i, i2i, Int()) // br, co, rf, com - val T0 = Relation( - "T0", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0G = Relation( - "T0_gate", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0C = Relation( - "T0_critical", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0CF = Relation( - "T0_critical_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0F = Relation( - "T0_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - - val T1 = Relation( - "T1", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1G = Relation( - "T1_gate", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1C = Relation( - "T1_critical", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1CF = Relation( - "T1_critical_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1F = Relation( - "T1_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), - Int() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0 = Relation("T0", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0G = Relation("T0_gate", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0C = Relation("T0_critical", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0CF = Relation("T0_critical_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0F = Relation("T0_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + + val T1 = Relation("T1", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1G = Relation("T1_gate", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1C = Relation("T1_critical", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1CF = Relation("T1_critical_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1F = Relation("T1_final", i2i, i2i, i2i, i2i, Int(), Int(), Int(), Int(), + Int()) // br, co, rf, com, eid, turn, flag0, flag1, cnt val W = Relation("W", i2i, i2i, i2i, i2i, Int(), Int(), Int()) // br, co, rf, com, eid, vid, val @@ -460,39 +440,23 @@ class TestChcUtils { val init = Relation("init", i2i, i2i, i2i, i2i, Int()) // br, co, rf, com - val T0 = Relation( - "T0", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0G = Relation( - "T0_gate", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0C = Relation( - "T0_critical", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T0F = Relation( - "T0_final", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - - val T1 = Relation( - "T1", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1G = Relation( - "T1_gate", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1C = Relation( - "T1_critical", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt - val T1F = Relation( - "T1_final", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), - Bool() - ) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0 = Relation("T0", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0G = Relation("T0_gate", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0C = Relation("T0_critical", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T0F = Relation("T0_final", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + + val T1 = Relation("T1", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1G = Relation("T1_gate", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1C = Relation("T1_critical", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt + val T1F = Relation("T1_final", i2i, i2i, i2i, i2i, Int(), Bool(), Bool(), Bool(), + Bool()) // br, co, rf, com, eid, turn, flag0, flag1, cnt val W = Relation("W", i2i, i2i, i2i, i2i, Int(), Int(), Bool()) // br, co, rf, com, eid, vid, val diff --git a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsToRelations.kt b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsToRelations.kt index 8d733b0bfe..4e4a63908b 100644 --- a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsToRelations.kt +++ b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/XstsToRelations.kt @@ -55,8 +55,7 @@ fun XSTS.toRelations(): List { is EnumLitExpr -> { val value = enumValueLut.computeIfAbsent(this.type) { LinkedHashMap() }.computeIfAbsent( - this.value - ) { cnt++ } + this.value) { cnt++ } return IntLitExpr.of(BigInteger.valueOf(value.toLong())) } diff --git a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/RandomXsts.kt b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/RandomXsts.kt index 06eead3068..a78b5bb70c 100644 --- a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/RandomXsts.kt +++ b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/RandomXsts.kt @@ -29,10 +29,8 @@ import hu.bme.mit.theta.xsts.XSTS import kotlin.random.Random @JvmOverloads -fun generateXsts( - seed: Int, numCtrl: Int = 1, numClock: Int = 1, numOther: Int = 3, - requireAllVarsWritten: Boolean = false -): XSTS { +fun generateXsts(seed: Int, numCtrl: Int = 1, numClock: Int = 1, numOther: Int = 3, + requireAllVarsWritten: Boolean = false): XSTS { val writtenVars = object : StmtVisitor>, Set>> { override fun visit(stmt: SkipStmt?, param: Set>): Set> { return param @@ -79,8 +77,7 @@ fun generateXsts( } override fun visit( - stmt: MemoryAssignStmt?, param: Set>? - ): Set> { + stmt: MemoryAssignStmt?, param: Set>?): Set> { TODO("Not yet implemented") } @@ -181,21 +178,17 @@ class RandomXsts(seed: Int, val exprMaxDepth: Int) { } fun randomSeq(currDepth: Int, maxDepth: Int): Stmt { - return Stmts.SequenceStmt( - listOf( - randomIntermediate(currDepth + 1, maxDepth), - randomIntermediate(currDepth + 1, maxDepth) - ) - ) + return Stmts.SequenceStmt(listOf( + randomIntermediate(currDepth + 1, maxDepth), + randomIntermediate(currDepth + 1, maxDepth) + )) } fun randomNonDet(currDepth: Int, maxDepth: Int): Stmt { - return Stmts.NonDetStmt( - listOf( - randomIntermediate(currDepth + 1, maxDepth), - randomIntermediate(currDepth + 1, maxDepth) - ) - ) + return Stmts.NonDetStmt(listOf( + randomIntermediate(currDepth + 1, maxDepth), + randomIntermediate(currDepth + 1, maxDepth) + )) } @@ -203,8 +196,7 @@ class RandomXsts(seed: Int, val exprMaxDepth: Int) { var expr: Expr do expr = randomBoolExpr(0) while (ExprUtils.getVars(expr).isEmpty()) - return IfStmt.of( - expr, + return IfStmt.of(expr, randomIntermediate(currDepth + 1, maxDepth), randomIntermediate(currDepth + 1, maxDepth) ) @@ -230,8 +222,7 @@ class RandomXsts(seed: Int, val exprMaxDepth: Int) { { BoolExprs.Or( randomBoolExpr(currDepth + 1), - randomBoolExpr(currDepth + 1) - ) + randomBoolExpr(currDepth + 1)) }, { BoolExprs.Imply(randomBoolExpr(currDepth + 1), randomBoolExpr(currDepth + 1)) }, { BoolExprs.Iff(randomBoolExpr(currDepth + 1), randomBoolExpr(currDepth + 1)) }, @@ -305,8 +296,7 @@ class RandomXsts(seed: Int, val exprMaxDepth: Int) { } fun randomAssume() = (listOf(this::randomDataAssume) + (if (clockVars.isEmpty()) listOf() else listOf( - this::randomClockConstraint - ))).random(random)() + this::randomClockConstraint))).random(random)() fun randomDataAssume(): Stmt { var expr: Expr @@ -333,15 +323,13 @@ class RandomXsts(seed: Int, val exprMaxDepth: Int) { ).random()() val compareTo = IntExprs.Int(random.nextInt(10)) - return Stmts.Assume( - listOf( - { IntExprs.Leq(c, compareTo) }, - { IntExprs.Lt(c, compareTo) }, - { IntExprs.Geq(c, compareTo) }, - { IntExprs.Gt(c, compareTo) }, - { IntExprs.Eq(c, compareTo) }, - ).random(random)() - ) + return Stmts.Assume(listOf( + { IntExprs.Leq(c, compareTo) }, + { IntExprs.Lt(c, compareTo) }, + { IntExprs.Geq(c, compareTo) }, + { IntExprs.Gt(c, compareTo) }, + { IntExprs.Eq(c, compareTo) }, + ).random(random)()) } fun randomHavoc(): Stmt { diff --git a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/XstsSerializer.kt b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/XstsSerializer.kt index e3d98a6c68..833a03799a 100644 --- a/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/XstsSerializer.kt +++ b/subprojects/xsts/xsts-analysis/src/main/kotlin/hu/bme/mit/theta/xsts/analysis/util/XstsSerializer.kt @@ -100,8 +100,7 @@ object XstsSerializer : StmtVisitor { } override fun visit( - stmt: MemoryAssignStmt?, param: Void? - ): String { + stmt: MemoryAssignStmt?, param: Void?): String { TODO("Not yet implemented") } diff --git a/subprojects/xsts/xsts/src/main/kotlin/hu/bme/mit/theta/xsts/utils/XSTSVarChanger.kt b/subprojects/xsts/xsts/src/main/kotlin/hu/bme/mit/theta/xsts/utils/XSTSVarChanger.kt index 7c9fd82f2f..c38b044ec5 100644 --- a/subprojects/xsts/xsts/src/main/kotlin/hu/bme/mit/theta/xsts/utils/XSTSVarChanger.kt +++ b/subprojects/xsts/xsts/src/main/kotlin/hu/bme/mit/theta/xsts/utils/XSTSVarChanger.kt @@ -25,9 +25,7 @@ fun XSTS.copyWithReplacingVars(variableMapping: Map>): XSTS { val matchingCtrlVarNames = ctrlVars.filter { variableMapping.containsKey(it.name) }.map { it.name } val newCtrlVars = ctrlVars.filter { it.name !in variableMapping } .toSet() + variableMapping.filter { it.key in matchingCtrlVarNames }.values.toSet() - return XSTS( - newCtrlVars, init.changeVars(variableMapping) as NonDetStmt, + return XSTS(newCtrlVars, init.changeVars(variableMapping) as NonDetStmt, tran.changeVars(variableMapping) as NonDetStmt, env.changeVars(variableMapping) as NonDetStmt, - initFormula.changeVars(variableMapping), prop.changeVars(variableMapping) - ) + initFormula.changeVars(variableMapping), prop.changeVars(variableMapping)) } \ No newline at end of file From 348cbbe3449f7fcc3fc0262dfce14a6775e9ba43 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:23:16 +0200 Subject: [PATCH 05/10] Version bump --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7c35deef20..54816a6b4d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -89,4 +89,4 @@ tasks { username = System.getenv("OSSRH_USERNAME") password = System.getenv("OSSRH_PASSWORD") } -} \ No newline at end of file +} From 416f3b650cf25dd531d80e6d37abc64f5207ade9 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:27:33 +0200 Subject: [PATCH 06/10] Updated actions --- .github/actions/check-formatting/action.yml | 6 +- .github/workflows/reapply_copyright.yml | 77 --------------------- .github/workflows/reformat-code.yml | 9 +-- 3 files changed, 4 insertions(+), 88 deletions(-) delete mode 100644 .github/workflows/reapply_copyright.yml diff --git a/.github/actions/check-formatting/action.yml b/.github/actions/check-formatting/action.yml index 89ad28ffd8..72cf9f45cb 100644 --- a/.github/actions/check-formatting/action.yml +++ b/.github/actions/check-formatting/action.yml @@ -6,8 +6,6 @@ runs: - name: Checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: Check for formatting - uses: leventeBajczi/intellij-idea-format@v1.0 + uses: ./.github/actions/cache-build with: - settings-file: "./.idea/codeStyles/Project.xml" - file-mask: "*.java,*.kt" - additional-options: "-dry" \ No newline at end of file + arguments: spotlessCheck \ No newline at end of file diff --git a/.github/workflows/reapply_copyright.yml b/.github/workflows/reapply_copyright.yml deleted file mode 100644 index 3acc9e3876..0000000000 --- a/.github/workflows/reapply_copyright.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: Reapply Copyright - -on: - workflow_dispatch: - inputs: - file_mask: - description: 'File mask to reapply license header (argument to find)' - required: true - default: '-name "*.java" -o -name "*.kt" -o -name "*.kts"' - direct-commit: - type: boolean - default: false - description: Commit directly to source (instead of opening a PR) - -jobs: - copyright_checker: - runs-on: ubuntu-latest - steps: - - uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 - id: generate-token - with: - app_id: ${{ secrets.APP_ID }} - private_key: ${{ secrets.APP_PRIVATE_KEY }} - - - name: Checkout repository - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - with: - token: ${{ steps.generate-token.outputs.token }} - - - name: Run Copyright Checker - shell: bash {0} - run: | - set +x - - for file in $(find . -type f \( ${{ inputs.file_mask }} \)); do - last_modified_year=$(git log -1 --format=%ad --date=format:%Y "$file") - echo "Checking file $file, last modified $last_modified_year" - - header_exists=$(head -n 2 "$file" | tail -n 1 | grep -c "Budapest University of Technology") - - echo "Header exists for $file: $header_exists" - - if [[ $header_exists -eq 0 ]]; then - echo "Adding copyright header to $file" - cat ./doc/copyright-header.txt "$file" > tmp_026204264 - mv tmp_026204264 "$file" - fi - - header_year=$(head -n 2 "$file" | tail -n 1 | grep -o -E '[0-9]{4}') - - echo "Header year for $file: $header_year" - - if [[ "$header_year" != "$last_modified_year" ]]; then - echo "Updating copyright year to $last_modified_year in $file (was $header_year)" - sed -i "s/Copyright [0-9]\{4\}/Copyright $last_modified_year/g" "$file" - fi - done - - - name: Create Pull Request - if: ${{ !inputs.direct-commit }} - uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 - with: - commit-message: "Reapplied copyright" - branch: "copyright-reapply" - title: '[AutoPR] Reaplied copyright' - token: ${{ steps.generate-token.outputs.token }} - committer: ThetaBotMaintainer[bot] <139346997+ThetaBotMaintainer[bot]@users.noreply.github.com> - author: ThetaBotMaintainer[bot] <139346997+ThetaBotMaintainer[bot]@users.noreply.github.com> - - - name: Commit changes - if: ${{ inputs.direct-commit }} - uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a - with: - commit_message: "Reapplied copyright" - commit_user_name: ThetaBotMaintainer[bot] - commit_user_email: 139346997+ThetaBotMaintainer[bot]@users.noreply.github.com - commit_author: ThetaBotMaintainer[bot] <139346997+ThetaBotMaintainer[bot]@users.noreply.github.com> \ No newline at end of file diff --git a/.github/workflows/reformat-code.yml b/.github/workflows/reformat-code.yml index fe6fc24d9f..29411d1f37 100644 --- a/.github/workflows/reformat-code.yml +++ b/.github/workflows/reformat-code.yml @@ -3,10 +3,6 @@ name: Reformat code on: workflow_dispatch: inputs: - file_mask: - description: 'File mask to reformat' - required: true - default: '*.java,*.kts,*.kt' direct-commit: type: boolean default: false @@ -28,10 +24,9 @@ jobs: token: ${{ steps.generate-token.outputs.token }} - name: Do reformat - uses: leventeBajczi/intellij-idea-format@v1.0 + uses: ./.github/actions/cache-build with: - settings-file: "./.idea/codeStyles/Project.xml" - file-mask: ${{ inputs.file_mask }} + arguments: spotlessApply - name: Create Pull Request if: ${{ !inputs.direct-commit }} From 8e5a991f00114ef99307c93e541b69c8dd86ba9a Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:42:51 +0200 Subject: [PATCH 07/10] Added 'git fetch origin main' to ci Removed branch name --- .github/actions/cache-build/action.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/actions/cache-build/action.yml b/.github/actions/cache-build/action.yml index 277be1eb47..b1c7d0945d 100644 --- a/.github/actions/cache-build/action.yml +++ b/.github/actions/cache-build/action.yml @@ -6,13 +6,10 @@ inputs: runs: using: "composite" steps: -# - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 -# if: runner.os == 'Linux' -# id: cache -# with: -# path: . -# key: ${{ runner.os }}-${{github.sha}} - + - name: fetch + shell: bash + run: | + git fetch origin - name: build gradle uses: gradle/gradle-build-action@40b6781dcdec2762ad36556682ac74e31030cfe2 # v2.5.1 with: From 377355702d3e8f3264538a216f68ee836db59bd6 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:50:59 +0200 Subject: [PATCH 08/10] spotlessCheck not dependency of check --- buildSrc/src/main/kotlin/java-common.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/kotlin/java-common.gradle.kts b/buildSrc/src/main/kotlin/java-common.gradle.kts index 1eb2c30393..7f02a1bb67 100644 --- a/buildSrc/src/main/kotlin/java-common.gradle.kts +++ b/buildSrc/src/main/kotlin/java-common.gradle.kts @@ -69,6 +69,8 @@ tasks { spotless { ratchetFrom("origin/master") + + enforceCheck false val year = "\$YEAR" // you can't escape $ in raw strings.. val licenseHeader = """ /* From ac78c548952d0667f7e0f592e883b80188cd4973 Mon Sep 17 00:00:00 2001 From: Levente Bajczi Date: Sat, 19 Oct 2024 15:53:48 +0200 Subject: [PATCH 09/10] Syntax fix in gradle Syntax fix in gradle #2 --- buildSrc/src/main/kotlin/java-common.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/java-common.gradle.kts b/buildSrc/src/main/kotlin/java-common.gradle.kts index 7f02a1bb67..838b4d4f41 100644 --- a/buildSrc/src/main/kotlin/java-common.gradle.kts +++ b/buildSrc/src/main/kotlin/java-common.gradle.kts @@ -70,7 +70,7 @@ tasks { spotless { ratchetFrom("origin/master") - enforceCheck false + isEnforceCheck = false val year = "\$YEAR" // you can't escape $ in raw strings.. val licenseHeader = """ /* From 5323d7f84ebc4e7b359ac6801dcaa89d04f9f012 Mon Sep 17 00:00:00 2001 From: "ThetaBotMaintainer[bot]" <139346997+ThetaBotMaintainer[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:29:02 +0000 Subject: [PATCH 10/10] Version bump --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 54816a6b4d..4316bed633 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ buildscript { allprojects { group = "hu.bme.mit.theta" - version = "6.6.1" + version = "6.6.2" apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts")) }