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

Using ENFORCE to populate I_Am doesn't work due to an incorrect expectation of relations starting with lower case #1519

Closed
RieksJ opened this issue Oct 22, 2024 · 8 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior component: compiler

Comments

@RieksJ
Copy link
Contributor

RieksJ commented Oct 22, 2024

I am using v4.7.7, and have the following script:

CONCEPT I_Am "Representation of the Actor that the system itself is"

CLASSIFY I_Am ISA Actor

RULE "There can only be one I_Am": V[I_Am] = I[I_Am]
POPULATION I_Am CONTAINS [ "I_Am" ] -- This is what I_Am

ENFORCE I[I_Am] := "I_Am"[I_Am]

I_Am is to be similar to ONE, i.e., there can only be one I_Am, but there also must be at least one I_Am, which is the atom I_Am.

To cater for that, I want to use the ENFORCE statement - see the above script.
This produces the error

C:\Git\Ampersand\Demos\siam-demo\project\SIAM_Who_I_Am.adl:11:9 error:
  unexpected keyword "I"
  expecting lower case identifier

I would have expected that I (and V for that matter)would be acceptable forENFORCE`.

@RieksJ RieksJ added bug Indicates an unexpected problem or unintended behavior component: compiler labels Oct 22, 2024
@hanjoosten
Copy link
Member

There are two issues here

  • unfortunately ENFORCE currently is only implemented for the case where the expression on the left hand side is a binded relation. I agree that it would make sense to also allow l[Some Concept]
  • your rule wouldn't work like you intend. If the population of I_am is empty, what tuple would denote the violation?

@hanjoosten
Copy link
Member

Implementing ENFORCE I |- <expr> (Or one of the other two operators) has to do with the discussion in #851

@RieksJ
Copy link
Contributor Author

RieksJ commented Oct 22, 2024

it is not ENFORCE ... |-... but ENFORCE ... :=... which goes both ways. so the violation is the other way (-|)

@hanjoosten
Copy link
Member

These are indeed the other two operators. But that is beside the point.

@hanjoosten
Copy link
Member

There are 3 operators: :=, :< and >:. We aren't talking about these operators, but on what is allowed at the left hand side of it. Currently, that may only be a user defined relation. The idea of the ENFORCE statement is that the population of whatever is at the left hand side is being manipulated automatically, based on the expression on the right hand side and the operator that is used.
It makes sense to also allow I[SomeConcept]. It does not make sense to allow V[SomeConcept*SomeOtherConcept]. Implementing I is what the first bullet above is about.

The second bullet still remains, with or without the implementation of the first bullet.

@RieksJ
Copy link
Contributor Author

RieksJ commented Oct 23, 2024

My earlier comment was about the second bullet, where you asked "If the population of I_am is empty, what tuple would denote the violation?". I understand ENFORCE I[I_Am] := "I_Am"[I_Am] to:

  1. check I[I_Am] -| "I_Am"[I_Am], so that it can depopulate I[I_Am] if the right hand side population does not have stuff that I[I_Am] has (which are the violations), and
  2. I[I_Am] |- "I_Am"[I_Am], so that it can populate I[I_Am] if the right hand side population has stuff that is not in I[I_Am] (which are the violations).

The violation you are asking for would then be ("I_Am","I_Am"), which is a violation of I[I_Am] -| "I_Am"[I_Am]

@hanjoosten
Copy link
Member

hanjoosten commented Oct 23, 2024

An atom used in a rule doesn't automatically translate to an atom in the database. See the 'Sinterklaas' issue for the discussion why. Besides that, even if atom would be element of the initial population of the concept, nothing would prevent anyone to delete it later on. That would be valid, because there is no rule that says it cannot be deleted.

@hanjoosten
Copy link
Member

I created #1520 for allowing I . The rest of your issue was explained in the opening and closing again of #166 .
I guess that resolves this issue. @RieksJ , if you disagree, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior component: compiler
Projects
None yet
Development

No branches or pull requests

2 participants