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

fix mutually dependent aggregates semantics checks #2372

Merged
merged 2 commits into from
Jan 5, 2023

Conversation

quentin
Copy link
Member

@quentin quentin commented Dec 12, 2022

Hi,
I think this change fixes the semantics checks on mutually dependent aggregates.

The checker was looking for mutually dependent aggregates between pairs of aggregate only comparing (un)bound variables by name, even when they do not have the same parent clause.

For instance in this program, where rules (R1, R2) are independent from (R3, R4):

/// An aggregate with R1 & R2

.decl R1(i:number, j:number, h:number)
.input R1()

.decl R2(i:number, j:number, v:number)
R2(i, j, v) :-
  R1(i, j, _),
  v = count : { R1(x, j, h), i < x, h > 2 }.

.output R2()

/// An aggregate with R3 & R4

.decl R3(i:number, j:number, h:number)
.input R3()

.decl R4(i:number, j:number, v:number)
R4(i, j, v) :-
  R3(i, j, _),
  v = count : { R3(i, y, h), j < y, h > 2 }.

.output R4()

Would error out:

Error: Mutually dependent aggregate in file foo.dl at line 9
  v = count : { R1(x, j, h), i < x, h > 2 }.
------^--------------------------------------
Error: Mutually dependent aggregate in file foo.dl at line 21
  v = count : { R3(i, y, h), j < y, h > 2 }.
------^--------------------------------------

@quentin quentin marked this pull request as ready for review December 12, 2022 07:44
@codecov
Copy link

codecov bot commented Dec 12, 2022

Codecov Report

Merging #2372 (d6a7a54) into master (b311946) will decrease coverage by 0.01%.
The diff coverage is 92.45%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2372      +/-   ##
==========================================
- Coverage   77.52%   77.50%   -0.02%     
==========================================
  Files         466      467       +1     
  Lines       30690    30759      +69     
==========================================
+ Hits        23791    23840      +49     
- Misses       6899     6919      +20     
Impacted Files Coverage Δ
src/synthesiser/GenDb.h 93.75% <78.26%> (-6.25%) ⬇️
src/MainDriver.cpp 70.23% <92.81%> (ø)
src/ast/transform/SemanticChecker.cpp 97.04% <100.00%> (-0.01%) ⬇️
src/souffle.cpp 100.00% <100.00%> (ø)
src/synthesiser/GenDb.cpp 97.15% <100.00%> (+0.05%) ⬆️
...ouffle/datastructure/ConcurrentInsertOnlyHashMap.h 87.40% <0.00%> (-1.58%) ⬇️
src/include/souffle/utility/ParallelUtil.h 83.72% <0.00%> (-1.56%) ⬇️
src/reports/DebugReport.cpp 20.19% <0.00%> (-0.97%) ⬇️
src/ram/analysis/Index.cpp 89.71% <0.00%> (-0.59%) ⬇️
src/include/souffle/datastructure/BTree.h 97.91% <0.00%> (-0.42%) ⬇️
... and 3 more

Copy link
Collaborator

@XiaowenHu96 XiaowenHu96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@quentin quentin merged commit f8c028e into souffle-lang:master Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants