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

BUG: Trouble with universal (forall) constraints #119

Open
andreas-zeller opened this issue Dec 10, 2024 · 3 comments
Open

BUG: Trouble with universal (forall) constraints #119

andreas-zeller opened this issue Dec 10, 2024 · 3 comments
Assignees
Labels
prio: high High priority issue scope: bug Something isn't working status: discussion Task requests further information

Comments

@andreas-zeller
Copy link
Collaborator

If I enter

$ fandango fuzz -f persons.fan -n 10 -c 'forall <lowercase_letter> in <first_name>: <lowercase_letter> == "a"'

I get a population of zero – Fandango cannot solve this.

The equivalent

$ fandango fuzz -f persons.fan -n 10 -c '<first_name>..<lowercase_letter> == "a"'

works, though.

@andreas-zeller andreas-zeller added scope: bug Something isn't working prio: high High priority issue labels Dec 10, 2024
@joszamama
Copy link
Collaborator

Hi Andreas!

This is a problem I really wanted to cover for a while. Let's take a look at your example:

forall <lowercase_letter> in <first_name>: <lowercase_letter> == "a"

The first nonterminal in the forall is a "tag" representation of the second nonterminal. In this case, <lowercase_letter> is not referring to a <lowercase_letter> child of <first_name>, but to <first_name> itself. So when you write <lowercase_letter> == "a", what you are really saying is that <first_name> == "a", and this cannot be parsed with the grammar persons.fan (<first_name> ::= <uppercase_letter><lowercase_letter>+;). That's why Fandango cannot find a solution.

The 'equivalent' way that you express in this issue, is not equivalent, since that is pointing to the actual children of <first_name>. The equivalent forall representation would be:

forall <foo> in <first_name>.<name>.<lowercase_letter>: <foo> == "a"

Now, I know what you are thinking, and yes, I do agree with you. I think the current way to represent foralls in Fandango is not intuitive, since, assuming a novice user perspective, I would expect that the first nonterminal of the forall refers to a child (direct/indirect) of the second nonterminal, as forall <child> in <parent>: ....

I will check this issue with Marius and come back to this issue.

@joszamama
Copy link
Collaborator

There also are all() and exists() functions in Python; maybe we can build on these? -- Andreas

@joszamama joszamama changed the title Trouble with universal (forall) constraints BUG: Trouble with universal (forall) constraints Dec 17, 2024
@andreas-zeller
Copy link
Collaborator Author

With #175 done, we'll get rid of quantification keywords anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio: high High priority issue scope: bug Something isn't working status: discussion Task requests further information
Projects
None yet
Development

No branches or pull requests

3 participants