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

Erroneous "variable only occurs once" warning, depends on clause order #1923

Closed
langston-barrett opened this issue May 3, 2021 · 3 comments

Comments

@langston-barrett
Copy link
Contributor

On this file:

.decl bar(?aCtx: symbol, ?alloc: symbol)
.decl foo()
foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
  ( ?a1 != ?a2
  ; ?c1 != ?c2
  ).
foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
  ( ?c1 != ?c2
  ; ?a1 != ?a2
  ).

Souffle prints these warnings:

Warning: No rules/facts defined for relation bar in file test.dl at line 1
.decl bar(?aCtx: symbol, ?alloc: symbol)
------^----------------------------------
Warning: Variable ?c1 only occurs once in file test.dl at line 4
  bar(?c1, ?a1),
------^----------
Warning: Variable ?c2 only occurs once in file test.dl at line 5
  bar(?c2, ?a2),
------^----------
Warning: Variable ?a1 only occurs once in file test.dl at line 10
  bar(?c1, ?a1),
-----------^-----
Warning: Variable ?a2 only occurs once in file test.dl at line 11
  bar(?c2, ?a2),
-----------^-----

Note that for the first rule for foo, only variables c1 and c2 are mentioned, and for the second rule, only a1 and a2` are mentioned, despite all variables appearing the same number of times in both rules. I wouldn't expect to see this warning at all, given that each variable appears more than once.

Version:

Souffle: 78c2bfc(32bit Domains)
Copyright (c) 2016-19 The Souffle Developers.
Copyright (c) 2013-16 Oracle and/or its affiliates.
@b-scholz
Copy link
Member

b-scholz commented May 4, 2021

That is a problem with how Souffle is processing disjunctions. It expands the program rules to the following rules:

foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
  ?a1 != ?a2.
foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
 ?c1 != ?c2.
foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
  ?c1 != ?c2.
foo() :-
  bar(?c1, ?a1),
  bar(?c2, ?a2),
  ?a1 != ?a2.

You can check with --show=transformed-datalog. This transformation is done in the ParserTransformer (way before the AST pipeline with its semantic checker).

Only if disjunctions (hopefully someday) become part of the AST we can suppress these error messages.

@b-scholz
Copy link
Member

b-scholz commented May 4, 2021

This is related to issue #1289 and #1409.

@quentin
Copy link
Member

quentin commented Jun 20, 2024

These warnings won't appear anymore since #2415

@quentin quentin closed this as completed Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants