Skip to content

Commit

Permalink
Free relations in CAT (#627)
Browse files Browse the repository at this point in the history
* - Add "free" relations to CAT

* - Centralized handling of the "enableMustSets" option.
- Fixed some bugs

* Added handling of Free relations to relation merging.

* Updated EmptyEventGraphTest
  • Loading branch information
ThomasHaas authored Feb 28, 2024
1 parent 6cc2789 commit 3c6c580
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 86 deletions.
2 changes: 2 additions & 0 deletions dartagnan/src/main/antlr4/Cat.g4
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ expression
| FENCEREL LPAR e = expression RPAR # exprFencerel
| LPAR e = expression RPAR # expr
| n = NAME # exprBasic
| call = NEW LPAR RPAR # exprNew
;

LET : 'let';
Expand Down Expand Up @@ -81,6 +82,7 @@ RBRAC : ']';
FENCEREL : 'fencerel';
DOMAIN : 'domain';
RANGE : 'range';
NEW : 'new';

FLAG : 'flag';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ public Void visitDefinition(Definition def) {
return null;
}

@Override
public Void visitFree(Free def) {
final Relation rel = def.getDefinedRelation();
EncodingContext.EdgeEncoder edge = context.edge(rel);
encodeSets.get(rel).apply((e1, e2) -> enc.add(bmgr.implication(edge.encode(e1, e2), execution(e1, e2))));
return null;
}

@Override
public Void visitUnion(Union union) {
final Relation rel = union.getDefinedRelation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public Object visitExpr(ExprContext ctx) {
return ctx.e.accept(this);
}

@Override
public Object visitExprNew(ExprNewContext ctx) {
return addDefinition(new Free(wmm.newRelation()));
}

@Override
public Object visitExprBasic(ExprBasicContext ctx) {
String name = ctx.n.getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ default T visitConstraint(Constraint constraint) {

// Base
default T visitUndefined(Definition.Undefined def) { return visitDefinition(def); }
default T visitFree(Free def) { return visitDefinition(def); }
default T visitEmpty(Empty def) { return visitDefinition(def); }
default T visitProgramOrder(ProgramOrder po) { return visitDefinition(po); }
default T visitExternal(External ext) { return visitDefinition(ext); }
Expand Down
Loading

0 comments on commit 3c6c580

Please sign in to comment.