-
Notifications
You must be signed in to change notification settings - Fork 58
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
copilot-theorem
: kind2Prover
gives parse error when disproving a property
#495
Comments
The following --- Dockerfile
FROM ubuntu:focal
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 \
libtool-bin libz-dev libzmq5 opam z3
# Install Kind2's OCaml dependencies
RUN opam init --auto-setup --yes --bare --disable-sandboxing \
&& opam switch create default 4.01.0 \
&& opam install -y -j "$(nproc)" camlp4 menhir \
&& opam clean -a -c -s --logs
# Install Kind2-0.7.2
ENV KIND2_VER="0.7.2"
RUN wget https://github.com/kind2-mc/kind2/archive/refs/tags/v${KIND2_VER}.zip \
&& unzip v${KIND2_VER}.zip
WORKDIR kind2-${KIND2_VER}
RUN sed -i.bak -e 's/-pedantic -Werror -Wall/-pedantic -Wall/' ocamlczmq/czmq/configure.ac
RUN eval $(opam env) \
&& ./autogen.sh \
&& ./build.sh \
&& make install
WORKDIR /
# Install GHC and Cabal
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 apt-get install --yes git
ADD Spec.hs /tmp/Spec.hs
SHELL ["/bin/bash", "-c"]
CMD git clone $REPO && cd $NAME && git checkout $COMMIT && cd .. \
&& cabal v1-install alex happy \
&& cabal v1-install $NAME/copilot**/ \
&& (cabal v1-exec -- runhaskell /tmp/Spec.hs | grep "false: proof failed") \
&& echo "Success"
--- Spec.hs
module Main (main) where
import Data.Functor
import Copilot.Theorem.Kind2
import Copilot.Theorem.Prove
import Language.Copilot
spec :: Spec
spec =
void $ theorem "false" (forAll false) (check (kind2Prover def))
main :: IO ()
main = void $ reify spec Run the Dockerfile like so:
This fails as of commit f823901:
|
Thank you, @RyanGlScott . |
Description
Type
Additional context None. Requester
Method to check presence of bug Attempting to run the following spec with kind2-0.7.2: module Main (main) where
import Data.Functor
import Copilot.Theorem.Kind2
import Copilot.Theorem.Prove
import Language.Copilot
spec :: Spec
spec =
void $ theorem "false" (forAll false) (check (kind2Prover def))
main :: IO ()
main = void $ reify spec leads to a crash due to a parse error:
Expected result Running the spec above should complete correctly, and produce an output that contains the text "false: proof failed", since the property we are attempting to prove is falsifiable. Desired result Running the spec above should complete correctly, and produce an output that contains the text "false: proof failed", since the property we are attempting to prove is falsifiable. Proposed solution Modify Further notes None. |
Change Manager: Confirmed that the bug exists. |
Technical Lead: Confirmed that the issue should be addressed. |
Technical Lead: Issue scheduled for fixing in Copilot 3.20. Fix assigned to: @RyanGlScott . |
…Language#495. Currently, the TransSys code that `copilot-theorem`'s Kind2 backend generates is only accepted by Kind-0.7.2. This patch makes this version requirement more obvious in the `copilot-theorem` `README`.
…-Language#495. In Kind2-0.7.2, disproven properties are tagged with `falsifiable` in the XML output, but the code in `copilot-theorem`'s Kind2 backend was instead searching for a tag named `invalid`. As a result, `copilot-theorem` would error when attempting to disprove properties that are false, as it fail to parse the XML output. This fixes the issue by replacing `invalid` with `falsifiable`.
Implementor: Solution implemented, review requested. |
In the past, we sometimes involved George Hagan with Kind2 issues. He
created Kind and is still in touch with the Iowa guys.
…On Wed, Apr 24, 2024 at 1:14 PM Ryan Scott ***@***.***> wrote:
Implementor: Solution implemented, review requested.
—
Reply to this email directly, view it on GitHub
<#495 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAONILT3MZWEAEDGVNOZRCDY67R7ZAVCNFSM6AAAAABBYKG5OKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZVGQ2DSNBTGM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Alwyn E. Goodloe, Ph.D.
***@***.***
Research Computer Engineer
NASA Langley Research Center
|
…-Language#495. In Kind2, disproven properties are tagged with `falsifiable` in the XML output, but the code in `copilot-theorem`'s Kind2 backend was instead searching for a tag named `invalid`. As a result, `copilot-theorem` would error when attempting to disprove properties that are false, as it fail to parse the XML output. This fixes the issue by replacing `invalid` with `falsifiable`.
Change Manager: Verified that:
|
Change Manager: Implementation ready to be merged. |
(In order to reproduce this bug, you'll need to install Kind2-0.7.2, which is (as far as I can tell) the latest version of Kind2 that
copilot-theorem
currently supports. Note that Kind2-0.7.2 doesn't offer binary distributions, so you'll have to build it from source.)copilot-theorem
'skind2Prover
is able to prove properties that are true. For instance, running this program:Will yield:
On the other hand, if
kind2Prover
attempts to disprove a property that is false, then it will crash with a parse error. This can be seen when running this program:The problem lies in this code:
copilot/copilot-theorem/src/Copilot/Theorem/Kind2/Output.hs
Lines 19 to 24 in 835deaf
This expects Kind2's XML output to have an
<Answer>...</Answer>
tag whose content is the stringinvalid
. As can be seen in the XML output that is dumped in the error message above, however, the actual content of the<Answer>
tag isfalsifiable
.Resolving this issue would be helpful in an eventual resolution for #254. In order to check an existentially quantified property with Kind2, it would be convenient to take a universally quantified property and negate it, checking if Kind2 returns
falsifiable
as the answer. This won't be possible unless we first fix this issue.The text was updated successfully, but these errors were encountered: