Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OC checker #264

Merged
merged 88 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
15fe63f
oc correctness validator initial commit
csanadtelbisz Apr 14, 2024
92f9798
Merge branch 'refs/heads/xcfa-oc' into xcfa-oc-validator
csanadtelbisz Apr 14, 2024
ac5ada9
validator random state of development
csanadtelbisz Apr 14, 2024
5860ee9
oc validator redundant scc approach to reachability
csanadtelbisz Apr 15, 2024
ef9d432
oc validator
csanadtelbisz Apr 15, 2024
a94e5c0
export and parse confict reasons, recursive reason validation
csanadtelbisz Apr 16, 2024
1de55f0
modified oc val config
csanadtelbisz Apr 17, 2024
ac6aab4
occhecker level conflict clause logging
csanadtelbisz Apr 17, 2024
0e0cfe6
Merge branch 'refs/heads/xcfa-oc' into xcfa-oc-validator
csanadtelbisz Apr 17, 2024
788c80b
merge
csanadtelbisz Apr 17, 2024
254c0e8
Merge branch 'refs/heads/xcfa-oc' into xcfa-oc-validator
csanadtelbisz Apr 17, 2024
c527c4d
oc validator join events
csanadtelbisz Apr 17, 2024
869b3da
Merge branch 'refs/heads/xcfa-oc' into xcfa-oc-validator
csanadtelbisz Apr 23, 2024
fd27d8d
po check fix
csanadtelbisz Apr 24, 2024
4c6d091
strict validator option
csanadtelbisz May 8, 2024
34e1c62
removed unnecessary logging
csanadtelbisz May 9, 2024
8c539be
small fix
csanadtelbisz May 10, 2024
373b05b
strict solver replaced
csanadtelbisz May 10, 2024
81983c2
further logging
csanadtelbisz May 10, 2024
55b0f6c
further logging
csanadtelbisz May 10, 2024
bf62922
retrieve memory events + refactor
csanadtelbisz Jun 12, 2024
8cdb183
same memory constraints, propagation
csanadtelbisz Jun 12, 2024
79b8fba
memory assignment fix
csanadtelbisz Jun 13, 2024
08cee39
pthread_exit
csanadtelbisz Jun 13, 2024
cb30768
pthread_exit not suppported within function call
csanadtelbisz Jun 13, 2024
8fe30ec
assume condition with derefvar fixed, derefvar removed
csanadtelbisz Jun 14, 2024
0f1e913
Merge branch 'master' into xcfa-oc
leventeBajczi Jun 15, 2024
2513bb6
code refactor
csanadtelbisz Aug 23, 2024
a922bba
Merge branch 'refs/heads/xcfa-oc' into xcfa-oc-validator
csanadtelbisz Aug 23, 2024
01ae416
merge xcfa-oc
csanadtelbisz Aug 23, 2024
0534cc4
merge xcfa-oc
csanadtelbisz Aug 23, 2024
2d65ce8
pre conflict finder
csanadtelbisz Sep 11, 2024
2466966
exact po in separate file
csanadtelbisz Sep 11, 2024
ab137c9
pre conflict finder v1
csanadtelbisz Sep 12, 2024
f43bf64
parse char definitions (e.g., char c = 'x';)
csanadtelbisz Sep 15, 2024
f7c5df2
rename to auto conflict
csanadtelbisz Sep 16, 2024
833acde
write interference fixed for memory assigns
csanadtelbisz Sep 17, 2024
1f0e706
write interference fixed for memory assigns
csanadtelbisz Sep 18, 2024
587d309
solver user propagatation fixed
csanadtelbisz Sep 20, 2024
9a29770
cleaning logs and unused code
csanadtelbisz Sep 23, 2024
ee241ca
reformat
csanadtelbisz Sep 25, 2024
327fce3
copyright
csanadtelbisz Sep 25, 2024
f69e2e0
Merge branch 'refs/heads/master' into xcfa-oc-validator
csanadtelbisz Sep 25, 2024
1e96e15
merge master issues resolved
csanadtelbisz Sep 25, 2024
9a73fa6
refactor, reformat
csanadtelbisz Sep 25, 2024
b649042
preventive propagation when interference is known
csanadtelbisz Sep 25, 2024
99555c1
oc checker minor fixes, logging
csanadtelbisz Oct 5, 2024
fe0387b
benchmark mod
csanadtelbisz Oct 6, 2024
90e3b45
z3 logging
csanadtelbisz Oct 6, 2024
6ab24e8
z3 logging fix
csanadtelbisz Oct 7, 2024
0188a95
auto conflict time logging
csanadtelbisz Oct 7, 2024
2a17f95
ws encoding if necessary
csanadtelbisz Oct 13, 2024
75210d6
oc logging
csanadtelbisz Oct 18, 2024
58b9204
Merge remote-tracking branch 'refs/remotes/origin/frontend-update-202…
csanadtelbisz Oct 18, 2024
d873017
accept unreliable safe config option
csanadtelbisz Oct 18, 2024
9b013e7
formatting
csanadtelbisz Oct 18, 2024
f98fe5a
Merge remote-tracking branch 'upstream/frontend-update-2024' into xcf…
csanadtelbisz Oct 18, 2024
da25084
Merge remote-tracking branch 'upstream/master' into xcfa-oc
csanadtelbisz Oct 19, 2024
f20c96d
version bump
csanadtelbisz Oct 19, 2024
4ba635b
procedure passes fix
csanadtelbisz Oct 19, 2024
8691d68
oc checker error messages
csanadtelbisz Oct 20, 2024
6226013
Merge branch 'master' into xcfa-oc
leventeBajczi Oct 21, 2024
2a346ce
Reformatted code
leventeBajczi Oct 21, 2024
b5246cb
Fixed imports
leventeBajczi Oct 21, 2024
a5b8641
Merge branch 'master' into xcfa-oc
leventeBajczi Oct 21, 2024
80b062b
uninitialized variable warning
csanadtelbisz Oct 21, 2024
bc6df54
Merge remote-tracking branch 'origin/xcfa-oc' into xcfa-oc
csanadtelbisz Oct 21, 2024
822b538
Merge remote-tracking branch 'upstream/fix-ref' into xcfa-oc
csanadtelbisz Oct 21, 2024
1d6c4e1
using unusedvar pass
csanadtelbisz Oct 22, 2024
45909fa
Merge remote-tracking branch 'upstream/fix-ref' into xcfa-oc
csanadtelbisz Oct 22, 2024
5a8ad9b
malloc var fix
csanadtelbisz Oct 24, 2024
26df5e7
pthread fixes and other improvements
csanadtelbisz Oct 25, 2024
ff6c51b
assign stmt util
csanadtelbisz Oct 29, 2024
4db2c85
reference elimination fix
csanadtelbisz Oct 29, 2024
84ecc05
exact po fix for same atomic block events
csanadtelbisz Oct 31, 2024
1050170
Merge remote-tracking branch 'upstream/master' into xcfa-oc
csanadtelbisz Oct 31, 2024
2d2ceba
resolving merge issues
csanadtelbisz Oct 31, 2024
92a2c36
unreliable safe flag fix
csanadtelbisz Nov 1, 2024
1329662
unreliable safe flag fix
csanadtelbisz Nov 1, 2024
789bb3d
ptrvar&mallocvar fix
csanadtelbisz Nov 1, 2024
172f9db
Reformatted
leventeBajczi Nov 3, 2024
f50fc4c
Merged master
leventeBajczi Nov 3, 2024
c5fc837
Removed unnecessary qualification
leventeBajczi Nov 4, 2024
19ff8fe
Added metadata where it was missing
leventeBajczi Nov 4, 2024
17327c4
Reformatted
leventeBajczi Nov 4, 2024
affcbbe
Amended tests
leventeBajczi Nov 4, 2024
8b388ff
Fixed horn problems
leventeBajczi Nov 4, 2024
e728553
Merge branch 'master' into xcfa-oc
leventeBajczi Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildscript {

allprojects {
group = "hu.bme.mit.theta"
version = "6.6.2"
version = "6.7.0"

apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,80 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package hu.bme.mit.theta.cfa.analysis

package hu.bme.mit.theta.cfa.analysis;

import com.google.common.base.Preconditions;
import com.google.common.base.Preconditions
import hu.bme.mit.theta.analysis.algorithm.bounded.MonolithicExpr
import hu.bme.mit.theta.analysis.expl.ExplState
import hu.bme.mit.theta.analysis.ptr.PtrState
import hu.bme.mit.theta.cfa.CFA;
import hu.bme.mit.theta.core.decl.Decls;
import hu.bme.mit.theta.core.model.ImmutableValuation
import hu.bme.mit.theta.cfa.CFA
import hu.bme.mit.theta.core.decl.Decls
import hu.bme.mit.theta.core.model.Valuation
import hu.bme.mit.theta.core.stmt.*
import hu.bme.mit.theta.core.type.booltype.BoolExprs.And
import hu.bme.mit.theta.core.type.inttype.IntExprs.*
import hu.bme.mit.theta.core.type.inttype.IntLitExpr
import hu.bme.mit.theta.core.utils.StmtUtils;
import hu.bme.mit.theta.core.utils.indexings.VarIndexingFactory;
import hu.bme.mit.theta.core.utils.StmtUtils
import hu.bme.mit.theta.core.utils.indexings.VarIndexingFactory
import java.util.*

fun CFA.toMonolithicExpr(): MonolithicExpr {
Preconditions.checkArgument(this.errorLoc.isPresent);
Preconditions.checkArgument(this.errorLoc.isPresent)

val map = mutableMapOf<CFA.Loc, Int>()
for ((i, x) in this.locs.withIndex()) {
map[x] = i;
}
val locVar = Decls.Var("__loc__", Int())
val tranList = this.edges.map { e ->
SequenceStmt.of(listOf(
val map = mutableMapOf<CFA.Loc, Int>()
for ((i, x) in this.locs.withIndex()) {
map[x] = i
}
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]!!))
))
}.toList()
val trans = NonDetStmt.of(tranList);
val transUnfold = StmtUtils.toExpr(trans, VarIndexingFactory.indexing(0));
val transExpr = And(transUnfold.exprs)
val initExpr = Eq(locVar.ref, Int(map[this.initLoc]!!))
val propExpr = Neq(locVar.ref, Int(map[this.errorLoc.orElseThrow()]!!))
AssignStmt.of(locVar, Int(map[e.target]!!)),
)
)
}
.toList()
val trans = NonDetStmt.of(tranList)
val transUnfold = StmtUtils.toExpr(trans, VarIndexingFactory.indexing(0))
val transExpr = And(transUnfold.exprs)
val initExpr = Eq(locVar.ref, Int(map[this.initLoc]!!))
val propExpr = Neq(locVar.ref, Int(map[this.errorLoc.orElseThrow()]!!))

