use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.
the class WmmEncoder method encodeConsistency.
// Encodes all axioms. This should be called after <encodeRelations>
public BooleanFormula encodeConsistency(SolverContext ctx) {
checkInitialized();
logger.info("Encoding consistency");
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
BooleanFormula expr = bmgr.makeTrue();
for (Axiom ax : memoryModel.getAxioms()) {
expr = bmgr.and(expr, ax.consistent(ctx));
}
return expr;
}
use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.
the class WmmEncoder method encodeRelations.
// Initializes everything just like encodeAnarchicSemantics but also encodes all
// relations that are needed for the axioms (but does NOT encode the axioms themselves yet)
// NOTE: It avoids encoding relations that do NOT affect the axioms, i.e. unused relations
public BooleanFormula encodeRelations(SolverContext ctx) {
checkInitialized();
logger.info("Encoding relations");
BooleanFormulaManager bmgr = ctx.getFormulaManager().getBooleanFormulaManager();
BooleanFormula enc = encodeAnarchicSemantics(ctx);
for (Axiom ax : memoryModel.getAxioms()) {
enc = bmgr.and(enc, ax.getRelation().encode(ctx));
}
return enc;
}
use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.
the class RelationAnalysis method run.
private void run(VerificationTask task, Context context) {
// Init data context so that each relation is able to compute its may/must sets.
Wmm memoryModel = task.getMemoryModel();
for (Axiom ax : memoryModel.getAxioms()) {
ax.getRelation().updateRecursiveGroupId(ax.getRelation().getRecursiveGroupId());
}
for (RecursiveGroup recursiveGroup : memoryModel.getRecursiveGroups()) {
recursiveGroup.setDoRecurse();
}
// ------------------------------------------------
for (String relName : Wmm.BASE_RELATIONS) {
memoryModel.getRelationRepository().getRelation(relName).initializeRelationAnalysis(task, context);
}
for (Relation rel : memoryModel.getRelationRepository().getRelations()) {
rel.initializeRelationAnalysis(task, context);
}
for (Axiom ax : memoryModel.getAxioms()) {
ax.initializeRelationAnalysis(task, context);
}
// ------------------------------------------------
for (String relName : Wmm.BASE_RELATIONS) {
Relation baseRel = memoryModel.getRelationRepository().getRelation(relName);
baseRel.getMaxTupleSet();
baseRel.getMinTupleSet();
}
for (RecursiveGroup recursiveGroup : memoryModel.getRecursiveGroups()) {
recursiveGroup.initMaxTupleSets();
recursiveGroup.initMinTupleSets();
}
for (Axiom ax : memoryModel.getAxioms()) {
ax.getRelation().getMaxTupleSet();
ax.getRelation().getMinTupleSet();
}
}
use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.
the class SymmetryEncoder method sort.
private void sort(List<Tuple> row) {
if (!breakBySyncDegree) {
// ===== Natural order =====
row.sort(Comparator.naturalOrder());
return;
}
// ====== Sync-degree based order ======
// Setup of data structures
Set<Event> inEvents = new HashSet<>();
Set<Event> outEvents = new HashSet<>();
for (Tuple t : row) {
inEvents.add(t.getFirst());
outEvents.add(t.getSecond());
}
Map<Event, Integer> combInDegree = new HashMap<>(inEvents.size());
Map<Event, Integer> combOutDegree = new HashMap<>(outEvents.size());
List<Axiom> axioms = memoryModel.getAxioms();
for (Event e : inEvents) {
int syncDeg = axioms.stream().mapToInt(ax -> ax.getRelation().getMinTupleSet().getBySecond(e).size() + 1).max().orElse(0);
combInDegree.put(e, syncDeg);
}
for (Event e : outEvents) {
int syncDec = axioms.stream().mapToInt(ax -> ax.getRelation().getMinTupleSet().getByFirst(e).size() + 1).max().orElse(0);
combOutDegree.put(e, syncDec);
}
// Sort by sync degrees
row.sort(Comparator.<Tuple>comparingInt(t -> combInDegree.get(t.getFirst()) * combOutDegree.get(t.getSecond())).reversed());
}
use of com.dat3m.dartagnan.wmm.axiom.Axiom in project Dat3M by hernanponcedeleon.
the class ExecutionGraph method constructMappings.
// --------------------------------------------------
private void constructMappings(boolean createOnlyAxiomRelevantGraphs) {
Set<RelationGraph> graphs = new HashSet<>();
Set<Constraint> constraints = new HashSet<>();
for (Axiom axiom : verificationTask.getAxioms()) {
Constraint constraint = getOrCreateConstraintFromAxiom(axiom);
constraints.add(constraint);
}
if (!createOnlyAxiomRelevantGraphs) {
for (Relation rel : verificationTask.getRelationDependencyGraph().getNodeContents()) {
if (!EXCLUDED_RELS.contains(rel.getName())) {
RelationGraph graph = getOrCreateGraphFromRelation(rel);
graphs.add(graph);
}
}
}
caatModel = CAATModel.from(graphs, constraints);
}
Aggregations