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

Handle CoCoSpec's ZtoPre and YtoPre unary operators. Refs #86. #87

Merged
merged 4 commits into from
May 21, 2023

Conversation

ivanperez-keera
Copy link
Member

Extend CoCoSpec grammar with and add translation to Copilot for unary operators ZtoPre and YtoPre, as prescribed in the solution proposed for #86.

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.
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

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 ivanperez-keera merged commit 8ba5f4e into develop May 21, 2023
@ivanperez-keera ivanperez-keera deleted the develop-cocospec-ytopre branch May 21, 2023 13:12
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.

1 participant