val offsetIndex = transUnfold.indexing
val offsetIndex = transUnfold.indexing

return MonolithicExpr(initExpr, transExpr, propExpr, offsetIndex)
return MonolithicExpr(initExpr, transExpr, propExpr, offsetIndex)
}

fun CFA.valToAction(val1: Valuation, val2: Valuation): CfaAction {
val val1Map = val1.toMap()
val val2Map = val2.toMap()
var i = 0
val map: MutableMap<CFA.Loc, Int> = mutableMapOf()
for (x in this.locs) {
map[x] = i++
val val1Map = val1.toMap()
val val2Map = val2.toMap()
var i = 0
val map: MutableMap<CFA.Loc, Int> = mutableMapOf()
for (x in this.locs) {
map[x] = i++
}
return CfaAction.create(
this.edges.first { edge ->
map[edge.source] ==
(val1Map[val1Map.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt() &&
map[edge.target] ==
(val2Map[val2Map.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()
}
return CfaAction.create(
this.edges.first { edge ->
map[edge.source] == (val1Map[val1Map.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt() &&
map[edge.target] == (val2Map[val2Map.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()
})
)
}

fun CFA.valToState(val1: Valuation): CfaState<ExplState> {
val valMap = val1.toMap()
var i = 0
val map: MutableMap<Int, CFA.Loc> = mutableMapOf()
for (x in this.locs) {
map[i++] = x
}
return CfaState.of(
map[(valMap[valMap.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()],
ExplState.of(val1)
)
val valMap = val1.toMap()
var i = 0
val map: MutableMap<Int, CFA.Loc> = mutableMapOf()
for (x in this.locs) {
map[i++] = x
}
return CfaState.of(
map[(valMap[valMap.keys.first { it.name == "__loc_" }] as IntLitExpr).value.toInt()],
ExplState.of(val1),
)
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package hu.bme.mit.theta.analysis.algorithm.bounded

import hu.bme.mit.theta.analysis.expr.ExprAction
Expand All @@ -25,49 +24,85 @@ import hu.bme.mit.theta.solver.Solver

@JvmOverloads
fun <S : ExprState, A : ExprAction> buildBMC(
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
): BoundedChecker<S, A> {
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
fun <S : ExprState, A : ExprAction> buildKIND(
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
indSolver: Solver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
kindEnabled: (Int) -> Boolean = { true },
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
indSolver: Solver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
kindEnabled: (Int) -> Boolean = { true },
): BoundedChecker<S, A> {
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
fun <S : ExprState, A : ExprAction> buildIMC(
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
itpSolver: ItpSolver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
imcEnabled: (Int) -> Boolean = { true },
monolithicExpr: MonolithicExpr,
bmcSolver: Solver,
itpSolver: ItpSolver,
valToState: (Valuation) -> S,
biValToAction: (Valuation, Valuation) -> A,
logger: Logger,
shouldGiveUp: (Int) -> Boolean = { false },
bmcEnabled: () -> Boolean = { true },
lfPathOnly: () -> Boolean = { true },
imcEnabled: (Int) -> Boolean = { true },
): BoundedChecker<S, A> {
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,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package hu.bme.mit.theta.analysis.algorithm.chc

import hu.bme.mit.theta.analysis.Cex
Expand All @@ -34,54 +33,58 @@ data class Invariant(val lookup: Map<Relation, Expr<BoolType>>) : Witness

data class CexTree(val proofNode: ProofNode) : Cex {

override fun length(): Int = proofNode.depth()
override fun length(): Int = proofNode.depth()
}

/**
* A checker for CHC-based verification.
*/
/** A checker for CHC-based verification. */
class HornChecker(
private val relations: List<Relation>,
private val hornSolverFactory: SolverFactory,
private val logger: Logger,
private val relations: List<Relation>,
private val hornSolverFactory: SolverFactory,
private val logger: Logger,
) : SafetyChecker<Invariant, CexTree, UnitPrec> {

override fun check(prec: UnitPrec?): SafetyResult<Invariant, CexTree> {
val solver = hornSolverFactory.createHornSolver()
logger.write(Logger.Level.MAINSTEP, "Starting encoding\n")
solver.add(relations)
logger.write(Logger.Level.DETAIL, "Relations:\n\t${
override fun check(prec: UnitPrec?): SafetyResult<Invariant, CexTree> {
val solver = hornSolverFactory.createHornSolver()
logger.write(Logger.Level.MAINSTEP, "Starting encoding\n")
solver.add(relations)
logger.write(
Logger.Level.DETAIL,
"Relations:\n\t${
relations.joinToString("\n\t") {
it.constDecl.toString()
}
}\n")
logger.write(Logger.Level.DETAIL, "Rules:\n\t${
}\n",
)
logger.write(
Logger.Level.DETAIL,
"Rules:\n\t${
solver.assertions.joinToString("\n\t") {
it.toString().replace(Regex("[\r\n\t ]+"), " ")
}
}\n")
logger.write(Logger.Level.MAINSTEP, "Added constraints to solver\n")
solver.check()
logger.write(Logger.Level.MAINSTEP, "Check() finished (result: ${solver.status})\n")
return when (solver.status) {
SolverStatus.SAT -> {
logger.write(Logger.Level.MAINSTEP, "Proof (model) found\n")
val model = solver.model.toMap()
SafetyResult.safe(
Invariant(relations.associateWith { model[it.constDecl] as? Expr<BoolType> ?: True() }))
}
}\n",
)
logger.write(Logger.Level.MAINSTEP, "Added constraints to solver\n")
solver.check()
logger.write(Logger.Level.MAINSTEP, "Check() finished (result: ${solver.status})\n")
return when (solver.status) {
SolverStatus.SAT -> {
logger.write(Logger.Level.MAINSTEP, "Proof (model) found\n")
val model = solver.model.toMap()
SafetyResult.safe(
Invariant(relations.associateWith { model[it.constDecl] as? Expr<BoolType> ?: True() })
)
}

SolverStatus.UNSAT -> {
logger.write(Logger.Level.MAINSTEP, "Counterexample found\n")
val proof = solver.proof
SafetyResult.unsafe(CexTree(proof), Invariant(emptyMap()))
}
SolverStatus.UNSAT -> {
logger.write(Logger.Level.MAINSTEP, "Counterexample found\n")
val proof = solver.proof
SafetyResult.unsafe(CexTree(proof), Invariant(emptyMap()))
}

else -> {
logger.write(Logger.Level.MAINSTEP, "No solution found.\n")
SafetyResult.unknown()
}
}
else -> {
logger.write(Logger.Level.MAINSTEP, "No solution found.\n")
SafetyResult.unknown()
}
}

}
}
}
Loading
Loading