Commit 4b1bc2b0 authored by Andrei Paskevich's avatar Andrei Paskevich

reorganize examples/

- all programs with sessions are in examples/
- all programs without sessions are in examples/in_progress/
  (if you have private sessions for those, just move them there)
- all pure logical problems are in logic/
  (to simplify bench scripts and gallery building; they are few anyway)
- all OCaml programs are in examples/use_api/
- all strange stuff is in examples/misc/
  (most of it should probably go)
- Claude's solutions for Foveoos 2011 are in examples/foveoos11-cm/
  (why do we need two sets of solutions for quite simple problems?)
- hoare_logic, bitvectors, vacid_0_binary_heaps are in examples/

Bench scripts and documentation are updated.
Also, bench/bench is simplified a little bit.
parent 09da8804
......@@ -172,12 +172,12 @@ pvsbin/
/tests/test-and/
# /examples/
/examples/programs/course/
/examples/programs/wcet_hull/
/examples/programs/binary_search2/
/examples/programs/vacid_0_red_black_trees_harness/
/examples/programs/next_digit_sum/
/examples/programs/binary_search_c/
/examples/in_progress/course/
/examples/in_progress/wcet_hull/
/examples/in_progress/binary_search2/
/examples/in_progress/binary_search_c/
/examples/in_progress/next_digit_sum/
/examples/in_progress/vacid_0_red_black_trees_harness/
/examples/why3bench.html
/examples/why3regtests.err
/examples/why3regtests.out
......@@ -187,8 +187,8 @@ pvsbin/
/examples/*/*.tex
/examples/*/*/*.tex
/examples/*/*/*/*.tex
/examples/runstrat/makejob.opt
/examples/runstrat/runstrat.opt
/examples/use_api/runstrat/makejob.opt
/examples/use_api/runstrat/runstrat.opt
# modules
/modules/string/
......
......@@ -425,14 +425,14 @@ clean::
gallery::
@if test "$(GALLERYDIR)" = ""; then echo "set GALLERYDIR first"; exit 1; fi
@for x in `find examples/programs/ -name why3session.xml`; do \
@for x in examples/*/why3session.xml ; do \
d=`dirname $$x`; \
f=`basename $$d`; \
echo "exporting $$f"; \
mkdir -p $(GALLERYDIR)/$$f; \
cp examples/programs/$$f.mlw $(GALLERYDIR)/$$f/; \
cp examples/$$f.mlw $(GALLERYDIR)/$$f/; \
rm -f $(GALLERYDIR)/$$f/$$f.zip; \
cd examples/programs/; \
cd examples/; \
zip -r $(GALLERYDIR)/$$f/$$f.zip $$f.mlw $$f; \
cd ../..; \
done
......@@ -1130,28 +1130,28 @@ testl-ide: bin/why3ide.opt
testl-type: bin/why3.byte
ocamlrun -bt bin/why3.byte --type-only tests/test-pgm-jcf.mlw
test-api.byte: examples/use_api.ml lib/why3/why3.cma
test-api.byte: examples/use_api/use_api.ml lib/why3/why3.cma
$(if $(QUIET),@echo 'Ocaml $<' &&) \
ocaml -I lib/why3 $(INCLUDES) $(EXTCMA) lib/why3/why3.cma $< \
|| (printf "Test of Why API calls failed. Please fix it"; exit 2)
test-api.opt: examples/use_api.ml lib/why3/why3.cmxa
test-api.opt: examples/use_api/use_api.ml lib/why3/why3.cmxa
$(if $(QUIET),@echo 'Ocamlopt $<' &&) \
($(OCAMLOPT) -o $@ -I lib/why3 $(INCLUDES) $(EXTCMXA) lib/why3/why3.cmxa $< \
&& ./test-api.opt) \
|| (printf "Test of Why API calls failed. Please fix it"; exit 2)
@rm -f test-api.opt
test-shape: lib/why3/why3.cma
ocaml -I lib/why3 $(INCLUDES) $(EXTCMA) $? examples/test_shape.ml
#test-shape: lib/why3/why3.cma
# ocaml -I lib/why3 $(INCLUDES) $(EXTCMA) $? examples/test_shape.ml
test-session.byte: examples/create_session.ml lib/why3/why3.cma
test-session.byte: examples/use_api/create_session.ml lib/why3/why3.cma
$(if $(QUIET),@echo 'Ocaml $<' &&) \
ocaml -I lib/why3 $(INCLUDES) $(EXTCMA) lib/why3/why3.cma $< \
|| (printf "Test of Why API calls for Session module failed. Please fix it"; exit 2)
@rm -f why3session.xml
test-session.opt: examples/create_session.ml lib/why3/why3.cmxa
test-session.opt: examples/use_api/create_session.ml lib/why3/why3.cmxa
$(if $(QUIET),@echo 'Ocamlopt $<' &&) \
($(OCAMLOPT) -o $@ -I lib/why3 $(INCLUDES) $(EXTCMXA) lib/why3/why3.cmxa $< \
&& ./test-session.opt) \
......@@ -1162,12 +1162,12 @@ test-session.opt: examples/create_session.ml lib/why3/why3.cmxa
#only test the compilation of runstrat
test-runstrat.byte: lib/why3/why3.cma lib/why3/META
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/runstrat clean
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/runstrat byte
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/use_api/runstrat clean
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/use_api/runstrat byte
test-runstrat.opt: lib/why3/why3.cmxa lib/why3/META
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/runstrat clean
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/runstrat opt
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/use_api/runstrat clean
OCAMLPATH=$(PWD)/lib $(MAKE) -C examples/use_api/runstrat opt
test-runstrat: test-runstrat.$(OCAMLBEST)
......@@ -1393,16 +1393,16 @@ DISTRIB_FILES = Version Makefile.in configure.in configure \
lib/why3/META.in lib/why3/why3.ml \
doc/version.tex.in doc/manual.pdf \
drivers/*.drv drivers/*.gen \
examples/*.why examples/programs/*.mlw examples/tptp/*.why \
examples/*.mlw examples/logic/*.why \
examples/tests-provers/*.why examples/check-builtin/*.why \
examples/bts/*.why \
examples/programs/vacid_0_binary_heaps/*.why \
examples/programs/vacid_0_binary_heaps/*.mlw \
examples/vacid_0_binary_heaps/*.why \
examples/vacid_0_binary_heaps/*.mlw \
examples/bitvectors/*.why \
examples/foveoos2011/*.mlw \
examples/foveoos11-cm/*.mlw \
examples/*/*.xml examples/*/*/*.xml examples/*/*/*/*.xml \
examples/*/*.v examples/*/*/*.v examples/*/*/*/*.v\
examples/use_api.ml \
examples/use_api/*.ml \
theories/*.why \
modules/*.mlw \
lib/coq/*.v lib/coq/*/*.v lib/coq-tactic/*.v \
......@@ -1445,6 +1445,7 @@ $(DISTRIB_TAR): doc/manual.pdf
ln -s ../theories $(DISTRIB_DIR)/share/theories
cp --parents $(DISTRIB_FILES) $(DISTRIB_DIR)
rm -rf $(DISTRIB_DIR)/examples/hoare_logic
rm -rf $(DISTRIB_DIR)/examples/misc
cd $(DISTRIB_DIR); rm -f $(LIBGENERATED) \
$(COQPGENERATED) $(WHY3DOCGENERATED) $(PLUGGENERATED)
cd distrib; tar cf $(NAME).tar $(NAME); gzip -f --best $(NAME).tar
......
......@@ -5,103 +5,72 @@
# Useless in this script ?
# export WHY3LIB=lib
# export WHY3DATA=.
export WHY3LOADPATH=theories
# export WHY3LOADPATH=theories
pgm=$1
pgml=$1
pgml_options=
shopt -u failglob
goods () {
for f in $1/*.why; do
echo -n " "$f"... "
base=$1/`basename $f .why`
for f in $1/*.[wm][hl][yw] ; do
echo -n " $f... "
# running Why
if ! $pgm $2 $f > /dev/null 2>&1; then
echo "why FAILED"
echo "env: WHY3DATA='$WHY3DATA'"
echo "FAILED!"
# echo "env: WHY3DATA='$WHY3DATA'"
echo "invocation: $pgm $2 $f"
echo "result:"
$pgm $2 $f
exit 1
fi
echo "why ok... "
echo "ok"
done
}
bads () {
for f in $1/*.why; do
echo -n " "$f"... "
for f in $1/*.[wm][hl][yw] ; do
echo -n " $f... "
if $pgm $2 $f > /dev/null 2>&1; then
echo "$pgm $2 $f"
echo "FAILED!"
echo "SHOULD FAIL!"
# echo "env: WHY3DATA='$WHY3DATA'"
echo "invocation: $pgm $2 $f"
exit 1
else
echo "ok"
fi
echo "ok"
done
}
drivers () {
for f in $1/*.drv; do
if [ $f = "drivers/ocaml.drv" ]; then continue; fi
echo -n " "$f"... "
echo -n " $f... "
# running Why
if ! echo "theory Test goal G : 1=2 end" | $pgm -F why --driver $f - > /dev/null 2>&1; then
echo "why FAILED"
echo "theory Test goal G : 1=2 end" | $pgm -F why --driver $f -
exit 1
fi
echo "why ok... "
done
}
programs () {
for f in $1/*.mlw; do
echo -n " "$f"... "
if ! $pgml -L modules $pgml_options $f $2 > /dev/null 2>&1; then
echo
echo "$pgml $pgml_options $f $2"
$pgml -L modules $pgml_options $f $2
echo "FAILED!"
exit 1
else
echo "ok"
fi
done
}
bad_programs () {
for f in $1/*.mlw; do
echo -n " "$f"... "
if $pgml -L modules $pgml_options $f > /dev/null 2>&1; then
echo
echo "$pgml $pgml_options $f"
echo "SHOULD FAIL!"
exit 1
else
echo "ok"
fi
echo "ok"
done
}
valid_goals () {
for f in $1/*.mlw; do
echo -n " "$f"... "
if $pgml -L modules -t 10 -P alt-ergo $f | grep -q -v Valid; then
if $pgm -t 10 -P alt-ergo $f | grep -q -v Valid; then
echo "valid test $f failed!"
echo "$pgml -P alt-ergo $f"
$pgml -L modules -t 10 -P alt-ergo $f
echo "$pgm -P alt-ergo $f"
$pgm -t 10 -P alt-ergo $f
exit 1
else
echo "ok"
fi
fi
done
}
list_stuff () {
echo -n "$1 "
if $pgml $1 > /dev/null 2>&1; then
if $pgm $1 > /dev/null 2>&1; then
echo "ok"
else
echo "$pgm $1 FAIL"
......@@ -115,52 +84,63 @@ echo "=== Checking drivers ==="
drivers drivers
echo ""
echo "=== Parsing good files ==="
goods bench/typing/bad --parse-only
echo ""
#echo "=== Parsing good files ==="
#goods bench/typing/bad --parse-only
#goods bench/typing/good --parse-only
#goods examples/logic --parse-only
#goods examples/bitvectors "--parse-only -I examples/bitvectors"
#echo ""
echo "=== Type-checking bad files ==="
goods bench/typing/bad --parse-only
bads bench/typing/bad --type-only
echo ""
echo "=== Type-checking good files ==="
goods bench/typing/good --type-only
goods examples --type-only
goods examples/tptp --type-only
echo ""
echo "=== Type-checking theories ==="
goods theories --type-only
echo ""
echo "=== Parsing programs ==="
pgml_options=--parse-only
programs bench/programs/bad-typing
programs bench/programs/good
programs examples/programs
echo "=== Type-checking good files ==="
goods bench/typing/good --type-only
goods examples/logic --type-only
goods examples/bitvectors "--type-only -I examples/bitvectors"
echo ""
echo "=== Type-checking bad programs ==="
pgml_options=--type-only
bad_programs bench/programs/bad-typing
#echo "=== Parsing goods ==="
#goods bench/programs/bad-typing --parse-only
#goods bench/programs/good --parse-only
#goods examples --parse-only
#goods examples/in_progress --parse-only
#goods examples/foveoos11-cm --parse-only
#goods examples/hoare_logic --parse-only
#goods examples/vacid_0_binary_heaps "--parse-only -I examples/vacid_0_binary_heaps"
#echo ""
echo "=== Type-checking bad goods ==="
goods bench/programs/bad-typing --parse-only
bads bench/goods/bad-typing --type-only
echo ""
echo "=== Type-checking modules ==="
pgml_options=--type-only
programs modules
echo ""
echo "=== Type-checking good programs ==="
pgml_options=--type-only
programs bench/programs/good
programs examples/programs
goods modules --type-only
echo ""
echo "=== VC generation on good programs ==="
pgml_options=
programs bench/programs/good
programs examples/programs
programs examples/programs/vacid_0_binary_heaps "-I examples/programs/vacid_0_binary_heaps"
#echo "=== Type-checking good goods ==="
#goods bench/programs/good --type-only
#goods examples --type-only
#goods examples/in_progress --type-only
#goods examples/foveoos11-cm --type-only
#goods examples/hoare_logic --type-only
#goods examples/vacid_0_binary_heaps "--type-only -I examples/vacid_0_binary_heaps"
#echo ""
echo "=== VC generation on good goods ==="
goods bench/programs/good
goods examples
goods examples/in_progress
goods examples/foveoos11-cm
goods examples/hoare_logic
goods examples/vacid_0_binary_heaps "-I examples/vacid_0_binary_heaps"
echo ""
echo "=== Checking valid goals ==="
......
../../examples/programs/mccarthy.mlw
\ No newline at end of file
../../examples/mccarthy.mlw
\ No newline at end of file
......@@ -11,7 +11,7 @@ at URL~\url{http://why3.lri.fr/api/}.
We assume the reader has a fair knowledge of the OCaml
language. Notice that the \why library must be installed, see
Section~\ref{sec:installlib}. The OCaml code given below is available in
the source distribution as \url{examples/use_api.ml}.
the source distribution as \url{examples/use_api/use_api.ml}.
\section{Building Propositional Formulas}
......@@ -483,7 +483,7 @@ One can run provers on those tasks exactly as we did above.
\section{Proof sessions}
See the example \url{examples/create_session.ml} of the distribution for
See the example \url{examples/use_api/create_session.ml} of the distribution for
an illustration on how to manipulate proof sessions from an OCaml program.
......
......@@ -6,9 +6,9 @@
The first step in using \why is to write a suitable input
file. When one wants to learn a programming language, one starts by
writing a basic program. Here is our first \why file, which is the file
\texttt{examples/hello\_proof.why} of the distribution. It contains a
small set of goals.
\lstinputlisting[language=why3]{../examples/hello_proof.why}
\texttt{examples/logic/hello\_proof.why} of the distribution.
It contains a small set of goals.
\lstinputlisting[language=why3]{../examples/logic/hello_proof.why}
Any declaration must occur
inside a theory, which is in that example called HelloProof and
......
......@@ -47,30 +47,30 @@ run_dir () {
echo '</ul>' >> $HTML
}
echo "=== Logic ==="
run_dir .
echo "=== Tests Provers ==="
run_dir tests-provers
echo ""
echo "=== BTS ==="
run_dir bts
echo "=== Check Builtin translation ==="
run_dir check-builtin
echo ""
echo "=== Programs ==="
run_dir programs
echo "=== BTS ==="
run_dir bts
echo ""
echo "=== Programs in their own subdir ==="
run_dir programs/vacid_0_binary_heaps "-I programs/vacid_0_binary_heaps"
run_dir hoare_logic "-I hoare_logic"
echo "=== Logic ==="
run_dir logic
run_dir bitvectors "-I bitvectors"
echo ""
echo "=== Check Builtin translation ==="
run_dir check-builtin
echo "=== Programs ==="
run_dir .
run_dir foveoos11-cm
run_dir hoare_logic
run_dir vacid_0_binary_heaps "-I vacid_0_binary_heaps"
echo ""
echo '</body></html>' >> $HTML
echo "Summary: $success/$total"
exit $res