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

ogma-core: Handle CoCoSpec's ZtoPre and YtoPre unary operators #86

Closed
ivanperez-keera opened this issue May 21, 2023 · 6 comments
Closed
Assignees
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Bug Admin only: Change request pertaining to error detected
Milestone

Comments

@ivanperez-keera
Copy link
Member

Description

Ogma cannot handle CoCoSpec boolean specifications containing the unary operators ZtoPre or YtoPre. This makes some of the specifications produced by FRET not parseable.

Type

  • Bug: FRET specification cannot be parsed or converted to Copilot monitor.

Additional context

None.

Requester

  • Ivan Perez

Method to check presence of bug

Compiling a specification with ZtoPre or YtoPre in the CoCoSpec property produces an error message instead of a correct Copilot specification:

{
  "test_componentSpec": {
    "Functions": [
    ],
    "Internal_variables": [
    ],
    "Other_variables": [
      {
        "name": "signal",
        "type": "bool"
      }
    ],
    "Requirements": [
      {
        "CoCoSpecCode": "ZtoPre(signal)",
        "fretish": "unimportant",
        "name": "testCopilot-001",
        "ptLTL": "signal"
      }
    ]
  }
}
$ ogma fret-component-spec --cocospec --fret-file-name fret-reqs-full.json 
fret-reqs-full.json: error: syntax error at line 1, column 7 before `('

Expected result

The execution above should produce a Copilot specification that translates ZtoPre to delay initialized to True. If modified to use YtoPre, the operator should be translated to a delay initialized to False.

Desired result

The execution above should produce a Copilot specification that translates ZtoPre to delay initialized to True. If modified to use YtoPre, the operator should be translated to a delay initialized to False.

Proposed solution

Modify CoCoSpec grammar to support ZtoPre and YtoPre.

Modify translator in ogma-core to perform the translation of ZtoPre to a delay initialized to True, and YtoPre to a delay initialized to False.

Further notes

None.

@ivanperez-keera ivanperez-keera added CR:Status:Initiated Admin only: Change request that has been initiated CR:Type:Bug Admin only: Change request pertaining to error detected labels May 21, 2023
@ivanperez-keera
Copy link
Member Author

Change Manager: Confirmed that the issue exists.

@ivanperez-keera ivanperez-keera added CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager and removed CR:Status:Initiated Admin only: Change request that has been initiated labels May 21, 2023
@ivanperez-keera
Copy link
Member Author

Technical Lead: Confirmed that the issue should be addressed.

@ivanperez-keera ivanperez-keera added CR:Status:Accepted Admin only: Change request accepted by technical lead and removed CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager labels May 21, 2023
@ivanperez-keera
Copy link
Member Author

Technical Lead: Issue scheduled for Ogma 1.(0+X).(8+Y).

Fix assigned to: @ivanperez-keera.

@ivanperez-keera ivanperez-keera added CR:Status:Scheduled Admin only: Change requested scheduled and removed CR:Status:Accepted Admin only: Change request accepted by technical lead labels May 21, 2023
@ivanperez-keera ivanperez-keera self-assigned this May 21, 2023
@ivanperez-keera ivanperez-keera added this to the Release 1.(0+X).(8+Y) milestone May 21, 2023
@ivanperez-keera ivanperez-keera added CR:Status:Implementation Admin only: Change request that is currently being implemented and removed CR:Status:Scheduled Admin only: Change requested scheduled labels May 21, 2023
ivanperez-keera added a commit that referenced this issue May 21, 2023
Ogma cannot handle CoCoSpec boolean specifications containing the unary
operators ZtoPre or YtoPre. This makes some of the specifications produced by
FRET not parseable.

This commit modifies the CoCoSpec grammar to include two new unary operators:
ZtoPre and YtoPre.
ivanperez-keera added a commit that referenced this issue May 21, 2023
Ogma cannot handle CoCoSpec boolean specifications containing the unary
operators ZtoPre or YtoPre. This makes some of the specifications produced by
FRET not parseable.

The CoCoSpec grammar has been extended with two new unary operators ZtoPre and
YtoPre.

This commit updates the translator from CoCoSpec to Copilot so that it assigns
a Copilot construct to those new unary operators. The component spec and
requirements db translators are updated to include the necessary Copilot
definitions so that the code produced compiles without errors.
@ivanperez-keera
Copy link
Member Author

Implementor: Solution implemented, review requested.

@ivanperez-keera ivanperez-keera added CR:Status:Verification Admin only: Change request that is currently being verified and removed CR:Status:Implementation Admin only: Change request that is currently being implemented labels May 21, 2023
@ivanperez-keera
Copy link
Member Author

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles passes the tests. Details:
      Docker image:

      FROM ubuntu:trusty
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy
      RUN apt-get install --yes git
      
      # We install the application first and then test it, in case any tests need to
      # run the tool.
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/$PAT**/ --enable-tests && \
          cabal v1-install $NAME/$PAT**/ --enable-tests --run-tests -j1

      Command:

      $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=6a1054f489edf4373831f8997c06d118db375d35" -it ogma-test
    • The solution proposed fixes the issues described. Details:
      The following Dockerfile runs the FRET to Copilot translators on the accompanying FRET component specification and FRET requirements DB, which contain ZtoPre and YtoPre in the CoCoSpec formulas.

      --- Dockerfile-verify-86
      FROM ubuntu:trusty
      
      ENV DEBIAN_FRONTEND=noninteractive
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy
      RUN cabal v1-install copilot-3.15
      RUN apt-get install --yes git
      
      ADD fret-reqs-db.json /tmp/fret-reqs-db.json
      ADD fret-reqs-cs.json /tmp/fret-reqs-cs.json
      
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install $NAME/$PAT**/ && \
          ogma fret-reqs-db --fret-file-name /tmp/fret-reqs-db.json --cocospec > DB.hs && \
          cabal v1-exec -- ghc --make DB.hs && \
          ogma fret-component-spec --fret-file-name /tmp/fret-reqs-cs.json --cocospec > CS.hs && \
          cabal v1-exec -- ghc --make CS.hs && \
          echo "Success"
      
      --- fret-reqs-cs.json
      {
        "test_componentSpec": {
          "Functions": [
          ],
          "Internal_variables": [
          ],
          "Other_variables": [
            {
              "name": "signal",
              "type": "bool"
            }
          ],
          "Requirements": [
            {
              "CoCoSpecCode": "ZtoPre(signal) and YtoPre(signal)",
              "fretish": "unimportant",
              "name": "testCopilot-001",
              "ptLTL": "TRUE"
            }
          ]
        }
      }
      
      --- fret-reqs-db.json
      [
          {
              "reqid": "test_req1",
              "parent_reqid": "",
              "project": "Test",
              "rationale": "",
              "fulltext": "",
              "semantics": {
                  "type": "test",
                  "ptExpanded": "TRUE",
                  "CoCoSpecCode": "ZtoPre(signal) and YtoPre(signal)"
              }
          }
      ]

      Command:

      $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=6a1054f489edf4373831f8997c06d118db375d35" -it ogma-verify-86
  • Implementation is documented. Details:
    No changes needed (Change is internal).
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No examples affected.
  • Required version bumps are evaluated. Details:
    No bump needed (internal change only).

@ivanperez-keera
Copy link
Member Author

Change Manager: Implementation ready to be merged.

@ivanperez-keera ivanperez-keera added CR:Status:Closed Admin only: Change request that has been completed and removed CR:Status:Verification Admin only: Change request that is currently being verified labels May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Bug Admin only: Change request pertaining to error detected
Projects
None yet
Development

No branches or pull requests

1 participant