aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.merlin2
-rw-r--r--.travis.yml8
-rw-r--r--CHANGES1
-rw-r--r--INSTALL14
-rw-r--r--Makefile3
-rw-r--r--Makefile.ci3
-rw-r--r--README.md11
-rw-r--r--TODO53
-rw-r--r--checker/checker.ml4
-rw-r--r--checker/closure.ml16
-rw-r--r--checker/declarations.ml13
-rw-r--r--checker/include2
-rw-r--r--checker/inductive.ml9
-rw-r--r--checker/subtyping.ml2
-rw-r--r--checker/term.ml4
-rw-r--r--checker/typeops.ml7
-rw-r--r--checker/univ.ml7
-rw-r--r--configure.ml31
-rw-r--r--dev/ci/ci-basic-overlay.sh13
-rwxr-xr-xdev/ci/ci-bedrock-facade.sh10
-rwxr-xr-xdev/ci/ci-bedrock-src.sh10
-rwxr-xr-xdev/ci/ci-fiat-crypto.sh2
-rw-r--r--dev/ci/ci-user-overlay.sh6
-rw-r--r--dev/doc/changes.txt46
-rw-r--r--dev/doc/cic.dtd2
-rw-r--r--dev/doc/econstr.md129
-rw-r--r--dev/doc/xml-protocol.md745
-rw-r--r--dev/top_printers.ml2
-rw-r--r--doc/RecTutorial/coqartmacros.tex2
-rw-r--r--doc/common/macros.tex3
-rw-r--r--doc/refman/RefMan-cic.tex12
-rw-r--r--doc/refman/RefMan-ext.tex24
-rw-r--r--doc/refman/RefMan-pre.tex2
-rw-r--r--doc/refman/RefMan-tac.tex34
-rw-r--r--doc/refman/RefMan-tus.tex18
-rw-r--r--engine/eConstr.ml1
-rw-r--r--engine/eConstr.mli1
-rw-r--r--engine/evarutil.ml3
-rw-r--r--engine/evd.ml6
-rw-r--r--engine/proofview.ml18
-rw-r--r--engine/proofview.mli1
-rw-r--r--engine/termops.ml25
-rw-r--r--engine/universes.ml3
-rw-r--r--engine/universes.mli2
-rw-r--r--grammar/argextend.mlp8
-rw-r--r--grammar/tacextend.mlp10
-rw-r--r--grammar/vernacextend.mlp8
-rw-r--r--ide/coq.ml6
-rw-r--r--ide/coq.mli2
-rw-r--r--ide/coqOps.ml78
-rw-r--r--ide/coqide.ml10
-rw-r--r--ide/coqide_ui.ml285
-rw-r--r--ide/ide_slave.ml87
-rw-r--r--ide/ideutils.ml13
-rw-r--r--ide/interface.mli6
-rw-r--r--ide/preferences.ml22
-rw-r--r--ide/session.ml14
-rw-r--r--ide/texmacspp.ml3
-rw-r--r--ide/wg_Command.ml19
-rw-r--r--ide/wg_Command.mli2
-rw-r--r--ide/wg_Completion.ml26
-rw-r--r--ide/wg_Detachable.ml4
-rw-r--r--ide/wg_Find.ml6
-rw-r--r--ide/wg_Notebook.ml2
-rw-r--r--ide/wg_ProofView.ml41
-rw-r--r--ide/wg_ScriptView.ml12
-rw-r--r--ide/wg_Segment.ml6
-rw-r--r--ide/xmlprotocol.ml10
-rw-r--r--interp/constrexpr_ops.ml88
-rw-r--r--interp/constrexpr_ops.mli12
-rw-r--r--interp/constrextern.ml16
-rw-r--r--interp/constrintern.ml8
-rw-r--r--interp/constrintern.mli1
-rw-r--r--interp/coqlib.mli2
-rw-r--r--interp/notation.ml1
-rw-r--r--interp/notation_ops.ml4
-rw-r--r--interp/stdarg.ml2
-rw-r--r--interp/stdarg.mli1
-rw-r--r--interp/syntax_def.ml2
-rw-r--r--interp/topconstr.ml11
-rw-r--r--intf/constrexpr.mli2
-rw-r--r--intf/misctypes.mli4
-rw-r--r--intf/tactypes.mli1
-rw-r--r--intf/vernacexpr.mli9
-rw-r--r--kernel/constr.ml33
-rw-r--r--kernel/constr.mli2
-rw-r--r--kernel/context.mli10
-rw-r--r--kernel/declarations.mli2
-rw-r--r--kernel/names.ml21
-rw-r--r--kernel/nativecode.ml19
-rw-r--r--kernel/nativeconv.ml2
-rw-r--r--kernel/nativelambda.ml90
-rw-r--r--kernel/nativevalues.ml3
-rw-r--r--kernel/pre_env.ml18
-rw-r--r--kernel/reduction.ml29
-rw-r--r--kernel/subtyping.ml2
-rw-r--r--kernel/term.ml2
-rw-r--r--kernel/term.mli2
-rw-r--r--kernel/term_typing.ml2
-rw-r--r--kernel/typeops.ml4
-rw-r--r--kernel/uGraph.mli3
-rw-r--r--kernel/univ.ml4
-rw-r--r--kernel/vars.ml2
-rw-r--r--kernel/vars.mli4
-rw-r--r--lib/backtrace.ml1
-rw-r--r--lib/cErrors.ml2
-rw-r--r--lib/cWarnings.ml4
-rw-r--r--lib/feedback.ml12
-rw-r--r--lib/feedback.mli23
-rw-r--r--lib/flags.ml25
-rw-r--r--lib/flags.mli38
-rw-r--r--lib/stateid.ml1
-rw-r--r--library/declare.ml5
-rw-r--r--library/goptions.ml1
-rw-r--r--library/libobject.ml1
-rw-r--r--library/loadpath.ml2
-rw-r--r--parsing/cLexer.ml431
-rw-r--r--parsing/egramcoq.ml5
-rw-r--r--parsing/egramcoq.mli8
-rw-r--r--parsing/g_constr.ml416
-rw-r--r--parsing/g_prim.ml41
-rw-r--r--parsing/g_proofs.ml41
-rw-r--r--parsing/g_vernac.ml458
-rw-r--r--parsing/pcoq.ml8
-rw-r--r--plugins/cc/cctac.ml138
-rw-r--r--plugins/cc/cctac.mli3
-rw-r--r--plugins/extraction/extract_env.ml2
-rw-r--r--plugins/firstorder/formula.ml106
-rw-r--r--plugins/firstorder/formula.mli13
-rw-r--r--plugins/firstorder/g_ground.ml440
-rw-r--r--plugins/firstorder/ground.ml38
-rw-r--r--plugins/firstorder/ground.mli4
-rw-r--r--plugins/firstorder/instances.ml114
-rw-r--r--plugins/firstorder/instances.mli4
-rw-r--r--plugins/firstorder/rules.ml171
-rw-r--r--plugins/firstorder/rules.mli4
-rw-r--r--plugins/firstorder/sequent.ml62
-rw-r--r--plugins/firstorder/sequent.mli32
-rw-r--r--plugins/firstorder/unify.ml58
-rw-r--r--plugins/firstorder/unify.mli7
-rw-r--r--plugins/fourier/fourierR.ml4
-rw-r--r--plugins/funind/functional_principles_proofs.ml24
-rw-r--r--plugins/funind/functional_principles_proofs.mli3
-rw-r--r--plugins/funind/g_indfun.ml41
-rw-r--r--plugins/funind/indfun.ml6
-rw-r--r--plugins/funind/indfun_common.ml15
-rw-r--r--plugins/funind/indfun_common.mli5
-rw-r--r--plugins/funind/invfun.ml11
-rw-r--r--plugins/funind/merge.ml1
-rw-r--r--plugins/funind/recdef.ml23
-rw-r--r--plugins/funind/recdef.mli2
-rw-r--r--plugins/ltac/evar_tactics.ml1
-rw-r--r--plugins/ltac/extratactics.ml43
-rw-r--r--plugins/ltac/g_auto.ml41
-rw-r--r--plugins/ltac/g_class.ml45
-rw-r--r--plugins/ltac/g_ltac.ml42
-rw-r--r--plugins/ltac/g_rewrite.ml414
-rw-r--r--plugins/ltac/pltac.ml1
-rw-r--r--plugins/ltac/pptactic.ml4
-rw-r--r--plugins/ltac/profile_ltac.ml3
-rw-r--r--plugins/ltac/rewrite.ml9
-rw-r--r--plugins/ltac/rewrite.mli1
-rw-r--r--plugins/ltac/taccoerce.mli1
-rw-r--r--plugins/ltac/tacentries.ml6
-rw-r--r--plugins/ltac/tacenv.mli1
-rw-r--r--plugins/ltac/tacintern.ml6
-rw-r--r--plugins/ltac/tacinterp.ml7
-rw-r--r--plugins/ltac/tacinterp.mli1
-rw-r--r--plugins/ltac/tactic_debug.ml8
-rw-r--r--plugins/ltac/tactic_debug.mli1
-rw-r--r--plugins/ltac/tauto.ml3
-rw-r--r--plugins/micromega/coq_micromega.ml58
-rw-r--r--plugins/micromega/mfourier.ml12
-rw-r--r--plugins/micromega/sos.ml270
-rw-r--r--plugins/micromega/sos_lib.ml4
-rw-r--r--plugins/nsatz/Nsatz.v5
-rw-r--r--plugins/nsatz/ideal.ml59
-rw-r--r--plugins/nsatz/nsatz.ml30
-rw-r--r--plugins/omega/coq_omega.ml305
-rw-r--r--plugins/omega/omega.ml10
-rw-r--r--plugins/romega/const_omega.ml6
-rw-r--r--plugins/romega/const_omega.mli2
-rw-r--r--plugins/romega/g_romega.ml42
-rw-r--r--plugins/romega/refl_omega.ml29
-rw-r--r--plugins/rtauto/refl_tauto.ml1
-rw-r--r--plugins/setoid_ring/newring.ml3
-rw-r--r--plugins/setoid_ring/newring.mli3
-rw-r--r--plugins/ssrmatching/ssrmatching.ml455
-rw-r--r--plugins/ssrmatching/ssrmatching.mli2
-rw-r--r--pretyping/cases.ml17
-rw-r--r--pretyping/cbv.mli1
-rw-r--r--pretyping/classops.ml3
-rw-r--r--pretyping/classops.mli1
-rw-r--r--pretyping/coercion.ml5
-rw-r--r--pretyping/coercion.mli1
-rw-r--r--pretyping/constr_matching.ml80
-rw-r--r--pretyping/detyping.ml10
-rw-r--r--pretyping/evarconv.ml1
-rw-r--r--pretyping/evarconv.mli1
-rw-r--r--pretyping/evardefine.ml1
-rw-r--r--pretyping/evarsolve.ml1
-rw-r--r--pretyping/find_subterm.mli1
-rw-r--r--pretyping/inductiveops.ml1
-rw-r--r--pretyping/miscops.ml2
-rw-r--r--pretyping/patternops.ml5
-rw-r--r--pretyping/patternops.mli1
-rw-r--r--pretyping/pretype_errors.ml1
-rw-r--r--pretyping/pretyping.ml105
-rw-r--r--pretyping/program.ml1
-rw-r--r--pretyping/reductionops.ml12
-rw-r--r--pretyping/reductionops.mli5
-rw-r--r--pretyping/tacred.mli1
-rw-r--r--pretyping/typeclasses_errors.ml1
-rw-r--r--pretyping/typeclasses_errors.mli1
-rw-r--r--pretyping/typing.ml3
-rw-r--r--pretyping/unification.ml5
-rw-r--r--printing/ppconstr.ml12
-rw-r--r--printing/ppvernac.ml18
-rw-r--r--printing/prettyp.ml2
-rw-r--r--printing/prettyp.mli1
-rw-r--r--printing/printer.ml161
-rw-r--r--printing/printer.mli21
-rw-r--r--proofs/clenv.ml5
-rw-r--r--proofs/clenvtac.mli1
-rw-r--r--proofs/goal.ml1
-rw-r--r--proofs/goal.mli3
-rw-r--r--proofs/logic.ml7
-rw-r--r--proofs/pfedit.mli2
-rw-r--r--proofs/proof_global.ml27
-rw-r--r--proofs/proof_global.mli1
-rw-r--r--proofs/proof_type.mli3
-rw-r--r--proofs/redexpr.ml2
-rw-r--r--proofs/refiner.ml21
-rw-r--r--proofs/refiner.mli2
-rw-r--r--proofs/tacmach.ml3
-rw-r--r--proofs/tacmach.mli1
-rw-r--r--stm/asyncTaskQueue.ml4
-rw-r--r--stm/stm.ml421
-rw-r--r--stm/stm.mli60
-rw-r--r--stm/vcs.ml2
-rw-r--r--stm/vernac_classifier.ml1
-rw-r--r--stm/workerLoop.ml2
-rw-r--r--tactics/auto.ml15
-rw-r--r--tactics/auto.mli1
-rw-r--r--tactics/autorewrite.ml46
-rw-r--r--tactics/btermdn.mli1
-rw-r--r--tactics/class_tactics.ml43
-rw-r--r--tactics/class_tactics.mli4
-rw-r--r--tactics/contradiction.mli1
-rw-r--r--tactics/dnet.mli2
-rw-r--r--tactics/eauto.mli2
-rw-r--r--tactics/elim.ml1
-rw-r--r--tactics/elim.mli1
-rw-r--r--tactics/eqdecide.ml57
-rw-r--r--tactics/equality.ml29
-rw-r--r--tactics/equality.mli1
-rw-r--r--tactics/hints.ml13
-rw-r--r--tactics/hints.mli1
-rw-r--r--tactics/hipattern.ml1
-rw-r--r--tactics/hipattern.mli1
-rw-r--r--tactics/inv.ml1
-rw-r--r--tactics/inv.mli1
-rw-r--r--tactics/leminv.ml15
-rw-r--r--tactics/leminv.mli1
-rw-r--r--tactics/tacticals.ml16
-rw-r--r--tactics/tacticals.mli4
-rw-r--r--tactics/tactics.ml52
-rw-r--r--tactics/term_dnet.ml2
-rw-r--r--test-suite/bugs/closed/4306.v32
-rw-r--r--test-suite/bugs/closed/5321.v18
-rw-r--r--test-suite/bugs/closed/5377.v54
-rw-r--r--test-suite/bugs/closed/5435.v2
-rw-r--r--test-suite/bugs/closed/5449.v6
-rw-r--r--test-suite/bugs/closed/5460.v11
-rw-r--r--test-suite/bugs/closed/5469.v3
-rw-r--r--test-suite/bugs/closed/5470.v3
-rw-r--r--test-suite/bugs/closed/5476.v28
-rw-r--r--test-suite/bugs/closed/5501.v21
-rw-r--r--test-suite/failure/proofirrelevance.v5
-rw-r--r--test-suite/output/PatternsInBinders.out2
-rw-r--r--test-suite/output/PatternsInBinders.v3
-rw-r--r--test-suite/output/Search.out8
-rw-r--r--test-suite/output/Search.v10
-rw-r--r--test-suite/success/Case19.v2
-rw-r--r--test-suite/success/ImplicitArguments.v6
-rw-r--r--test-suite/success/Notations.v7
-rw-r--r--test-suite/success/all-check.v3
-rw-r--r--test-suite/success/polymorphism.v32
-rw-r--r--test-suite/success/record_syntax.v8
-rw-r--r--theories/.dir-locals.el4
-rw-r--r--theories/Classes/CMorphisms.v2
-rw-r--r--theories/Classes/Morphisms.v2
-rw-r--r--theories/Init/Datatypes.v2
-rw-r--r--theories/Init/Logic.v13
-rw-r--r--theories/Init/Specif.v11
-rw-r--r--theories/Init/Tactics.v7
-rw-r--r--theories/Init/_CoqProject2
-rw-r--r--theories/Logic/ChoiceFacts.v300
-rw-r--r--theories/Reals/DiscrR.v5
-rw-r--r--theories/Reals/RIneq.v11
-rw-r--r--theories/Reals/Ranalysis5.v16
-rw-r--r--theories/Reals/Rfunctions.v98
-rw-r--r--theories/Reals/Rpower.v14
-rw-r--r--tools/coq_makefile.ml116
-rw-r--r--tools/coqc.ml4
-rw-r--r--tools/coqdep.ml2
-rw-r--r--tools/coqdoc/output.mli1
-rw-r--r--tools/coqwc.mll2
-rw-r--r--toplevel/coqinit.ml11
-rw-r--r--toplevel/coqinit.mli2
-rw-r--r--toplevel/coqloop.ml90
-rw-r--r--toplevel/coqloop.mli4
-rw-r--r--toplevel/coqtop.ml77
-rw-r--r--toplevel/usage.ml2
-rw-r--r--toplevel/vernac.ml236
-rw-r--r--toplevel/vernac.mli36
-rw-r--r--vernac/auto_ind_decl.ml8
-rw-r--r--vernac/class.ml4
-rw-r--r--vernac/classes.ml2
-rw-r--r--vernac/command.ml45
-rw-r--r--vernac/command.mli8
-rw-r--r--vernac/ind_tables.ml6
-rw-r--r--vernac/lemmas.ml31
-rw-r--r--vernac/lemmas.mli4
-rw-r--r--vernac/metasyntax.ml42
-rw-r--r--vernac/mltop.ml4
-rw-r--r--vernac/obligations.ml6
-rw-r--r--vernac/obligations.mli1
-rw-r--r--vernac/record.ml2
-rw-r--r--vernac/search.ml2
-rw-r--r--vernac/search.mli1
-rw-r--r--vernac/topfmt.ml67
-rw-r--r--vernac/topfmt.mli11
-rw-r--r--vernac/vernac.mllib1
-rw-r--r--vernac/vernacentries.ml86
-rw-r--r--vernac/vernacentries.mli32
-rw-r--r--vernac/vernacprop.ml53
-rw-r--r--vernac/vernacprop.mli19
338 files changed, 4182 insertions, 3426 deletions
diff --git a/.merlin b/.merlin
index 5cae15f5f4..f91e1b8fd7 100644
--- a/.merlin
+++ b/.merlin
@@ -1,4 +1,4 @@
-FLG -rectypes -thread -safe-string
+FLG -rectypes -thread -safe-string -w +a-4-9-27-41-42-44-45-48-50
S ltac
B ltac
diff --git a/.travis.yml b/.travis.yml
index d35b7a8422..adaae54872 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,11 +22,14 @@ env:
- NJOBS=2
# system is == 4.02.3
- COMPILER="system"
+ - CAMLP5_VER="6.14"
# Main test suites
matrix:
- TEST_TARGET="test-suite" COMPILER="4.02.3+32bit"
- TEST_TARGET="validate" TW="travis_wait"
- TEST_TARGET="validate" COMPILER="4.02.3+32bit" TW="travis_wait"
+ - TEST_TARGET="ci-bedrock-src"
+ - TEST_TARGET="ci-bedrock-facade"
- TEST_TARGET="ci-color"
- TEST_TARGET="ci-compcert"
- TEST_TARGET="ci-coquelicot"
@@ -81,6 +84,7 @@ matrix:
- env:
- TEST_TARGET="test-suite"
- COMPILER="4.04.0"
+ - CAMLP5_VER="6.17"
- EXTRA_CONF="-coqide opt -with-doc yes"
- EXTRA_OPAM="lablgtk-extras hevea"
addons:
@@ -106,8 +110,8 @@ matrix:
install:
- opam init -j ${NJOBS} --compiler=${COMPILER} -n -y
- eval $(opam config env)
-- opam config var root
-- opam install -j ${NJOBS} -y camlp5 ocamlfind ${EXTRA_OPAM}
+- opam config list
+- opam install -j ${NJOBS} -y camlp5.${CAMLP5_VER} ocamlfind ${EXTRA_OPAM}
- opam list
script:
diff --git a/CHANGES b/CHANGES
index 02df8614c6..60b88ea8db 100644
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,7 @@ Tactics
Most notably, the new implementation recognizes Miller patterns that were
missed before because of a missing normalization step. Hopefully this should
be fairly uncommon.
+- "auto with real" can now discharge comparisons of literals
Standard Library
diff --git a/INSTALL b/INSTALL
index 6b49738b83..eacbec299c 100644
--- a/INSTALL
+++ b/INSTALL
@@ -168,16 +168,10 @@ INSTALLATION PROCEDURE FOR ADVANCED USERS.
Then compile the sources as described in step 5 above. The resulting
binaries will reside in the subdirectory bin/.
- If you want to compile the sources for debugging (i.e. with the option
- -g of the Caml compiler) then add the -debug option at configuration
- step :
-
- ./configure -debug <other options>
-
- and then compile the sources (step 5). Then you must make a Coq toplevel
- including your own tactics, which must be compiled with -g, with coqmktop.
- See the chapter 16 of the Coq Reference Manual for details about how
- to use coqmktop and the Objective Caml debugger with Coq.
+ Unless you pass the -nodebug option to ./configure, the -g option of the
+ OCaml compiler will be used during compilation to allow debugging.
+ See the debugging file in dev/doc and the chapter 15 of the Coq Reference
+ Manual for details about how to use the OCaml debugger with Coq.
THE AVAILABLE COMMANDS.
diff --git a/Makefile b/Makefile
index e1d6e8e1d2..826ed17b05 100644
--- a/Makefile
+++ b/Makefile
@@ -52,7 +52,8 @@ FIND_VCS_CLAUSE:='(' \
-name '.bzr' -o \
-name 'debian' -o \
-name "$${GIT_DIR}" -o \
- -name '_build' \
+ -name '_build' -o \
+ -name '_build_ci' \
')' -prune -o
define find
diff --git a/Makefile.ci b/Makefile.ci
index b055ada8e5..4c4606aff6 100644
--- a/Makefile.ci
+++ b/Makefile.ci
@@ -1,11 +1,10 @@
CI_TARGETS=ci-all ci-hott ci-math-comp ci-compcert ci-sf ci-cpdt \
ci-color ci-math-classes ci-tlc ci-fiat-crypto ci-fiat-parsers \
ci-coquelicot ci-flocq ci-iris-coq ci-metacoq ci-geocoq \
- ci-unimath ci-vst
+ ci-unimath ci-vst ci-bedrock-src ci-bedrock-facade
.PHONY: $(CI_TARGETS)
# Generic rule, we use make to easy travis integraton with mixed rules
$(CI_TARGETS): ci-%:
./dev/ci/ci-$*.sh
-
diff --git a/README.md b/README.md
index a41ee7cc07..91f9c560e8 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,23 @@
# Coq
+
+[![Coq 8.7~alpha](https://travis-ci.org/coq/coq.svg?branch=trunk)](https://travis-ci.org/coq/coq) [![Gitter](https://badges.gitter.im/coq/coq.svg)](https://gitter.im/coq/coq)
+
Coq is a formal proof management system. It provides a formal language to write
mathematical definitions, executable algorithms and theorems together with an
environment for semi-interactive development of machine-checked proofs.
## Installation
-See the file `INSTALL` for installation procedure.
+Go to the [download page](https://coq.inria.fr/download) for Windows and MacOS packages;
+read the [help page](https://coq.inria.fr/opam/www/using.html) on how to install Coq with OPAM;
+or refer to the [`INSTALL` file](/INSTALL) for the procedure to install from source.
## Documentation
The documentation is part of the archive in directory doc. The
documentation of the last released version is available on the Coq
-web site at [coq.inria.fr/doc](http://coq.inria.fr/doc).
+web site at [coq.inria.fr/documentation](http://coq.inria.fr/documentation).
## Changes
-There is a file named `CHANGES` that explains the differences and the
+There is a file named [`CHANGES`](/CHANGES) that explains the differences and the
incompatibilities since last versions. If you upgrade Coq, please read
it carefully.
diff --git a/TODO b/TODO
deleted file mode 100644
index f24a37f389..0000000000
--- a/TODO
+++ /dev/null
@@ -1,53 +0,0 @@
-Langage:
-
-Distribution:
-
-Environnement:
-
-- Porter SearchIsos
-
-Noyau:
-
-Tactic:
-
-- Que contradiction raisonne a isomorphisme pres de False
-
-Vernac:
-
-- Print / Print Proof en fait identiques ; Print ne devrait pas afficher
- les constantes opaques (devrait afficher qqchose comme <opaque>)
-
-Theories:
-
-- Rendre transparent tous les theoremes prouvant {A}+{B}
-- Faire demarrer PolyList.nth a` l'indice 0
- Renommer l'actuel nth en nth1 ??
-
-Doc:
-
-- Mettre à jour les messages d'erreurs de Discriminate/Simplify_eq/Injection
-- Documenter le filtrage sur les types inductifs avec let-ins (dont la
- compatibilite V6)
-
-- Ajouter let dans les règles du CIC
- -> FAIT, mais reste a documenter le let dans les inductifs
- et les champs manifestes dans les Record
-- revoir le chapitre sur les tactiques utilisateur
-- faut-il mieux spécifier la sémantique de Simpl (??)
-
-- Préciser la clarification syntaxique de IntroPattern
-- preciser que Goal vient en dernier dans une clause pattern list et
- qu'il doit apparaitre si il y a un "in"
-
-- Omega Time debranche mais Omega System et Omega Action remarchent ?
-- Ajout "Replace in" (mais TODO)
-- Syntaxe Conditional tac Rewrite marche, à documenter
-- Documenter Dependent Rewrite et CutRewrite ?
-- Ajouter les motifs sous-termes de ltac
-
-- ajouter doc de GenFixpoint (mais avant: changer syntaxe) (J. Forest ou Pierre C.)
-- mettre à jour la doc de induction (arguments multiples) (Pierre C.)
-- mettre à jour la doc de functional induction/scheme (J. Forest ou Pierre C.)
---> mettre à jour le CHANGES (vers la ligne 72)
-
-
diff --git a/checker/checker.ml b/checker/checker.ml
index 95a9ea78b1..5cadfe7b94 100644
--- a/checker/checker.ml
+++ b/checker/checker.ml
@@ -221,7 +221,7 @@ let where = function
| Some s ->
if !Flags.debug then (str"in " ++ str s ++ str":" ++ spc ()) else (mt ())
-let rec explain_exn = function
+let explain_exn = function
| Stream.Failure ->
hov 0 (anomaly_string () ++ str "uncaught Stream.Failure.")
| Stream.Error txt ->
@@ -354,7 +354,7 @@ let parse_args argv =
| "-norec" :: [] -> usage ()
| "-silent" :: rem ->
- Flags.make_silent true; parse rem
+ Flags.quiet := true; parse rem
| s :: _ when s<>"" && s.[0]='-' ->
fatal_error (str "Unknown option " ++ str s) false
diff --git a/checker/closure.ml b/checker/closure.ml
index cef1d31a68..b8294e7958 100644
--- a/checker/closure.ml
+++ b/checker/closure.ml
@@ -651,22 +651,6 @@ let drop_parameters depth n argstk =
(** Projections and eta expansion *)
-let rec get_parameters depth n argstk =
- match argstk with
- Zapp args::s ->
- let q = Array.length args in
- if n > q then Array.append args (get_parameters depth (n-q) s)
- else if Int.equal n q then [||]
- else Array.sub args 0 n
- | Zshift(k)::s ->
- get_parameters (depth-k) n s
- | [] -> (* we know that n < stack_args_size(argstk) (if well-typed term) *)
- if Int.equal n 0 then [||]
- else raise Not_found (* Trying to eta-expand a partial application..., should do
- eta expansion first? *)
- | _ -> assert false
- (* strip_update_shift_app only produces Zapp and Zshift items *)
-
let eta_expand_ind_stack env ind m s (f, s') =
let mib = lookup_mind (fst ind) env in
match mib.mind_record with
diff --git a/checker/declarations.ml b/checker/declarations.ml
index 1fe02c8b60..ad93146d55 100644
--- a/checker/declarations.ml
+++ b/checker/declarations.ml
@@ -6,6 +6,7 @@ open Term
(** Substitutions, code imported from kernel/mod_subst *)
module Deltamap = struct
+ [@@@ocaml.warning "-32-34"]
type t = delta_resolver
let empty = MPmap.empty, KNmap.empty
let is_empty (mm, km) = MPmap.is_empty mm && KNmap.is_empty km
@@ -25,6 +26,7 @@ end
let empty_delta_resolver = Deltamap.empty
module Umap = struct
+ [@@@ocaml.warning "-32-34"]
type 'a t = 'a umap_t
let empty = MPmap.empty, MBImap.empty
let is_empty (m1,m2) = MPmap.is_empty m1 && MBImap.is_empty m2
@@ -461,13 +463,6 @@ let is_opaque cb = match cb.const_body with
let opaque_univ_context cb = force_lazy_constr_univs cb.const_body
-let subst_rel_declaration sub (id,copt,t as x) =
- let copt' = Option.smartmap (subst_mps sub) copt in
- let t' = subst_mps sub t in
- if copt == copt' && t == t' then x else (id,copt',t')
-
-let subst_rel_context sub = List.smartmap (subst_rel_declaration sub)
-
let subst_recarg sub r = match r with
| Norec -> r
| (Mrec(kn,i)|Imbr (kn,i)) -> let kn' = subst_ind sub kn in
@@ -515,10 +510,6 @@ let subst_decl_arity f g sub ar =
if x' == x then ar
else TemplateArity x'
-let map_decl_arity f g = function
- | RegularArity a -> RegularArity (f a)
- | TemplateArity a -> TemplateArity (g a)
-
let subst_rel_declaration sub =
Term.map_rel_decl (subst_mps sub)
diff --git a/checker/include b/checker/include
index 6bea3c91a7..09bf2826c0 100644
--- a/checker/include
+++ b/checker/include
@@ -116,7 +116,7 @@ let prsub s =
#install_printer prsub;;*)
Checker.init_with_argv [|"";"-coqlib";"."|];;
-Flags.make_silent false;;
+Flags.quiet := false;;
Flags.debug := true;;
Sys.catch_break true;;
diff --git a/checker/inductive.ml b/checker/inductive.ml
index c4ffc141ff..8f23a38afc 100644
--- a/checker/inductive.ml
+++ b/checker/inductive.ml
@@ -149,7 +149,7 @@ let remember_subst u subst =
(* Bind expected levels of parameters to actual levels *)
(* Propagate the new levels in the signature *)
-let rec make_subst env =
+let make_subst env =
let rec make subst = function
| LocalDef _ :: sign, exp, args ->
make subst (sign, exp, args)
@@ -436,13 +436,6 @@ let eq_recarg r1 r2 = match r1, r2 with
let eq_wf_paths = Rtree.equal eq_recarg
-let pp_recarg = function
- | Norec -> Pp.str "Norec"
- | Mrec i -> Pp.str ("Mrec "^MutInd.to_string (fst i))
- | Imbr i -> Pp.str ("Imbr "^MutInd.to_string (fst i))
-
-let pp_wf_paths = Rtree.pp_tree pp_recarg
-
let inter_recarg r1 r2 = match r1, r2 with
| Norec, Norec -> Some r1
| Mrec i1, Mrec i2
diff --git a/checker/subtyping.ml b/checker/subtyping.ml
index 7eae9b8310..a290b240d8 100644
--- a/checker/subtyping.ml
+++ b/checker/subtyping.ml
@@ -113,7 +113,7 @@ let check_inductive env mp1 l info1 mib2 spec2 subst1 subst2=
in
let check_inductive_type env t1 t2 =
- (* Due to sort-polymorphism in inductive types, the conclusions of
+ (* Due to template polymorphism, the conclusions of
t1 and t2, if in Type, are generated as the least upper bounds
of the types of the constructors.
diff --git a/checker/term.ml b/checker/term.ml
index 591348cb69..24e6008d34 100644
--- a/checker/term.ml
+++ b/checker/term.ml
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-(* This module instantiates the structure of generic deBruijn terms to Coq *)
+(* This module instantiates the structure of generic de Bruijn terms to Coq *)
open CErrors
open Util
@@ -94,7 +94,7 @@ let closedn n c =
in
try closed_rec n c; true with LocalOccur -> false
-(* [closed0 M] is true iff [M] is a (deBruijn) closed term *)
+(* [closed0 M] is true iff [M] is a (de Bruijn) closed term *)
let closed0 = closedn 0
diff --git a/checker/typeops.ml b/checker/typeops.ml
index 173e19ce1b..1396d56df3 100644
--- a/checker/typeops.ml
+++ b/checker/typeops.ml
@@ -85,9 +85,6 @@ let type_of_constant_knowing_parameters env cst paramtyps =
let type_of_constant_type env t =
type_of_constant_type_knowing_parameters env t [||]
-let type_of_constant env cst =
- type_of_constant_knowing_parameters env cst [||]
-
let judge_of_constant_knowing_parameters env (kn,u as cst) paramstyp =
let _cb =
try lookup_constant kn env
@@ -278,13 +275,11 @@ let rec execute env cstr =
let j =
match f with
| Ind ind ->
- (* Sort-polymorphism of inductive types *)
judge_of_inductive_knowing_parameters env ind jl
| Const cst ->
- (* Sort-polymorphism of constant *)
judge_of_constant_knowing_parameters env cst jl
| _ ->
- (* No sort-polymorphism *)
+ (* No template polymorphism *)
execute env f
in
let jl = Array.map2 (fun c ty -> c,ty) args jl in
diff --git a/checker/univ.ml b/checker/univ.ml
index 668f3a0584..fb1a0faa78 100644
--- a/checker/univ.ml
+++ b/checker/univ.ml
@@ -87,7 +87,6 @@ module HList = struct
val exists : (elt -> bool) -> t -> bool
val for_all : (elt -> bool) -> t -> bool
val for_all2 : (elt -> elt -> bool) -> t -> t -> bool
- val remove : elt -> t -> t
val to_list : t -> elt list
end
@@ -128,12 +127,6 @@ module HList = struct
| Nil -> []
| Cons (x, _, l) -> x :: to_list l
- let rec remove x = function
- | Nil -> nil
- | Cons (y, _, l) ->
- if H.eq x y then l
- else cons y (remove x l)
-
end
end
diff --git a/configure.ml b/configure.ml
index befd67262c..5330da7d37 100644
--- a/configure.ml
+++ b/configure.ml
@@ -270,6 +270,7 @@ module Prefs = struct
let nativecompiler = ref (not (os_type_win32 || os_type_cygwin))
let coqwebsite = ref "http://coq.inria.fr/"
let force_caml_version = ref false
+ let warn_error = ref false
end
(* TODO : earlier any option -foo was also available as --foo *)
@@ -352,6 +353,8 @@ let args_options = Arg.align [
" URL of the coq website";
"-force-caml-version", Arg.Set Prefs.force_caml_version,
" Force OCaml version";
+ "-warn-error", Arg.Set Prefs.warn_error,
+ " Make OCaml warnings into errors";
]
let parse_args () =
@@ -511,6 +514,32 @@ let camltag = match caml_version_list with
| x::y::_ -> "OCAML"^x^y
| _ -> assert false
+(** Explanation of disabled warnings:
+ 3: deprecated warning (not error for non minimum supported ocaml)
+ 4: fragile pattern matching: too common in the code and too annoying to avoid in general
+ 9: missing fields in a record pattern: too common in the code and not worth the bother
+ 27: innocuous unused variable: innocuous
+ 41: ambiguous constructor or label: too common
+ 42: disambiguated counstructor or label: too common
+ 44: "open" shadowing already defined identifier: too common, especially when some are aliases
+ 45: "open" shadowing a label or constructor: see 44
+ 48: implicit elimination of optional arguments: too common
+ 50: unexpected documentation comment: too common and annoying to avoid
+ 56: unreachable match case: the [_ -> .] syntax doesn't exist in 4.02.3
+*)
+let coq_warn_flags =
+ let warnings = "-w +a-4-9-27-41-42-44-45-48-50" in
+ let errors =
+ if !Prefs.warn_error
+ then "-warn-error +a"
+ ^ (if caml_version_nums > [4;2;3]
+ then "-3-56"
+ else "")
+ else ""
+ in
+ warnings ^ " " ^ errors
+
+
(** * CamlpX configuration *)
@@ -1103,7 +1132,7 @@ let write_makefile f =
pr "CAMLHLIB=%S\n\n" camllib;
pr "# Caml link command and Caml make top command\n";
pr "# Caml flags\n";
- pr "CAMLFLAGS=-rectypes %s %s\n" coq_annotate_flag coq_safe_string;
+ pr "CAMLFLAGS=-rectypes %s %s %s\n" coq_warn_flags coq_annotate_flag coq_safe_string;
pr "# User compilation flag\n";
pr "USERFLAGS=\n\n";
pr "# Flags for GCC\n";
diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh
index 336ce9d8f1..e0851816ce 100644
--- a/dev/ci/ci-basic-overlay.sh
+++ b/dev/ci/ci-basic-overlay.sh
@@ -95,6 +95,18 @@
: ${fiat_crypto_CI_GITURL:=https://github.com/mit-plv/fiat-crypto.git}
########################################################################
+# bedrock_src
+########################################################################
+: ${bedrock_src_CI_BRANCH:=master}
+: ${bedrock_src_CI_GITURL:=https://github.com/JasonGross/bedrock.git}
+
+########################################################################
+# bedrock_facade
+########################################################################
+: ${bedrock_facade_CI_BRANCH:=master}
+: ${bedrock_facade_CI_GITURL:=https://github.com/JasonGross/bedrock.git}
+
+########################################################################
# CoLoR
########################################################################
: ${Color_CI_SVNURL:=https://scm.gforge.inria.fr/anonscm/svn/color/trunk/color}
@@ -109,4 +121,3 @@
########################################################################
: ${tlc_CI_BRANCH:=master}
: ${tlc_CI_GITURL:=https://gforge.inria.fr/git/tlc/tlc.git}
-
diff --git a/dev/ci/ci-bedrock-facade.sh b/dev/ci/ci-bedrock-facade.sh
new file mode 100755
index 0000000000..95cfa3073f
--- /dev/null
+++ b/dev/ci/ci-bedrock-facade.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+ci_dir="$(dirname "$0")"
+source ${ci_dir}/ci-common.sh
+
+bedrock_facade_CI_DIR=${CI_BUILD_DIR}/bedrock-facade
+
+git_checkout ${bedrock_facade_CI_BRANCH} ${bedrock_facade_CI_GITURL} ${bedrock_facade_CI_DIR}
+
+( cd ${bedrock_facade_CI_DIR} && make -j ${NJOBS} facade )
diff --git a/dev/ci/ci-bedrock-src.sh b/dev/ci/ci-bedrock-src.sh
new file mode 100755
index 0000000000..532611d4b3
--- /dev/null
+++ b/dev/ci/ci-bedrock-src.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+ci_dir="$(dirname "$0")"
+source ${ci_dir}/ci-common.sh
+
+bedrock_src_CI_DIR=${CI_BUILD_DIR}/bedrock-src
+
+git_checkout ${bedrock_src_CI_BRANCH} ${bedrock_src_CI_GITURL} ${bedrock_src_CI_DIR}
+
+( cd ${bedrock_src_CI_DIR} && make -j ${NJOBS} src )
diff --git a/dev/ci/ci-fiat-crypto.sh b/dev/ci/ci-fiat-crypto.sh
index 93d39aab07..c6df45a1d4 100755
--- a/dev/ci/ci-fiat-crypto.sh
+++ b/dev/ci/ci-fiat-crypto.sh
@@ -7,4 +7,4 @@ fiat_crypto_CI_DIR=${CI_BUILD_DIR}/fiat-crypto
git_checkout ${fiat_crypto_CI_BRANCH} ${fiat_crypto_CI_GITURL} ${fiat_crypto_CI_DIR}
-( cd ${fiat_crypto_CI_DIR} && make -j ${NJOBS} )
+( cd ${fiat_crypto_CI_DIR} && make -j ${NJOBS} lite )
diff --git a/dev/ci/ci-user-overlay.sh b/dev/ci/ci-user-overlay.sh
index bb193ebb55..fad6472911 100644
--- a/dev/ci/ci-user-overlay.sh
+++ b/dev/ci/ci-user-overlay.sh
@@ -25,7 +25,7 @@ echo $TRAVIS_PULL_REQUEST
echo $TRAVIS_BRANCH
echo $TRAVIS_COMMIT
-if [ $TRAVIS_PULL_REQUEST == "461" ] || [ $TRAVIS_BRANCH == "stm+remove_compat_parsing" ]; then
- mathcomp_CI_BRANCH=no_camlp4_compat
- mathcomp_CI_GITURL=https://github.com/ejgallego/math-comp.git
+if [ $TRAVIS_PULL_REQUEST == "568" ] || [ $TRAVIS_BRANCH == "remove-tactic-compat" ]; then
+ fiat_parsers_CI_BRANCH=fix-ml
+ fiat_parsers_CI_GITURL=https://github.com/ppedrot/fiat.git
fi
diff --git a/dev/doc/changes.txt b/dev/doc/changes.txt
index af077bbb40..8ea1638c99 100644
--- a/dev/doc/changes.txt
+++ b/dev/doc/changes.txt
@@ -44,6 +44,22 @@ The following constructors have been renamed:
LocalRawAssum -> CLocalAssum
LocalPattern -> CLocalPattern
+In Constrexpr_ops:
+
+ Deprecating abstract_constr_expr in favor of mkCLambdaN, and
+ prod_constr_expr in favor of mkCProdN. Note: the first ones were
+ interpreting "(x y z:_)" as "(x:_) (y:_) (z:_)" while the second
+ ones were preserving the original sharing of the type.
+
+** Tactic API **
+
+- pf_constr_of_global now returns a tactic instead of taking a continuation.
+ Thus it only generates one instance of the global reference, and it is the
+ caller's responsibility to perform a focus on the goal.
+
+- The tclWEAK_PROGRESS and tclNOTSAMEGOAL tacticals were removed. Their usecase
+ was very specific. Use tclPROGRESS instead.
+
** Ltac API **
Many Ltac specific API has been moved in its own ltac/ folder. Amongst other
@@ -139,6 +155,36 @@ document type". This allows for a more uniform handling of printing
module Tag
+** Stm API **
+
+- We have streamlined the `Stm` API, now `add` and `query` take a
+ `coq_parsable` instead a `string` so clients can have more control
+ over their input stream. As a consequence, their types have been
+ modified.
+
+- The main parsing entry point has also been moved to the
+ `Stm`. Parsing is considered a synchronous operation so it will
+ either succeed or raise an exception.
+
+- `Feedback` is now only emitted for asynchronous operations. As a
+ consequence, it always carries a valid stateid and the type has
+ changed to accommodate that.
+
+- A few unused hooks were removed due to cleanups, no clients known.
+
+** Toplevel and Vernacular API **
+
+- The components related to vernacular interpretation have been moved
+ to their own folder `vernac/` whereas toplevel now contains the
+ proper toplevel shell and compiler.
+
+- Coq's toplevel has been ported to directly use the common `Stm`
+ API. The signature of a few functions has changed as a result.
+
+** XML Protocol **
+
+- The legacy `Interp` call has been turned into a noop.
+
=========================================
= CHANGES BETWEEN COQ V8.5 AND COQ V8.6 =
=========================================
diff --git a/dev/doc/cic.dtd b/dev/doc/cic.dtd
index f2314e224f..cc33efd483 100644
--- a/dev/doc/cic.dtd
+++ b/dev/doc/cic.dtd
@@ -125,7 +125,7 @@
id ID #REQUIRED
sort %sort; #REQUIRED>
-<!-- The substitutions are ordered by increasing DeBrujin -->
+<!-- The substitutions are ordered by increasing de Bruijn -->
<!-- index. An empty substitution means that that index is -->
<!-- not accessible. -->
<!ELEMENT META (substitution*)>
diff --git a/dev/doc/econstr.md b/dev/doc/econstr.md
new file mode 100644
index 0000000000..bb17e8fb62
--- /dev/null
+++ b/dev/doc/econstr.md
@@ -0,0 +1,129 @@
+# Evar-insensitive terms (EConstr)
+
+Evar-insensitive terms were introduced in 8.7, following
+[CEP #10](https://github.com/coq/ceps/blob/master/text/010-econstr.md). We will
+not recap the motivations in this document and rather summarize the code changes
+to perform.
+
+## Overview
+
+The essential datastructures are defined in
+[the `EConstr` module](/engine/eConstr.mli) module. It defines
+the tactic counterparts of kernel data structures such as terms
+(`EConstr.constr`), universes (`EConstr.ESorts.t`) and contexts
+(`EConstr.*_context`).
+
+The main difference with kernel-side types is that observing them requires
+an evar-map at hand in order to normalize evars on the fly. The basic primitive
+to observe an `EConstr.t` is the following function:
+```
+val kind : Evd.evar_map -> t -> (t, t, ESorts.t, EInstance.t) Constr.kind_of_term
+(** Same as {!Constr.kind} except that it expands evars and normalizes
+ universes on the fly. *)
+```
+
+Essentially, each time it sees an evar which happens to be defined in the
+provided evar-map, it replaces it with the corresponding body and carries on.
+
+Due to universe unification occuring at the tactic level, the same goes for
+universe instances and sorts. See the `ESort` and `EInstance` modules in
+`EConstr`.
+
+This normalization is critical for the soundness of tactics. Before EConstr, a
+lot of bugs were lurking in the code base, a few still are (most notably in
+meta-based unification) and failure to respect the guidelines thereafter may
+result in nasal demons.
+
+## Transition path
+
+### Types
+
+As a rule of thumb, all functions living at the tactic level should manipulate
+`EConstr.t` instead of `Constr.t`, and similarly for the other data structures.
+
+To ease the transition, the `EConstr` module defines a handful of aliases to
+shadow the type names from the kernel.
+
+It is recommended to perform the following replacement in headers.
+```ocaml
+(** Kernel types. You may remove the two following opens if you want. Beware
+ that [kind_of_term] needs to be in scope if you use [EConstr.kind] so that
+ you may still need to open one of the two. *)
+open Term
+open Constr
+(** Tactic types. Open this after to shadow kernel types. *)
+open EConstr
+```
+
+Note that the `EConstr` module also redefines a `Vars` submodule.
+
+### Evar-map-passing
+
+All functions deconstructing an econstr need to take an evar-map as a parameter.
+Therefore, you need to pass one as an argument virtually everywhere.
+
+In the Coq source code, it is recommended to take the evar-map as a first
+argument called `sigma`, except if the function also takes an environment in
+which case it is passed second. Namely, the two typical instances are:
+```ocaml
+let foo sigma c = mycode
+val foo : Evd.evar_map -> EConstr.t -> Foo.t
+
+let bar env sigma c = mycode
+val bar : Environ.env -> Evd.evar_map -> EConstr.t -> Bar.t
+```
+
+The EConstr API makes the code much more sensitive to evar-maps, because a
+lot of now useless normalizations were removed. Thus one should be cautious of
+**not** dropping the evar-map when it has been updated, and should rather stick
+to a strict state-passing discipline. Unsound primitives like
+`Typing.unsafe_type_of` are also a known source of problems, so you should
+replace them with the corresponding evar-map-returning function and thread it
+properly.
+
+### Functions
+
+Many functions from `Constr` and `Term` are redefined to work on econstr in
+the `EConstr` module, so that it is often enough to perform the `open` as
+described above to replace them. Their type may differ though, because they now
+need access to an evar-map. A lot of econstr-manipulating functions are also
+defined in [`Termops`](/engine/termops.mli).
+
+Functions manipulating tactic terms and kernel terms share the same name if they
+are the equivalent one of the other. Do not hesitate to grep Coq mli files to
+find the equivalent of a function you want to port if it is neither in `EConstr`
+nor in `Termops` (this should be very rare).
+
+### Conversion
+
+Sometimes you do not have any other choice than calling kernel-side functions
+on terms, and conversely to turn a kernel term into a tactic term.
+
+There are two functions to do so.
+* `EConstr.of_constr` turns kernel terms into tactic terms. It is currently
+the physical identity, and thus O(1), but this may change in the future.
+* `EConstr.to_constr` turns tactic terms into kernel terms. It performs a
+full-blown normalization of the given term, which is O(n) and potentially
+costly.
+
+For performance reasons, avoiding to jump back and forth between kernel and
+tactic terms is recommended.
+
+There are also a few unsafe conversion functions that take advantage of the
+fact that `EConstr.t` is internally the same as `Constr.t`. Namely,
+`EConstr.Unsafe.to_constr` is the physical identity. It should **not** be used
+in typical code and is instead provided for efficiency **when you know what you
+are doing**. Either use it to reimplement low-level functions that happen to
+be insensitive externally, or use it to provide backward compatibility with
+broken code that relies on evar-sensitivity. **Do not use it because it is
+easier than stuffing evar-maps everywhere.** You've been warned.
+
+## Notes
+
+The EConstr branch fixed a lot of eisenbugs linked to lack of normalization
+everywhere, most notably in unification. It may also have introduced a few, so
+if you see a change in behaviour *that looks like a bug*, please report it.
+Obviously, unification is not specified, so it's hard to tell apart, but still.
+
+Efficiency has been affected as well. We now pay an overhead when observing a
+term, but at the same time a lot of costly upfront normalizations were removed.
diff --git a/dev/doc/xml-protocol.md b/dev/doc/xml-protocol.md
new file mode 100644
index 0000000000..2ff82c6888
--- /dev/null
+++ b/dev/doc/xml-protocol.md
@@ -0,0 +1,745 @@
+#Coq XML Protocol for Coq 8.6#
+
+This document is based on documentation originally written by CJ Bell
+for his [vscoq](https://github.com/siegebell/vscoq/) project.
+
+Here, the aim is to provide a "hands on" description of the XML
+protocol that coqtop and IDEs use to communicate. The protocol first appeared
+with Coq 8.5, and is used by CoqIDE. It will also be used in upcoming
+versions of Proof General.
+
+A somewhat out-of-date description of the async state machine is
+[documented here](https://github.com/ejgallego/jscoq/blob/master/etc/notes/coq-notes.md).
+OCaml types for the protocol can be found in the [`ide/interface.mli` file](/ide/interface.mli).
+
+# CHANGES
+## Changes from 8.5:
+ * In several places, flat text wrapped in <string> tags now appears as structured text inside <richpp> tags
+ * The "errormsg" feedback has been replaced by a "message" feedback which contains
+ <feedback\_content> tag, with a message_level attribute of "error"
+
+* [Commands](#commands)
+ - [About](#command-about)
+ - [Add](#command-add)
+ - [EditAt](#command-editAt)
+ - [Init](#command-init)
+ - [Goal](#command-goal)
+ - [Status](#command-status)
+ - [Query](#command-query)
+ - [Evars](#command-evars)
+ - [Hints](#command-hints)
+ - [Search](#command-search)
+ - [GetOptions](#command-getoptions)
+ - [SetOptions](#command-setoptions)
+ - [MkCases](#command-mkcases)
+ - [StopWorker](#command-stopworker)
+ - [PrintAst](#command-printast)
+ - [Annotate](#command-annotate)
+* [Feedback messages](#feedback)
+ - [Added Axiom](#feedback-addedaxiom)
+ - [Processing](#feedback-processing)
+ - [Processed](#feedback-processed)
+ - [Incomplete](#feedback-incomplete)
+ - [Complete](#feedback-complete)
+ - [GlobRef](#feedback-globref)
+ - [Error](#feedback-error)
+ - [InProgress](#feedback-inprogress)
+ - [WorkerStatus](#feedback-workerstatus)
+ - [File Dependencies](#feedback-filedependencies)
+ - [File Loaded](#feedback-fileloaded)
+ - [Message](#feedback-message)
+ - [Custom](#feedback-custom)
+
+Sentences: each command sent to Coqtop is a "sentence"; they are typically terminated by ".\s" (followed by whitespace or EOF).
+Examples: "Lemma a: True.", "(* asdf *) Qed.", "auto; reflexivity."
+In practice, the command sentences sent to Coqtop are terminated at the "." and start with any previous whitespace.
+Each sentence is assigned a unique stateId after being sent to Coq (via Add).
+States:
+ * Processing: has been received by Coq and has no obvious syntax error (that would prevent future parsing)
+ * Processed:
+ * InProgress:
+ * Incomplete: the validity of the sentence cannot be checked due to a prior error
+ * Complete:
+ * Error: the sentence has an error
+
+State ID 0 is reserved as a 'dummy' state.
+
+--------------------------
+
+## <a name="commands">Commands</a>
+
+### <a name="command-about">**About(unit)**</a>
+Returns information about the protocol and build dates for Coqtop.
+```
+<call val="About">
+ <unit/>
+</call>
+```
+#### *Returns*
+```html
+ <value val="good">
+ <coq_info><string>8.6</string>
+ <string>20150913</string>
+ <string>December 2016</string>
+ <string>Dec 23 2016 16:16:30</string>
+ </coq_info>
+</value>
+```
+The string fields are the Coq version, the protocol version, the release date, and the compile time of Coqtop.
+The protocol version is a date in YYYYMMDD format, where "20150913" corresponds to Coq 8.6. An IDE that wishes
+to support multiple Coq versions can use the protocol version information to know how to handle output from Coqtop.
+
+### <a name="command-add">**Add(stateId: integer, command: string, verbose: boolean)**</a>
+Adds a toplevel command (e.g. vernacular, definition, tactic) to the given state.
+`verbose` controls whether out-of-band messages will be generated for the added command (e.g. "foo is assumed" in response to adding "Axiom foo: nat.").
+```html
+<call val="Add">
+ <pair>
+ <pair>
+ <string>${command}</string>
+ <int>${editId}</int>
+ </pair>
+ <pair>
+ <state_id val="${stateId}"/>
+ <bool val="${verbose}"/>
+ </pair>
+ </pair>
+</call>
+```
+
+#### *Returns*
+* The added command is given a fresh `stateId` and becomes the next "tip".
+```html
+<value val="good">
+ <pair>
+ <state_id val="${newStateId}"/>
+ <pair>
+ <union val="in_l"><unit/></union>
+ <string>${message}</string>
+ </pair>
+ </pair>
+</value>
+```
+* When closing a focused proof (in the middle of a bunch of interpreted commands),
+the `Qed` will be assigned a prior `stateId` and `nextStateId` will be the id of an already-interpreted
+state that should become the next tip.
+```html
+<value val="good">
+ <pair>
+ <state_id val="${stateId}"/>
+ <pair>
+ <union val="in_r"><state_id val="${nextStateId}"/></union>
+ <string>${message}</string>
+ </pair>
+ </pair>
+</value>
+```
+* Failure:
+ - Syntax error. Error offsets are byte offsets (not character offsets) with respect to the start of the sentence, starting at 0.
+ ```html
+ <value val="fail"
+ loc_s="${startOffsetOfError}"
+ loc_e="${endOffsetOfError}">
+ <state_id val="${stateId}"/>
+ <richpp>${errorMessage}</richpp>
+ </value>
+ ```
+ - Another kind of error, for example, Qed with a pending goal.
+ ```html
+ <value val="fail"><state_id val="${stateId}"/><richpp>${errorMessage}</richpp></value>
+ ```
+
+-------------------------------
+
+### <a name="command-editAt">**EditAt(stateId: integer)**</a>
+Moves current tip to `${stateId}`, such that commands may be added to the new state ID.
+```html
+<call val="Edit_at"><state_id val="${stateId}"/></call>
+```
+#### *Returns*
+* Simple backtrack; focused stateId becomes the parent state
+```html
+<value val="good">
+ <union val="in_l"><unit/></union>
+</value>
+```
+
+* New focus; focusedQedStateId is the closing Qed of the new focus; senteneces between the two should be cleared
+```html
+<value val="good">
+ <union val="in_r">
+ <pair>
+ <state_id val="${focusedStateId}"/>
+ <pair>
+ <state_id val="${focusedQedStateId}"/>
+ <state_id val="${oldFocusedStateId}"/>
+ </pair>
+ </pair>
+ </union>
+</value>
+```
+* Failure: If `stateId` is in an error-state and cannot be jumped to, `errorFreeStateId` is the parent state of ``stateId` that shopuld be edited instead.
+```html
+<value val="fail" loc_s="${startOffsetOfError}" loc_e="${endOffsetOfError}">
+ <state_id val="${errorFreeStateId}"/>
+ ${errorMessage}
+</value>
+```
+
+-------------------------------
+
+### <a name="command-init">**Init()**</a>
+* No options.
+```html
+<call val="Init"><option val="none"/></call>
+```
+* With options. Looking at
+ [ide_slave.ml](https://github.com/coq/coq/blob/c5d0aa889fa80404f6c291000938e443d6200e5b/ide/ide_slave.ml#L355),
+ it seems that `options` is just the name of a script file, whose path
+ is added via `Add LoadPath` to the initial state.
+```html
+<call val="Init">
+ <option val="some">
+ <string>${options}</string>
+ </option>
+</call>
+```
+Providing the script file enables Coq to use .aux files created during
+compilation. Those file contain timing information that allow Coq to
+choose smartly between asynchronous and synchronous processing of
+proofs.
+
+#### *Returns*
+* The initial stateId (not associated with a sentence)
+```html
+<value val="good">
+ <state_id val="${initialStateId}"/>
+</value>
+```
+
+-------------------------------
+
+
+### <a name="command-goal">**Goal()**</a>
+```html
+<call val="Goal"><unit/></call>
+```
+#### *Returns*
+* If there is a goal. `shelvedGoals` and `abandonedGoals` have the same structure as the first set of (current/foreground) goals. `backgroundGoals` contains a list of pairs of lists of goals (list ((list Goal)*(list Goal))); it represents a "focus stack" ([see code for reference](https://github.com/coq/coq/blob/trunk/engine/proofview.ml#L113)). Each time a proof is focused, it will add a new pair of lists-of-goals. The first pair is the most nested set of background goals, the last pair is the top level set of background goals. The first list in the pair is in reverse order. Each time you focus the goal (e.g. using `Focus` or a bullet), a new pair will be prefixed to the list.
+```html
+<value val="good">
+ <option val="some">
+ <goals>
+ <!-- current goals -->
+ <list>
+ <goal>
+ <string>3</string>
+ <list>
+ <richpp>${hyp1}</richpp>
+ ...
+ <richpp>${hypN}</richpp>
+ </list>
+ <richpp>${goal}</richpp>
+ </goal>
+ ...
+ ${goalN}
+ </list>
+ <!-- `backgroundGoals` -->
+ <list>
+ <pair>
+ <list><goal />...</list>
+ <list><goal />...</list>
+ </pair>
+ ...
+ </list>
+ ${shelvedGoals}
+ ${abandonedGoals}
+ </goals>
+ </option>
+</value>
+```
+
+For example, this script:
+```coq
+Goal P -> (1=1/\2=2) /\ (3=3 /\ (4=4 /\ 5=5) /\ 6=6) /\ 7=7.
+intros.
+split; split. (* current visible goals are [1=1, 2=2, 3=3/\(4=4/\5=5)/\6=6, 7=7] *)
+Focus 3. (* focus on 3=3/\(4=4/\5=5)/\6=6; bg-before: [1=1, 2=2], bg-after: [7=7] *)
+split; [ | split ]. (* current visible goals are [3=3, 4=4/\5=5, 6=6] *)
+Focus 2. (* focus on 4=4/\5=5; bg-before: [3=3], bg-after: [6=6] *)
+* (* focus again on 4=4/\5=5; bg-before: [], bg-after: [] *)
+split. (* current visible goals are [4=4,5=5] *)
+```
+should generate the following goals structure:
+```
+goals: [ P|-4=4, P|-5=5 ]
+background:
+[
+ ( [], [] ), (* bullet with one goal has no before or after background goals *)
+ ( [ P|-3=3 ], [ P|-6=6 ] ), (* Focus 2 *)
+ ( [ P|-2=2, P|-1=1 ], [ P|-7=7 ] ) (* Focus 3; notice that 1=1 and 2=2 are reversed *)
+]
+```
+Pseudocode for listing all of the goals in order: `rev (flat_map fst background) ++ goals ++ flat_map snd background`.
+
+* No goal:
+```html
+<value val="good"><option val="none"/></value>
+```
+
+-------------------------------
+
+
+### <a name="command-status">**Status(force: bool)**</a>
+CoqIDE typically sets `force` to `false`.
+```html
+<call val="Status"><bool val="${force}"/></call>
+```
+#### *Returns*
+*
+```html
+<status>
+ <string>${path}</string>
+ <string>${proofName}</string>
+ <string>${allProofs}</string>
+ <string>${proofNumber}</string>
+</status>
+```
+
+-------------------------------
+
+
+### <a name="command-query">**Query(query: string, stateId: integer)**</a>
+In practice, `stateId` is 0, but the effect is to perform the query on the currently-focused state.
+```html
+<call val="Query">
+ <pair>
+ <string>${query}</string>
+ <state_id val="${stateId}"/>
+ </pair>
+</call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <string>${message}</string>
+</value>
+```
+-------------------------------
+
+
+
+### <a name="command-evars">**Evars()**</a>
+```html
+<call val="Evars"><unit/></call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <option val="some">
+ <list>
+ <evar>${evar1}</evar>
+ ...
+ <evar>${evarN}</evar>
+ </list>
+ </option>
+</value>
+```
+
+-------------------------------
+
+
+### <a name="command-hints">**Hints()**</a>
+```html
+<call val="Hints"><unit/></call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <option val="some">
+ <pair>
+ <list/>
+ <list>
+ <pair>
+ <string>${hint1}</string>
+ <string>${hint2}</string>
+ </pair>
+ ...
+ <pair>
+ <string>${hintN-1}</string>
+ <string>${hintN}</string>
+ </pair>
+ </list>
+ </pair>
+ </option>
+</value>
+```
+
+-------------------------------
+
+
+### <a name="command-search">**Search([(constraintTypeN: string, constraintValueN: string, positiveConstraintN: boolean)])**</a>
+Searches for objects that satisfy a list of constraints. If `${positiveConstraint}` is `false`, then the constraint is inverted.
+```html
+<call val="Search">
+ <list>
+ <pair>
+ <search_cst val="${constraintType1}">
+ ${constraintValue1}
+ </search_cst>
+ <bool val="${positiveConstraint1}"/>
+ </pair>
+ ...
+ <!-- Example: -->
+ <pair>
+ <search_cst val="name_pattern">
+ <string>bool_rect</string>
+ </search_cst>
+ <bool val="true"/>
+ </pair>
+ </list>
+</call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <list>
+ <coq_object>
+ <list>
+ <string>${metaInfo}</string>
+ ...
+ </list>
+ <list>
+ <string>${name}</string>
+ </list>
+ <string>${definition}</string>
+ </coq_object>
+ ...
+ </list>
+</value>
+```
+##### Types of constraints:
+* Name pattern: `${constraintType} = "name_pattern"`; `${constraintValue}` is a regular expression string.
+* Type pattern: `${constraintType} = "type_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string.
+* SubType pattern: `${constraintType} = "subtype_pattern"`; `${constraintValue}` is a pattern (???: an open gallina term) string.
+* In module: `${constraintType} = "in_module"`; `${constraintValue}` is a list of strings specifying the module/directory structure.
+* Include blacklist: `${constraintType} = "include_blacklist"`; `${constraintValue}` *is ommitted*.
+
+-------------------------------
+
+
+### <a name="command-getoptions">**GetOptions()**</a>
+```html
+<call val="GetOptions"><unit/></call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <list>
+ <pair>
+ <list><string>${string1}</string>...</list>
+ <option_state>
+ <bool>${sync}</bool>
+ <bool>${deprecated}</bool>
+ <string>${name}</string>
+ ${option_value}
+ </option_state>
+ </pair>
+ ...
+ </list>
+</value>
+```
+
+-------------------------------
+
+
+### <a name="command-setoptions">**SetOptions(options)**</a>
+Sends a list of option settings, where each setting roughly looks like:
+`([optionNamePart1, ..., optionNamePartN], value)`.
+```html
+<call val="SetOptions">
+ <list>
+ <pair>
+ <list>
+ <string>optionNamePart1</string>
+ ...
+ <string>optionNamePartN</string>
+ </list>
+ <option_value val="${typeOfOption}">
+ <option val="some">
+ ${value}
+ </option>
+ </option_value>
+ </pair>
+ ...
+ <!-- Example: -->
+ <pair>
+ <list>
+ <string>Printing</string>
+ <string>Width</string>
+ </list>
+ <option_value val="intvalue">
+ <option val="some"><int>60</int></option>
+ </option_value>
+ </pair>
+ </list>
+</call>
+```
+CoqIDE sends the following settings (defaults in parentheses):
+```
+Printing Width : (<option_value val="intvalue"><int>60</int></option_value>),
+Printing Coercions : (<option_value val="boolvalue"><bool val="false"/></option_value>),
+Printing Matching : (...true...)
+Printing Notations : (...true...)
+Printing Existential Instances : (...false...)
+Printing Implicit : (...false...)
+Printing All : (...false...)
+Printing Universes : (...false...)
+```
+#### *Returns*
+*
+```html
+<value val="good"><unit/></value>
+```
+
+-------------------------------
+
+
+### <a name="command-mkcases">**MkCases(...)**</a>
+```html
+<call val="MkCases"><string>...</string></call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <list>
+ <list><string>${string1}</string>...</list>
+ ...
+ </list>
+</value>
+```
+
+-------------------------------
+
+
+### <a name="command-stopworker">**StopWorker(worker: string)**</a>
+```html
+<call val="StopWorker"><string>${worker}</string></call>
+```
+#### *Returns*
+*
+```html
+<value val="good"><unit/></value>
+```
+
+-------------------------------
+
+
+### <a name="command-printast">**PrintAst(stateId: integer)**</a>
+```html
+<call val="PrintAst"><state_id val="${stateId}"/></call>
+```
+#### *Returns*
+*
+```html
+<value val="good">
+ <gallina begin="${gallina_begin}" end="${gallina_end}">
+ <theorem begin="${theorem_begin}" end="${theorem_end}" type="Theorem" name="${theorem_name}">
+ <apply begin="${apply_begin}" end="${apply_end}">
+ <operator begin="${operator_begin}" end="${operator_end}" name="${operator_name}"/>
+ <typed begin="${typed_begin}" end="${typed_end}">
+ <constant begin="${constant_begin}" end="${constant_end}" name="${constant_name}"/>
+ ...
+ <token begin="${token_begin}" end="token_end">${token}</token>
+ ...
+ </typed>
+ ...
+ </apply>
+ </theorem>
+ ...
+ </gallina>
+</value>
+```
+
+-------------------------------
+
+
+
+### <a name="command-annotate">**Annotate(annotation: string)**</a>
+```html
+<call val="Annotate"><string>${annotation}</string></call>
+```
+#### *Returns*
+*
+
+take `<call val="Annotate"><string>Theorem plus_0_r : forall n : nat, n + 0 = n.</string></call>` as an example.
+
+```html
+<value val="good">
+ <pp startpos="0" endpos="45">
+ <vernac_expr startpos="0" endpos="44">
+ <keyword startpos="0" endpos="7">Theorem</keyword>
+ &nbsp;plus_0_r&nbsp;:&nbsp;
+ <constr_expr startpos="19" endpos="44">
+ <keyword startpos="19" endpos="25">forall</keyword>
+ &nbsp;n&nbsp;:&nbsp;
+ <constr_expr startpos="30" endpos="33">nat</constr_expr>
+ ,&nbsp;
+ <unparsing startpos="35" endpos="44">
+ <unparsing startpos="35" endpos="40">
+ <unparsing startpos="35" endpos="40">
+ <unparsing startpos="35" endpos="36">
+ <constr_expr startpos="35" endpos="36">n</constr_expr>
+ </unparsing>
+ <unparsing startpos="36" endpos="38">&nbsp;+</unparsing>
+ <unparsing startpos="38" endpos="39">&nbsp;</unparsing>
+ <unparsing startpos="39" endpos="40">
+ <constr_expr startpos="39" endpos="40">0</constr_expr>
+ </unparsing>
+ </unparsing>
+ </unparsing>
+ <unparsing startpos="40" endpos="42">&nbsp;=</unparsing>
+ <unparsing startpos="42" endpos="43">&nbsp;</unparsing>
+ <unparsing startpos="43" endpos="44">
+ <constr_expr startpos="43" endpos="44">n</constr_expr>
+ </unparsing>
+ </unparsing>
+ </constr_expr>
+ </vernac_expr>
+ .
+ </pp>
+</value>
+```
+
+-------------------------------
+
+## <a name="feedback">Feedback messages</a>
+
+Feedback messages are issued out-of-band,
+ giving updates on the current state of sentences/stateIds,
+ worker-thread status, etc.
+
+In the descriptions of feedback syntax below, wherever a `state_id`
+tag may occur, there may instead be an `edit_id` tag.
+
+* <a name="feedback-addedaxiom">Added Axiom</a>: in response to `Axiom`, `admit`, `Admitted`, etc.
+```html
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="addedaxiom" />
+</feedback>
+```
+* <a name="feedback-processing">Processing</a>
+```html
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="processingin">
+ <string>${workerName}</string>
+ </feedback_content>
+</feedback>
+```
+* <a name="feedback-processed">Processed</a>
+```html
+<feedback object="state" route="0">
+ <feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="processed"/>
+</feedback>
+```
+* <a name="feedback-incomplete">Incomplete</a>
+```html
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="incomplete" />
+</feedback>
+```
+* <a name="feedback-complete">Complete</a>
+* <a name="feedback-globref">GlobRef</a>
+* <a name="feedback-error">Error</a>. Issued, for example, when a processed tactic has failed or is unknown.
+The error offsets may both be 0 if there is no particular syntax involved.
+* <a name="feedback-inprogress">InProgress</a>
+```html
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="inprogress">
+ <int>1</int>
+ </feedback_content>
+</feedback>
+```
+* <a name="feedback-workerstatus">WorkerStatus</a>
+Ex: `workername = "proofworker:0"`
+Ex: `status = "Idle"` or `status = "proof: myLemmaName"` or `status = "Dead"`
+```html
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="workerstatus">
+ <pair>
+ <string>${workerName}</string>
+ <string>${status}</string>
+ </pair>
+ </feedback_content>
+</feedback>
+```
+* <a name="feedback-filedependencies">File Dependencies</a>. Typically in response to a `Require`. Dependencies are *.vo files.
+ - State `stateId` directly depends on `dependency`:
+ ```html
+ <feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="filedependency">
+ <option val="none"/>
+ <string>${dependency}</string>
+ </feedback_content>
+ </feedback>
+ ```
+ - State `stateId` depends on `dependency` via dependency `sourceDependency`
+ ```xml
+ <feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="filedependency">
+ <option val="some"><string>${sourceDependency}</string></option>
+ <string>${dependency}</string>
+ </feedback_content>
+ </feedback>
+ ```
+* <a name="feedback-fileloaded">File Loaded</a>. For state `stateId`, module `module` is being loaded from `voFileName`
+```xml
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="fileloaded">
+ <string>${module}</string>
+ <string>${voFileName`}</string>
+ </feedback_content>
+</feedback>
+```
+
+* <a name="feedback-message">Message</a>. `level` is one of `{info,warning,notice,error,debug}`. For example, in response to an <a href="#command-add">add</a> `"Axiom foo: nat."` with `verbose=true`, message `foo is assumed` will be emitted in response.
+```xml
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="message">
+ <message>
+ <message_level val="${level}"/>
+ <string>${message}</string>
+ </message>
+ </feedback_content>
+</feedback>
+```
+
+* <a name="feedback-custom">Custom</a>. A feedback message that Coq plugins can use to return structured results, including results from Ltac profiling. Optionally, `startPos` and `stopPos` define a range of offsets in the document that the message refers to; otherwise, they will be 0. `customTag` is intended as a unique string that identifies what kind of payload is contained in `customXML`.
+```xml
+<feedback object="state" route="0">
+ <state_id val="${stateId}"/>
+ <feedback_content val="custom">
+ <loc start="${startPos}" stop="${stopPos}"/>
+ <string>${customTag}</string>
+ ${customXML}
+ </feedback_content>
+</feedback>
+```
+
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index 474cc85c17..7caaf2d9d5 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -7,6 +7,7 @@
(************************************************************************)
(* Printers for the ocaml toplevel. *)
+[@@@ocaml.warning "-32"]
open Util
open Pp
@@ -502,7 +503,6 @@ VERNAC COMMAND EXTEND PrintConstr
END
*)
-open Pcoq
open Genarg
open Stdarg
open Egramml
diff --git a/doc/RecTutorial/coqartmacros.tex b/doc/RecTutorial/coqartmacros.tex
index 2a2c211963..72d7492690 100644
--- a/doc/RecTutorial/coqartmacros.tex
+++ b/doc/RecTutorial/coqartmacros.tex
@@ -149,7 +149,7 @@
\newcommand{\PicAbst}[3]{\begin{bundle}{\bf abst}\chunk{#1}\chunk{#2}\chunk{#3}%
\end{bundle}}
-% the same in DeBruijn form
+% the same in de Bruijn form
\newcommand{\PicDbj}[2]{\begin{bundle}{\bf abst}\chunk{#1}\chunk{#2}
\end{bundle}}
diff --git a/doc/common/macros.tex b/doc/common/macros.tex
index 5abdecfc18..0a4251a373 100644
--- a/doc/common/macros.tex
+++ b/doc/common/macros.tex
@@ -145,7 +145,7 @@
\newcommand{\typecstr}{\zeroone{{\tt :}~{\term}}}
\newcommand{\typecstrwithoutblank}{\zeroone{{\tt :}{\term}}}
-
+\newcommand{\typecstrtype}{\zeroone{{\tt :}~{\type}}}
\newcommand{\Fwterm}{\nterm{Fwterm}}
\newcommand{\Index}{\nterm{index}}
@@ -164,6 +164,7 @@
\newcommand{\digit}{\nterm{digit}}
\newcommand{\exteqn}{\nterm{ext\_eqn}}
\newcommand{\field}{\nterm{field}}
+\newcommand{\fielddef}{\nterm{field\_def}}
\newcommand{\firstletter}{\nterm{first\_letter}}
\newcommand{\fixpg}{\nterm{fix\_pgm}}
\newcommand{\fixpointbodies}{\nterm{fix\_bodies}}
diff --git a/doc/refman/RefMan-cic.tex b/doc/refman/RefMan-cic.tex
index b9c17d8148..fdd2725810 100644
--- a/doc/refman/RefMan-cic.tex
+++ b/doc/refman/RefMan-cic.tex
@@ -79,8 +79,8 @@ An algebraic universe $u$ is either a variable (a qualified
identifier with a number) or a successor of an algebraic universe (an
expression $u+1$), or an upper bound of algebraic universes (an
expression $max(u_1,...,u_n)$), or the base universe (the expression
-$0$) which corresponds, in the arity of sort-polymorphic inductive
-types (see Section \ref{Sort-polymorphism-inductive}),
+$0$) which corresponds, in the arity of template polymorphic inductive
+types (see Section \ref{Template-polymorphism}),
to the predicative sort {\Set}. A graph of constraints between
the universe variables is maintained globally. To ensure the existence
of a mapping of the universes to the positive integers, the graph of
@@ -977,8 +977,8 @@ Inductive exType (P:Type->Prop) : Type :=
%is recursive or not. We shall write the type $(x:_R T)C$ if it is
%a recursive argument and $(x:_P T)C$ if the argument is not recursive.
-\paragraph[Sort-polymorphism of inductive types.]{Sort-polymorphism of inductive types.\index{Sort-polymorphism of inductive types}}
-\label{Sort-polymorphism-inductive}
+\paragraph[Template polymorphism.]{Template polymorphism.\index{Template polymorphism}}
+\label{Template-polymorphism}
Inductive types declared in {\Type} are
polymorphic over their arguments in {\Type}.
@@ -1120,6 +1120,10 @@ Check (fun (A:Prop) (B:Set) => prod A B).
Check (fun (A:Type) (B:Prop) => prod A B).
\end{coq_example}
+\Rem Template polymorphism used to be called ``sort-polymorphism of
+inductive types'' before universe polymorphism (see
+Chapter~\ref{Universes-full}) was introduced.
+
\subsection{Destructors}
The specification of inductive definitions with arities and
constructors is quite natural. But we still have to say how to use an
diff --git a/doc/refman/RefMan-ext.tex b/doc/refman/RefMan-ext.tex
index 74d64497aa..6dd0ddf81d 100644
--- a/doc/refman/RefMan-ext.tex
+++ b/doc/refman/RefMan-ext.tex
@@ -29,8 +29,8 @@ construction allows defining ``signatures''.
{\recordkw} & ::= &
{\tt Record} $|$ {\tt Inductive} $|$ {\tt CoInductive}\\
& & \\
-{\field} & ::= & {\name} \zeroone{\binders} : {\type} [ {\tt where} {\it notation} ] \\
- & $|$ & {\name} \zeroone{\binders} {\typecstr} := {\term}
+{\field} & ::= & {\name} \zeroone{\binders} : {\type} \zeroone{{\tt where} {\it notation}} \\
+ & $|$ & {\name} \zeroone{\binders} {\typecstrtype} := {\term}\\
\end{tabular}
\end{centerframe}
\caption{Syntax for the definition of {\tt Record}}
@@ -213,7 +213,21 @@ Record point := { x : nat; y : nat }.
Definition a := Build_point 5 3.
\end{coq_example}
-The following syntax allows creating objects by using named fields. The
+\begin{figure}[t]
+\begin{centerframe}
+\begin{tabular}{lcl}
+{\term} & ++= &
+ \verb!{|! \zeroone{\nelist{\fielddef}{;}} \verb!|}! \\
+ & & \\
+{\fielddef} & ::= & {\name} \zeroone{\binders} := {\term} \\
+\end{tabular}
+\end{centerframe}
+\caption{Syntax for constructing elements of a \texttt{Record} using named fields}
+\label{fig:fieldsyntax}
+\end{figure}
+
+A syntax is available for creating objects by using named fields, as
+shown on Figure~\ref{fig:fieldsyntax}. The
fields do not have to be in any particular order, nor do they have to be all
present if the missing ones can be inferred or prompted for (see
Section~\ref{Program}).
@@ -252,7 +266,7 @@ Eval compute in (
Reset Initial.
\end{coq_eval}
-\Rem An experimental syntax for projections based on a dot notation is
+\Rem A syntax for projections based on a dot notation is
available. The command to activate it is
\optindex{Printing Projections}
\begin{quote}
@@ -267,7 +281,7 @@ available. The command to activate it is
& $|$ & {\term} {\tt .(} {@}{\qualid} \nelist{\term}{} {\tt )}
\end{tabular}
\end{centerframe}
-\caption{Syntax of \texttt{Record} projections}
+\caption{Syntax for \texttt{Record} projections}
\label{fig:projsyntax}
\end{figure}
diff --git a/doc/refman/RefMan-pre.tex b/doc/refman/RefMan-pre.tex
index f36969e821..0441f952df 100644
--- a/doc/refman/RefMan-pre.tex
+++ b/doc/refman/RefMan-pre.tex
@@ -529,7 +529,7 @@ intensive computations.
Christine Paulin implemented an extension of inductive types allowing
recursively non uniform parameters. Hugo Herbelin implemented
-sort-polymorphism for inductive types.
+sort-polymorphism for inductive types (now called template polymorphism).
Claudio Sacerdoti Coen improved the tactics for rewriting on arbitrary
compatible equivalence relations. He also generalized rewriting to
diff --git a/doc/refman/RefMan-tac.tex b/doc/refman/RefMan-tac.tex
index 3f12411863..87b9e4914f 100644
--- a/doc/refman/RefMan-tac.tex
+++ b/doc/refman/RefMan-tac.tex
@@ -1275,15 +1275,18 @@ in the list of subgoals remaining to prove.
\item{\tt assert ( {\ident} := {\term} )}
- This behaves as {\tt assert ({\ident} :\ {\type});[exact
- {\term}|idtac]} where {\type} is the type of {\term}. This is
- deprecated in favor of {\tt pose proof}.
+ This behaves as {\tt assert ({\ident} :\ {\type}) by exact {\term}}
+ where {\type} is the type of {\term}. This is deprecated in favor of
+ {\tt pose proof}.
+
+ If the head of {\term} is {\ident}, the tactic behaves as
+ {\tt specialize \term}.
\ErrMsg \errindex{Variable {\ident} is already declared}
-\item \texttt{pose proof {\term} as {\intropattern}\tacindex{pose proof}}
+\item \texttt{pose proof {\term} \zeroone{as {\intropattern}}\tacindex{pose proof}}
- This tactic behaves like \texttt{assert T as {\intropattern} by
+ This tactic behaves like \texttt{assert T \zeroone{as {\intropattern}} by
exact {\term}} where \texttt{T} is the type of {\term}.
In particular, \texttt{pose proof {\term} as {\ident}} behaves as
@@ -1326,8 +1329,8 @@ in the list of subgoals remaining to prove.
following subgoals: {\tt U -> T} and \texttt{U}. The subgoal {\tt U
-> T} comes first in the list of remaining subgoal to prove.
-\item {\tt specialize ({\ident} \term$_1$ \dots\ \term$_n$)\tacindex{specialize}} \\
- {\tt specialize {\ident} with \bindinglist}
+\item {\tt specialize ({\ident} \term$_1$ \dots\ \term$_n$)\tacindex{specialize} \zeroone{as \intropattern}}\\
+ {\tt specialize {\ident} with {\bindinglist} \zeroone{as \intropattern}}
The tactic {\tt specialize} works on local hypothesis \ident.
The premises of this hypothesis (either universal
@@ -1338,14 +1341,19 @@ in the list of subgoals remaining to prove.
second form, all instantiation elements must be given, whereas
in the first form the application to \term$_1$ {\ldots}
\term$_n$ can be partial. The first form is equivalent to
- {\tt assert (\ident' := {\ident} {\term$_1$} \dots\ \term$_n$);
- clear \ident; rename \ident' into \ident}.
+ {\tt assert ({\ident} := {\ident} {\term$_1$} \dots\ \term$_n$)}.
+
+ With the {\tt as} clause, the local hypothesis {\ident} is left
+ unchanged and instead, the modified hypothesis is introduced as
+ specified by the {\intropattern}.
The name {\ident} can also refer to a global lemma or
hypothesis. In this case, for compatibility reasons, the
behavior of {\tt specialize} is close to that of {\tt
generalize}: the instantiated statement becomes an additional
- premise of the goal.
+ premise of the goal. The {\tt as} clause is especially useful
+ in this case to immediately introduce the instantiated statement
+ as a local hypothesis.
\begin{ErrMsgs}
\item \errindexbis{{\ident} is used in hypothesis \ident'}{is used in hypothesis}
@@ -2618,9 +2626,9 @@ as the ones described in Section~\ref{Tac-induction}.
In the syntax of the tactic, the identifier {\ident} is the name given
to the induction hypothesis. The natural number {\num} tells on which
premise of the current goal the induction acts, starting
-from 1 and counting both dependent and non dependent
-products. Especially, the current lemma must be composed of at least
-{\num} products.
+from 1, counting both dependent and non dependent
+products, but skipping local definitions. Especially, the current
+lemma must be composed of at least {\num} products.
Like in a {\tt fix} expression, the induction
hypotheses have to be used on structurally smaller arguments.
diff --git a/doc/refman/RefMan-tus.tex b/doc/refman/RefMan-tus.tex
index 797b0adedd..017de6d484 100644
--- a/doc/refman/RefMan-tus.tex
+++ b/doc/refman/RefMan-tus.tex
@@ -288,8 +288,8 @@ constructors:
\item $(\texttt{VAR}\;id)$, a reference to a global identifier called $id$;
\item $(\texttt{Rel}\;n)$, a bound variable, whose binder is the $nth$
binder up in the term;
-\item $\texttt{DLAM}\;(x,t)$, a deBruijn's binder on the term $t$;
-\item $\texttt{DLAMV}\;(x,vt)$, a deBruijn's binder on all the terms of
+\item $\texttt{DLAM}\;(x,t)$, a de Bruijn's binder on the term $t$;
+\item $\texttt{DLAMV}\;(x,vt)$, a de Bruijn's binder on all the terms of
the vector $vt$;
\item $(\texttt{DOP0}\;op)$, a unary operator $op$;
\item $\texttt{DOP2}\;(op,t_1,t_2)$, the application of a binary
@@ -299,7 +299,7 @@ vector of terms $vt$.
\end{itemize}
In this meta-language, bound variables are represented using the
-so-called deBrujin's indexes. In this representation, an occurrence of
+so-called de Bruijn's indexes. In this representation, an occurrence of
a bound variable is denoted by an integer, meaning the number of
binders that must be traversed to reach its own
binder\footnote{Actually, $(\texttt{Rel}\;n)$ means that $(n-1)$ binders
@@ -339,7 +339,7 @@ on the terms of the meta-language:
\fun{val Generic.dependent : 'op term -> 'op term -> bool}
{Returns true if the first term is a sub-term of the second.}
%\fun{val Generic.subst\_var : identifier -> 'op term -> 'op term}
-% { $(\texttt{subst\_var}\;id\;t)$ substitutes the deBruijn's index
+% { $(\texttt{subst\_var}\;id\;t)$ substitutes the de Bruijn's index
% associated to $id$ to every occurrence of the term
% $(\texttt{VAR}\;id)$ in $t$.}
\end{description}
@@ -482,7 +482,7 @@ following constructor functions:
\begin{description}
\fun{val Term.mkRel : int -> constr}
- {$(\texttt{mkRel}\;n)$ represents deBrujin's index $n$.}
+ {$(\texttt{mkRel}\;n)$ represents de Bruijn's index $n$.}
\fun{val Term.mkVar : identifier -> constr}
{$(\texttt{mkVar}\;id)$
@@ -545,7 +545,7 @@ following constructor functions:
\fun{val Term.mkProd : name ->constr ->constr -> constr}
{$(\texttt{mkProd}\;x\;A\;B)$ represents the product $(x:A)B$.
- The free ocurrences of $x$ in $B$ are represented by deBrujin's
+ The free ocurrences of $x$ in $B$ are represented by de Bruijn's
indexes.}
\fun{val Term.mkNamedProd : identifier -> constr -> constr -> constr}
@@ -553,14 +553,14 @@ following constructor functions:
but the bound occurrences of $x$ in $B$ are denoted by
the identifier $(\texttt{mkVar}\;x)$. The function automatically
changes each occurrences of this identifier into the corresponding
- deBrujin's index.}
+ de Bruijn's index.}
\fun{val Term.mkArrow : constr -> constr -> constr}
{$(\texttt{arrow}\;A\;B)$ represents the type $(A\rightarrow B)$.}
\fun{val Term.mkLambda : name -> constr -> constr -> constr}
{$(\texttt{mkLambda}\;x\;A\;b)$ represents the lambda abstraction
- $[x:A]b$. The free ocurrences of $x$ in $B$ are represented by deBrujin's
+ $[x:A]b$. The free ocurrences of $x$ in $B$ are represented by de Bruijn's
indexes.}
\fun{val Term.mkNamedLambda : identifier -> constr -> constr -> constr}
@@ -666,7 +666,7 @@ use the primitive \textsl{Case} described in Chapter \ref{Cic}
\item Restoring type coercions and synthesizing the implicit arguments
(the one denoted by question marks in
{\Coq} syntax: see Section~\ref{Coercions}).
-\item Transforming the named bound variables into deBrujin's indexes.
+\item Transforming the named bound variables into de Bruijn's indexes.
\item Classifying the global names into the different classes of
constants (defined constants, constructors, inductive types, etc).
\end{enumerate}
diff --git a/engine/eConstr.ml b/engine/eConstr.ml
index bb9075e74a..54d3ce6cf7 100644
--- a/engine/eConstr.ml
+++ b/engine/eConstr.ml
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open CSig
open CErrors
open Util
open Names
diff --git a/engine/eConstr.mli b/engine/eConstr.mli
index 3a9469e55a..693b592fd4 100644
--- a/engine/eConstr.mli
+++ b/engine/eConstr.mli
@@ -9,7 +9,6 @@
open CSig
open Names
open Constr
-open Context
open Environ
type t
diff --git a/engine/evarutil.ml b/engine/evarutil.ml
index 1624dc93e4..e85c1f6fd8 100644
--- a/engine/evarutil.ml
+++ b/engine/evarutil.ml
@@ -10,7 +10,6 @@ open CErrors
open Util
open Names
open Term
-open Vars
open Termops
open Namegen
open Pre_env
@@ -462,7 +461,7 @@ let e_new_evar env evdref ?(src=default_source) ?filter ?candidates ?store ?nami
ev
(* This assumes an evar with identity instance and generalizes it over only
- the De Bruijn part of the context *)
+ the de Bruijn part of the context *)
let generalize_evar_over_rels sigma (ev,args) =
let open EConstr in
let evi = Evd.find sigma ev in
diff --git a/engine/evd.ml b/engine/evd.ml
index 5419a10a8e..db048bbd6e 100644
--- a/engine/evd.ml
+++ b/engine/evd.ml
@@ -14,10 +14,8 @@ open Nameops
open Term
open Vars
open Environ
-open Globnames
-open Context.Named.Declaration
-module RelDecl = Context.Rel.Declaration
+(* module RelDecl = Context.Rel.Declaration *)
module NamedDecl = Context.Named.Declaration
(** Generic filters *)
@@ -360,8 +358,6 @@ module EvMap = Evar.Map
module EvNames :
sig
-open Misctypes
-
type t
val empty : t
diff --git a/engine/proofview.ml b/engine/proofview.ml
index 9c264439be..99bd4bc4ff 100644
--- a/engine/proofview.ml
+++ b/engine/proofview.ml
@@ -858,14 +858,12 @@ let tclPROGRESS t =
let quick_test =
initial.solution == final.solution && initial.comb == final.comb
in
- let exhaustive_test =
+ let test =
+ quick_test ||
Util.List.for_all2eq begin fun i f ->
Progress.goal_equal initial.solution i final.solution f
end initial.comb final.comb
in
- let test =
- quick_test || exhaustive_test
- in
if not test then
tclUNIT res
else
@@ -1020,11 +1018,11 @@ module Goal = struct
let assume (gl : ('a, 'r) t) = (gl :> ([ `NF ], 'r) t)
- let env { env=env } = env
- let sigma { sigma=sigma } = Sigma.Unsafe.of_evar_map sigma
- let hyps { env=env } = EConstr.named_context env
- let concl { concl=concl } = concl
- let extra { sigma=sigma; self=self } = goal_extra sigma self
+ let env {env} = env
+ let sigma {sigma} = Sigma.Unsafe.of_evar_map sigma
+ let hyps {env} = EConstr.named_context env
+ let concl {concl} = concl
+ let extra {sigma; self} = goal_extra sigma self
let gmake_with info env sigma goal =
{ env = Environ.reset_with_named_context (Evd.evar_filtered_hyps info) env ;
@@ -1040,7 +1038,7 @@ module Goal = struct
let nf_enter f =
InfoL.tag (Info.Dispatch) begin
iter_goal begin fun goal ->
- Env.get >>= fun env ->
+ tclENV >>= fun env ->
tclEVARMAP >>= fun sigma ->
try
let (gl, sigma) = nf_gmake env sigma goal in
diff --git a/engine/proofview.mli b/engine/proofview.mli
index a3b0304b17..da8a8fecdd 100644
--- a/engine/proofview.mli
+++ b/engine/proofview.mli
@@ -13,7 +13,6 @@
state and returning a value of type ['a]. *)
open Util
-open Term
open EConstr
(** Main state of tactics *)
diff --git a/engine/termops.ml b/engine/termops.ml
index 64f4c6dc5e..19e62f8e62 100644
--- a/engine/termops.ml
+++ b/engine/termops.ml
@@ -612,30 +612,6 @@ let adjust_app_array_size f1 l1 f2 l2 =
let extras,restl1 = Array.chop (len1-len2) l1 in
(mkApp (f1,extras), restl1, f2, l2)
-(* [map_constr_with_named_binders g f l c] maps [f l] on the immediate
- subterms of [c]; it carries an extra data [l] (typically a name
- list) which is processed by [g na] (which typically cons [na] to
- [l]) at each binder traversal (with name [na]); it is not recursive
- and the order with which subterms are processed is not specified *)
-
-let map_constr_with_named_binders g f l c = match kind_of_term c with
- | (Rel _ | Meta _ | Var _ | Sort _ | Const _ | Ind _
- | Construct _) -> c
- | Cast (c,k,t) -> mkCast (f l c, k, f l t)
- | Prod (na,t,c) -> mkProd (na, f l t, f (g na l) c)
- | Lambda (na,t,c) -> mkLambda (na, f l t, f (g na l) c)
- | LetIn (na,b,t,c) -> mkLetIn (na, f l b, f l t, f (g na l) c)
- | App (c,al) -> mkApp (f l c, Array.map (f l) al)
- | Proj (p,c) -> mkProj (p, f l c)
- | Evar (e,al) -> mkEvar (e, Array.map (f l) al)
- | Case (ci,p,c,bl) -> mkCase (ci, f l p, f l c, Array.map (f l) bl)
- | Fix (ln,(lna,tl,bl)) ->
- let l' = Array.fold_left (fun l na -> g na l) l lna in
- mkFix (ln,(lna,Array.map (f l) tl,Array.map (f l') bl))
- | CoFix(ln,(lna,tl,bl)) ->
- let l' = Array.fold_left (fun l na -> g na l) l lna in
- mkCoFix (ln,(lna,Array.map (f l) tl,Array.map (f l') bl))
-
(* [map_constr_with_binders_left_to_right g f n c] maps [f n] on the
immediate subterms of [c]; it carries an extra data [n] (typically
a lift index) which is processed by [g] (which typically add 1 to
@@ -1451,7 +1427,6 @@ let dependency_closure env sigma sign hyps =
List.rev lh
let global_app_of_constr sigma c =
- let open Univ in
let open Globnames in
match EConstr.kind sigma c with
| Const (c, u) -> (ConstRef c, u), None
diff --git a/engine/universes.ml b/engine/universes.ml
index ad5ff827bd..1900112dde 100644
--- a/engine/universes.ml
+++ b/engine/universes.ml
@@ -13,7 +13,6 @@ open Term
open Environ
open Univ
open Globnames
-open Decl_kinds
let pr_with_global_universes l =
try Nameops.pr_id (LMap.find l (snd (Global.global_universe_names ())))
@@ -732,7 +731,7 @@ let instantiate_with_lbound u lbound lower alg enforce (ctx, us, algs, insts, cs
type constraints_map = (Univ.constraint_type * Univ.LMap.key) list Univ.LMap.t
-let pr_constraints_map cmap =
+let _pr_constraints_map (cmap:constraints_map) =
LMap.fold (fun l cstrs acc ->
Level.pr l ++ str " => " ++
prlist_with_sep spc (fun (d,r) -> pr_constraint_type d ++ Level.pr r) cstrs ++
diff --git a/engine/universes.mli b/engine/universes.mli
index 932de941a6..83ca1ea606 100644
--- a/engine/universes.mli
+++ b/engine/universes.mli
@@ -223,7 +223,7 @@ val refresh_constraints : UGraph.t -> universe_context_set -> universe_context_s
val pr_universe_opt_subst : universe_opt_subst -> Pp.std_ppcmds
-(** {6 Support for old-style sort-polymorphism } *)
+(** {6 Support for template polymorphism } *)
val solve_constraints_system : universe option array -> universe array -> universe array ->
universe array
diff --git a/grammar/argextend.mlp b/grammar/argextend.mlp
index aaf3afe436..d00ee4e5d2 100644
--- a/grammar/argextend.mlp
+++ b/grammar/argextend.mlp
@@ -11,8 +11,14 @@ open Q_util
let loc = Ploc.dummy
let default_loc = <:expr< Loc.ghost >>
+IFDEF STRICT THEN
+ let ploc_vala x = Ploc.VaVal x
+ELSE
+ let ploc_vala x = x
+END
+
let declare_str_items loc l =
- MLast.StDcl (loc, Ploc.VaVal l) (* correspond to <:str_item< declare $list:l'$ end >> *)
+ MLast.StDcl (loc, ploc_vala l) (* correspond to <:str_item< declare $list:l'$ end >> *)
let mk_extraarg loc s = <:expr< $lid:"wit_"^s$ >>
diff --git a/grammar/tacextend.mlp b/grammar/tacextend.mlp
index f57be9022f..b14fba9758 100644
--- a/grammar/tacextend.mlp
+++ b/grammar/tacextend.mlp
@@ -14,11 +14,11 @@ open Argextend
(** Quotation difference for match clauses *)
let default_patt loc =
- (<:patt< _ >>, Ploc.VaVal None, <:expr< failwith "Extension: cannot occur" >>)
+ (<:patt< _ >>, ploc_vala None, <:expr< failwith "Extension: cannot occur" >>)
let make_fun loc cl =
let l = cl @ [default_patt loc] in
- MLast.ExFun (loc, Ploc.VaVal l) (* correspond to <:expr< fun [ $list:l$ ] >> *)
+ MLast.ExFun (loc, ploc_vala l) (* correspond to <:expr< fun [ $list:l$ ] >> *)
let dloc = <:expr< Loc.ghost >>
@@ -49,7 +49,7 @@ let rec make_let raw e = function
let make_clause (pt,_,e) =
(make_patt pt,
- Ploc.VaVal None,
+ ploc_vala None,
make_let false e pt)
let make_fun_clauses loc s l =
@@ -108,7 +108,7 @@ let declare_tactic loc tacname ~level classification clause = match clause with
whole-prof tactics like [shelve_unifiable]. *)
<:expr< fun _ $lid:"ist"$ -> $tac$ >>
| _ ->
- let f = make_fun loc [patt, Ploc.VaVal None, <:expr< fun $lid:"ist"$ -> $tac$ >>] in
+ let f = make_fun loc [patt, ploc_vala None, <:expr< fun $lid:"ist"$ -> $tac$ >>] in
<:expr< Tacinterp.lift_constr_tac_to_ml_tac $vars$ $f$ >>
in
(** Arguments are not passed directly to the ML tactic in the TacML node,
@@ -129,7 +129,7 @@ let declare_tactic loc tacname ~level classification clause = match clause with
let se = <:expr< { Tacexpr.mltac_tactic = $entry$; Tacexpr.mltac_plugin = $plugin_name$ } >> in
let gl = mlexpr_of_clause clause in
let level = mlexpr_of_int level in
- let obj = <:expr< fun () -> Tacentries.add_ml_tactic_notation $se$ $level$ $gl$ >> in
+ let obj = <:expr< fun () -> Tacentries.add_ml_tactic_notation $se$ ~{ level = $level$ } $gl$ >> in
declare_str_items loc
[ <:str_item< do {
Tacenv.register_ml_tactic $se$ (Array.of_list $make_fun_clauses loc tacname clause$);
diff --git a/grammar/vernacextend.mlp b/grammar/vernacextend.mlp
index d4857b1dfa..436a7f0d98 100644
--- a/grammar/vernacextend.mlp
+++ b/grammar/vernacextend.mlp
@@ -36,7 +36,7 @@ let rec make_let e = function
let make_clause { r_patt = pt; r_branch = e; } =
(make_patt pt,
- Ploc.VaVal None,
+ ploc_vala None,
make_let e pt)
(* To avoid warnings *)
@@ -54,11 +54,11 @@ let make_clause_classifier cg s { r_patt = pt; r_class = c; } =
match c ,cg with
| Some c, _ ->
(make_patt pt,
- Ploc.VaVal None,
+ ploc_vala None,
make_let (mk_ignore c pt) pt)
| None, Some cg ->
(make_patt pt,
- Ploc.VaVal None,
+ ploc_vala None,
<:expr< fun () -> $cg$ $str:s$ >>)
| None, None -> prerr_endline
(("Vernac entry \""^s^"\" misses a classifier. "^
@@ -81,7 +81,7 @@ let make_clause_classifier cg s { r_patt = pt; r_class = c; } =
("Specific classifiers have precedence over global "^
"classifiers. Only one classifier is called.") ^ "\n");
(make_patt pt,
- Ploc.VaVal None,
+ ploc_vala None,
<:expr< fun () -> (Vernacexpr.VtUnknown, Vernacexpr.VtNow) >>)
let make_fun_clauses loc s l =
diff --git a/ide/coq.ml b/ide/coq.ml
index 3a1d877872..cd45e2fcdc 100644
--- a/ide/coq.ml
+++ b/ide/coq.ml
@@ -519,6 +519,7 @@ struct
let all_basic = ["Printing"; "All"]
let existential = ["Printing"; "Existential"; "Instances"]
let universes = ["Printing"; "Universes"]
+ let unfocused = ["Printing"; "Unfocused"]
type bool_descr = { opts : t list; init : bool; label : string }
@@ -534,7 +535,8 @@ struct
label = "Display _existential variable instances" };
{ opts = [universes]; init = false; label = "Display _universe levels" };
{ opts = [all_basic;existential;universes]; init = false;
- label = "Display all _low-level contents" }
+ label = "Display all _low-level contents" };
+ { opts = [unfocused]; init = false; label = "Display _unfocused goals" }
]
(** The current status of the boolean options *)
@@ -549,6 +551,8 @@ struct
let _ = reset ()
+ let printing_unfocused () = Hashtbl.find current_state unfocused
+
(** Transmitting options to coqtop *)
let enforce h k =
diff --git a/ide/coq.mli b/ide/coq.mli
index ab8c12a6f1..e8e2f5239e 100644
--- a/ide/coq.mli
+++ b/ide/coq.mli
@@ -140,6 +140,8 @@ sig
val set : t -> bool -> unit
+ val printing_unfocused: unit -> bool
+
(** [enforce] transmits to coq the current option values.
It is also called by [goals] and [evars] above. *)
diff --git a/ide/coqOps.ml b/ide/coqOps.ml
index 3d6a2583fe..b180aa5569 100644
--- a/ide/coqOps.ml
+++ b/ide/coqOps.ml
@@ -117,7 +117,7 @@ end = struct
(b#get_iter_at_mark s.start)#offset
(b#get_iter_at_mark s.stop)#offset
(ellipsize
- ((b#get_iter_at_mark s.start)#get_slice (b#get_iter_at_mark s.stop)))
+ ((b#get_iter_at_mark s.start)#get_slice ~stop:(b#get_iter_at_mark s.stop)))
(String.concat "," (List.map str_of_flag s.flags))
(ellipsize
(String.concat ","
@@ -128,9 +128,6 @@ end = struct
end
open SentenceId
-let log_pp msg : unit task =
- Coq.lift (fun () -> Minilib.log_pp msg)
-
let log msg : unit task =
Coq.lift (fun () -> Minilib.log msg)
@@ -207,7 +204,7 @@ object (self)
in
List.iter (fun s -> set_index s (s.index + 1)) after;
set_index s (document_length - List.length after);
- ignore ((SentenceId.connect s)#changed self#on_changed);
+ ignore ((SentenceId.connect s)#changed ~callback:self#on_changed);
document_length <- document_length + 1;
List.iter (fun f -> f `INSERT) cbs
@@ -221,8 +218,8 @@ object (self)
List.iter (fun f -> f `REMOVE) cbs
initializer
- let _ = (Doc.connect doc)#pushed self#on_push in
- let _ = (Doc.connect doc)#popped self#on_pop in
+ let _ = (Doc.connect doc)#pushed ~callback:self#on_push in
+ let _ = (Doc.connect doc)#popped ~callback:self#on_pop in
()
end
@@ -273,15 +270,15 @@ object(self)
else iter
in
let iter = sentence_start iter in
- script#buffer#place_cursor iter;
+ script#buffer#place_cursor ~where:iter;
ignore (script#scroll_to_iter ~use_align:true ~yalign:0. iter)
in
- let _ = segment#connect#clicked on_click in
+ let _ = segment#connect#clicked ~callback:on_click in
()
method private tooltip_callback ~x ~y ~kbd tooltip =
- let x, y = script#window_to_buffer_coords `WIDGET x y in
- let iter = script#get_iter_at_location x y in
+ let x, y = script#window_to_buffer_coords ~tag:`WIDGET ~x ~y in
+ let iter = script#get_iter_at_location ~x ~y in
if iter#has_tag Tags.Script.tooltip then begin
let s =
let rec aux iter =
@@ -366,6 +363,9 @@ object(self)
(* This method is intended to perform stateless commands *)
method raw_coq_query phrase =
+ let sid = try Document.tip document
+ with Document.Empty -> Stateid.initial
+ in
let action = log "raw_coq_query starting now" in
let display_error s =
if not (validate s) then
@@ -373,11 +373,10 @@ object(self)
else messages#add s;
in
let query =
- Coq.query (phrase,Stateid.dummy) in
+ Coq.query (phrase,sid) in
let next = function
| Fail (_, _, err) -> display_error err; Coq.return ()
- | Good msg ->
- messages#add_string msg; Coq.return ()
+ | Good msg -> Coq.return ()
in
Coq.bind (Coq.seq action query) next
@@ -414,16 +413,9 @@ object(self)
buffer#apply_tag Tags.Script.tooltip ~start ~stop;
add_tooltip sentence pre post markup
- method private is_dummy_id id =
- match id with
- | Edit 0 -> true
- | State id when Stateid.equal id Stateid.dummy -> true
- | _ -> false
-
method private enqueue_feedback msg =
- (* Minilib.log ("Feedback received: " ^ Xml_printer.to_string_fmt (Xmlprotocol.of_feedback msg)); *)
- let id = msg.id in
- if self#is_dummy_id id then () else Queue.add msg feedbacks
+ (* Minilib.log ("Feedback received: " ^ Xml_printer.to_string_fmt Xmlprotocol.(of_feedback Ppcmds msg)); *)
+ Queue.add msg feedbacks
method private process_feedback () =
let rec eat_feedback n =
@@ -433,46 +425,45 @@ object(self)
let sentence =
let finder _ state_id s =
match state_id, id with
- | Some id', State id when Stateid.equal id id' -> Some (state_id, s)
- | _, Edit id when id = s.edit_id -> Some (state_id, s)
+ | Some id', id when Stateid.equal id id' -> Some (state_id, s)
| _ -> None in
try Some (Doc.find_map document finder)
with Not_found -> None in
- let log_pp s state_id =
+ let log_pp ?id s=
Minilib.log_pp Pp.(seq
- [str "Feedback "; s; str " on ";
- str (Stateid.to_string (Option.default Stateid.dummy state_id))]) in
- let log s state_id = log_pp (Pp.str s) state_id in
+ [str "Feedback "; s; pr_opt (fun id -> str " on " ++ str (Stateid.to_string id)) id])
+ in
+ let log ?id s = log_pp ?id (Pp.str s) in
begin match msg.contents, sentence with
| AddedAxiom, Some (id,sentence) ->
- log "AddedAxiom" id;
+ log ?id "AddedAxiom";
remove_flag sentence `PROCESSING;
remove_flag sentence `ERROR;
add_flag sentence `UNSAFE;
self#mark_as_needed sentence
| Processed, Some (id,sentence) ->
- log "Processed" id;
+ log ?id "Processed" ;
remove_flag sentence `PROCESSING;
self#mark_as_needed sentence
| ProcessingIn _, Some (id,sentence) ->
- log "ProcessingIn" id;
+ log ?id "ProcessingIn";
add_flag sentence `PROCESSING;
self#mark_as_needed sentence
| Incomplete, Some (id, sentence) ->
- log "Incomplete" id;
+ log ?id "Incomplete";
add_flag sentence `INCOMPLETE;
self#mark_as_needed sentence
| Complete, Some (id, sentence) ->
- log "Complete" id;
+ log ?id "Complete";
remove_flag sentence `INCOMPLETE;
self#mark_as_needed sentence
| GlobRef(loc, filepath, modpath, ident, ty), Some (id,sentence) ->
- log "GlobRef" id;
+ log ?id "GlobRef";
self#attach_tooltip ~loc sentence
(Printf.sprintf "%s %s %s" filepath ident ty)
| Message(Error, loc, msg), Some (id,sentence) ->
let uloc = Option.default Loc.ghost loc in
- log_pp Pp.(str "ErrorMsg" ++ msg) id;
+ log_pp ?id Pp.(str "ErrorMsg" ++ msg);
remove_flag sentence `PROCESSING;
let rmsg = Pp.string_of_ppcmds msg in
add_flag sentence (`ERROR (uloc, rmsg));
@@ -481,32 +472,33 @@ object(self)
self#position_tag_at_sentence ?loc Tags.Script.error sentence
| Message(Warning, loc, msg), Some (id,sentence) ->
let uloc = Option.default Loc.ghost loc in
- log_pp Pp.(str "WarningMsg" ++ msg) id;
+ log_pp ?id Pp.(str "WarningMsg" ++ msg);
let rmsg = Pp.string_of_ppcmds msg in
add_flag sentence (`WARNING (uloc, rmsg));
self#attach_tooltip sentence ?loc rmsg;
self#position_tag_at_sentence ?loc Tags.Script.warning sentence;
messages#push Warning msg
| Message(lvl, loc, msg), Some (id,sentence) ->
- log_pp Pp.(str "Msg" ++ msg) id;
+ log_pp ?id Pp.(str "Msg" ++ msg);
+ messages#push lvl msg
+ | Message(lvl, loc, msg), None ->
+ log_pp Pp.(str "Msg" ++ msg);
messages#push lvl msg
| InProgress n, _ ->
if n < 0 then processed <- processed + abs n
else to_process <- to_process + n
| WorkerStatus(id,status), _ ->
- log "WorkerStatus" None;
+ log "WorkerStatus";
slaves_status <- CString.Map.add id status slaves_status
-
| _ ->
if sentence <> None then Minilib.log "Unsupported feedback message"
else if Doc.is_empty document then ()
else
try
match id, Doc.tip document with
- | Edit _, _ -> ()
- | State id1, id2 when Stateid.newer_than id2 id1 -> ()
+ | id1, id2 when Stateid.newer_than id2 id1 -> ()
| _ -> Queue.add msg feedbacks
- with Doc.Empty | Invalid_argument _ -> Queue.add msg feedbacks
+ with Doc.Empty | Invalid_argument _ -> Queue.add msg feedbacks
end;
eat_feedback (n-1)
in
diff --git a/ide/coqide.ml b/ide/coqide.ml
index 25858acced..0b7567a5ae 100644
--- a/ide/coqide.ml
+++ b/ide/coqide.ml
@@ -792,11 +792,11 @@ let coqtop_arguments sn =
sn.messages#push Feedback.Error (Pp.str msg)
else dialog#destroy ()
in
- let _ = entry#connect#activate ok_cb in
- let _ = ok#connect#clicked ok_cb in
+ let _ = entry#connect#activate ~callback:ok_cb in
+ let _ = ok#connect#clicked ~callback:ok_cb in
let cancel = GButton.button ~stock:`CANCEL ~packing:box#add () in
let cancel_cb () = dialog#destroy () in
- let _ = cancel#connect#clicked cancel_cb in
+ let _ = cancel#connect#clicked ~callback:cancel_cb in
dialog#show ()
let coqtop_arguments = cb_on_current_term coqtop_arguments
@@ -1274,8 +1274,8 @@ let build_ui () =
if b then toolbar#misc#show () else toolbar#misc#hide ()
in
stick show_toolbar toolbar refresh_toolbar;
- let _ = source_style#connect#changed refresh_style in
- let _ = source_language#connect#changed refresh_language in
+ let _ = source_style#connect#changed ~callback:refresh_style in
+ let _ = source_language#connect#changed ~callback:refresh_language in
(* Color configuration *)
Tags.Script.incomplete#set_property
diff --git a/ide/coqide_ui.ml b/ide/coqide_ui.ml
index 2ae18593ac..717c4000f5 100644
--- a/ide/coqide_ui.ml
+++ b/ide/coqide_ui.ml
@@ -28,148 +28,149 @@ let list_queries menu li =
res_buf
let init () =
- let theui = Printf.sprintf "<ui>
-<menubar name='CoqIde MenuBar'>
- <menu action='File'>
- <menuitem action='New' />
- <menuitem action='Open' />
- <menuitem action='Save' />
- <menuitem action='Save as' />
- <menuitem action='Save all' />
- <menuitem action='Revert all buffers' />
- <menuitem action='Close buffer' />
- <menuitem action='Print...' />
- <menu action='Export to'>
- <menuitem action='Html' />
- <menuitem action='Latex' />
- <menuitem action='Dvi' />
- <menuitem action='Pdf' />
- <menuitem action='Ps' />
- </menu>
- <menuitem action='Rehighlight' />
- %s
- </menu>
- <menu name='Edit' action='Edit'>
- <menuitem action='Undo' />
- <menuitem action='Redo' />
- <separator />
- <menuitem action='Cut' />
- <menuitem action='Copy' />
- <menuitem action='Paste' />
- <separator />
- <menuitem action='Find' />
- <menuitem action='Find Next' />
- <menuitem action='Find Previous' />
- <menuitem action='Complete Word' />
- <separator />
- <menuitem action='External editor' />
- <separator />
- <menuitem name='Prefs' action='Preferences' />
- </menu>
- <menu name='View' action='View'>
- <menuitem action='Previous tab' />
- <menuitem action='Next tab' />
- <separator/>
- <menuitem action='Zoom in' />
- <menuitem action='Zoom out' />
- <menuitem action='Zoom fit' />
- <separator/>
- <menuitem action='Show Toolbar' />
- <menuitem action='Query Pane' />
- <separator/>
- <menuitem action='Display implicit arguments' />
- <menuitem action='Display coercions' />
- <menuitem action='Display raw matching expressions' />
- <menuitem action='Display notations' />
- <menuitem action='Display all basic low-level contents' />
- <menuitem action='Display existential variable instances' />
- <menuitem action='Display universe levels' />
- <menuitem action='Display all low-level contents' />
- </menu>
- <menu action='Navigation'>
- <menuitem action='Forward' />
- <menuitem action='Backward' />
- <menuitem action='Go to' />
- <menuitem action='Start' />
- <menuitem action='End' />
- <menuitem action='Interrupt' />
- <menuitem action='Previous' />
- <menuitem action='Next' />
- </menu>
- <menu action='Try Tactics'>
- <menuitem action='auto' />
- <menuitem action='auto with *' />
- <menuitem action='eauto' />
- <menuitem action='eauto with *' />
- <menuitem action='intuition' />
- <menuitem action='omega' />
- <menuitem action='simpl' />
- <menuitem action='tauto' />
- <menuitem action='trivial' />
- <menuitem action='Wizard' />
- <separator />
- %s
- </menu>
- <menu action='Templates'>
- <menuitem action='Lemma' />
- <menuitem action='Theorem' />
- <menuitem action='Definition' />
- <menuitem action='Inductive' />
- <menuitem action='Fixpoint' />
- <menuitem action='Scheme' />
- <menuitem action='match' />
- <separator />
- %s
- </menu>
- <menu action='Queries'>
- <menuitem action='Search' />
- <menuitem action='Check' />
- <menuitem action='Print' />
- <menuitem action='About' />
- <menuitem action='Locate' />
- <menuitem action='Print Assumptions' />
- <separator />
- %s
- </menu>
- <menu name='Tools' action='Tools'>
- <menuitem action='Comment' />
- <menuitem action='Uncomment' />
- <separator />
- <menuitem action='Coqtop arguments' />
- </menu>
- <menu action='Compile'>
- <menuitem action='Compile buffer' />
- <menuitem action='Make' />
- <menuitem action='Next error' />
- <menuitem action='Make makefile' />
- </menu>
- <menu action='Windows'>
- <menuitem action='Detach View' />
- </menu>
- <menu name='Help' action='Help'>
- <menuitem action='Browse Coq Manual' />
- <menuitem action='Browse Coq Library' />
- <menuitem action='Help for keyword' />
- <menuitem action='Help for μPG mode' />
- <separator />
- <menuitem name='Abt' action='About Coq' />
- </menu>
-</menubar>
-<toolbar name='CoqIde ToolBar'>
- <toolitem action='Save' />
- <toolitem action='Close buffer' />
- <toolitem action='Forward' />
- <toolitem action='Backward' />
- <toolitem action='Go to' />
- <toolitem action='Start' />
- <toolitem action='End' />
- <toolitem action='Force' />
- <toolitem action='Interrupt' />
- <toolitem action='Previous' />
- <toolitem action='Next' />
- <toolitem action='Wizard' />
-</toolbar>
-</ui>"
+ let theui = Printf.sprintf "<ui>\
+\n<menubar name='CoqIde MenuBar'>\
+\n <menu action='File'>\
+\n <menuitem action='New' />\
+\n <menuitem action='Open' />\
+\n <menuitem action='Save' />\
+\n <menuitem action='Save as' />\
+\n <menuitem action='Save all' />\
+\n <menuitem action='Revert all buffers' />\
+\n <menuitem action='Close buffer' />\
+\n <menuitem action='Print...' />\
+\n <menu action='Export to'>\
+\n <menuitem action='Html' />\
+\n <menuitem action='Latex' />\
+\n <menuitem action='Dvi' />\
+\n <menuitem action='Pdf' />\
+\n <menuitem action='Ps' />\
+\n </menu>\
+\n <menuitem action='Rehighlight' />\
+\n %s\
+\n </menu>\
+\n <menu name='Edit' action='Edit'>\
+\n <menuitem action='Undo' />\
+\n <menuitem action='Redo' />\
+\n <separator />\
+\n <menuitem action='Cut' />\
+\n <menuitem action='Copy' />\
+\n <menuitem action='Paste' />\
+\n <separator />\
+\n <menuitem action='Find' />\
+\n <menuitem action='Find Next' />\
+\n <menuitem action='Find Previous' />\
+\n <menuitem action='Complete Word' />\
+\n <separator />\
+\n <menuitem action='External editor' />\
+\n <separator />\
+\n <menuitem name='Prefs' action='Preferences' />\
+\n </menu>\
+\n <menu name='View' action='View'>\
+\n <menuitem action='Previous tab' />\
+\n <menuitem action='Next tab' />\
+\n <separator/>\
+\n <menuitem action='Zoom in' />\
+\n <menuitem action='Zoom out' />\
+\n <menuitem action='Zoom fit' />\
+\n <separator/>\
+\n <menuitem action='Show Toolbar' />\
+\n <menuitem action='Query Pane' />\
+\n <separator/>\
+\n <menuitem action='Display implicit arguments' />\
+\n <menuitem action='Display coercions' />\
+\n <menuitem action='Display raw matching expressions' />\
+\n <menuitem action='Display notations' />\
+\n <menuitem action='Display all basic low-level contents' />\
+\n <menuitem action='Display existential variable instances' />\
+\n <menuitem action='Display universe levels' />\
+\n <menuitem action='Display all low-level contents' />\
+\n <menuitem action='Display unfocused goals' />\
+\n </menu>\
+\n <menu action='Navigation'>\
+\n <menuitem action='Forward' />\
+\n <menuitem action='Backward' />\
+\n <menuitem action='Go to' />\
+\n <menuitem action='Start' />\
+\n <menuitem action='End' />\
+\n <menuitem action='Interrupt' />\
+\n <menuitem action='Previous' />\
+\n <menuitem action='Next' />\
+\n </menu>\
+\n <menu action='Try Tactics'>\
+\n <menuitem action='auto' />\
+\n <menuitem action='auto with *' />\
+\n <menuitem action='eauto' />\
+\n <menuitem action='eauto with *' />\
+\n <menuitem action='intuition' />\
+\n <menuitem action='omega' />\
+\n <menuitem action='simpl' />\
+\n <menuitem action='tauto' />\
+\n <menuitem action='trivial' />\
+\n <menuitem action='Wizard' />\
+\n <separator />\
+\n %s\
+\n </menu>\
+\n <menu action='Templates'>\
+\n <menuitem action='Lemma' />\
+\n <menuitem action='Theorem' />\
+\n <menuitem action='Definition' />\
+\n <menuitem action='Inductive' />\
+\n <menuitem action='Fixpoint' />\
+\n <menuitem action='Scheme' />\
+\n <menuitem action='match' />\
+\n <separator />\
+\n %s\
+\n </menu>\
+\n <menu action='Queries'>\
+\n <menuitem action='Search' />\
+\n <menuitem action='Check' />\
+\n <menuitem action='Print' />\
+\n <menuitem action='About' />\
+\n <menuitem action='Locate' />\
+\n <menuitem action='Print Assumptions' />\
+\n <separator />\
+\n %s\
+\n </menu>\
+\n <menu name='Tools' action='Tools'>\
+\n <menuitem action='Comment' />\
+\n <menuitem action='Uncomment' />\
+\n <separator />\
+\n <menuitem action='Coqtop arguments' />\
+\n </menu>\
+\n <menu action='Compile'>\
+\n <menuitem action='Compile buffer' />\
+\n <menuitem action='Make' />\
+\n <menuitem action='Next error' />\
+\n <menuitem action='Make makefile' />\
+\n </menu>\
+\n <menu action='Windows'>\
+\n <menuitem action='Detach View' />\
+\n </menu>\
+\n <menu name='Help' action='Help'>\
+\n <menuitem action='Browse Coq Manual' />\
+\n <menuitem action='Browse Coq Library' />\
+\n <menuitem action='Help for keyword' />\
+\n <menuitem action='Help for μPG mode' />\
+\n <separator />\
+\n <menuitem name='Abt' action='About Coq' />\
+\n </menu>\
+\n</menubar>\
+\n<toolbar name='CoqIde ToolBar'>\
+\n <toolitem action='Save' />\
+\n <toolitem action='Close buffer' />\
+\n <toolitem action='Forward' />\
+\n <toolitem action='Backward' />\
+\n <toolitem action='Go to' />\
+\n <toolitem action='Start' />\
+\n <toolitem action='End' />\
+\n <toolitem action='Force' />\
+\n <toolitem action='Interrupt' />\
+\n <toolitem action='Previous' />\
+\n <toolitem action='Next' />\
+\n <toolitem action='Wizard' />\
+\n</toolbar>\
+\n</ui>"
(if Coq_config.gtk_platform <> `QUARTZ then "<menuitem action='Quit' />" else "")
(Buffer.contents (list_items "Tactic" Coq_commands.tactics))
(Buffer.contents (list_items "Template" Coq_commands.commands))
diff --git a/ide/ide_slave.ml b/ide/ide_slave.ml
index 0dfa03cca0..56ada9d132 100644
--- a/ide/ide_slave.ml
+++ b/ide/ide_slave.ml
@@ -8,6 +8,7 @@
(************************************************************************)
open Vernacexpr
+open Vernacprop
open CErrors
open Util
open Pp
@@ -53,50 +54,36 @@ let coqide_known_option table = List.mem table [
["Printing";"All"];
["Printing";"Records"];
["Printing";"Existential";"Instances"];
- ["Printing";"Universes"]]
+ ["Printing";"Universes"];
+ ["Printing";"Unfocused"]]
let is_known_option cmd = match cmd with
| VernacSetOption (o,BoolValue true)
| VernacUnsetOption o -> coqide_known_option o
| _ -> false
-let is_debug cmd = match cmd with
- | VernacSetOption (["Ltac";"Debug"], _) -> true
- | _ -> false
-
-let is_query cmd = match cmd with
- | VernacChdir None
- | VernacMemOption _
- | VernacPrintOption _
- | VernacCheckMayEval _
- | VernacGlobalCheck _
- | VernacPrint _
- | VernacSearch _
- | VernacLocate _ -> true
- | _ -> false
-
-let is_undo cmd = match cmd with
- | VernacUndo _ | VernacUndoTo _ -> true
- | _ -> false
-
(** Check whether a command is forbidden in the IDE *)
-let ide_cmd_checks (loc,ast) =
+let ide_cmd_checks ~id (loc,ast) =
let user_error s = CErrors.user_err ~loc ~hdr:"CoqIde" (str s) in
+ let warn msg = Feedback.(feedback ~id (Message (Warning, Some loc, strbrk msg))) in
if is_debug ast then
user_error "Debug mode not available in the IDE";
if is_known_option ast then
- Feedback.msg_warning (strbrk "Set this option from the IDE menu instead");
- if Vernac.is_navigation_vernac ast || is_undo ast then
- Feedback.msg_warning (strbrk "Use IDE navigation instead");
+ warn "Set this option from the IDE menu instead";
+ if is_navigation_vernac ast || is_undo ast then
+ warn "Use IDE navigation instead";
if is_query ast then
- Feedback.msg_warning (strbrk "Query commands should not be inserted in scripts")
+ warn "Query commands should not be inserted in scripts"
(** Interpretation (cf. [Ide_intf.interp]) *)
let add ((s,eid),(sid,verbose)) =
- let newid, rc = Stm.add ~ontop:sid verbose ~check:ide_cmd_checks eid s in
+ let pa = Pcoq.Gram.parsable (Stream.of_string s) in
+ let loc_ast = Stm.parse_sentence sid pa in
+ let newid, rc = Stm.add ~ontop:sid verbose loc_ast in
let rc = match rc with `NewTip -> CSig.Inl () | `Unfocus id -> CSig.Inr id in
+ ide_cmd_checks ~id:newid loc_ast;
(* TODO: the "" parameter is a leftover of the times the protocol
* used to include stderr/stdout output.
*
@@ -122,12 +109,14 @@ let edit_at id =
* as not to break the core protocol for this minor change, but it should
* be removed in the next version of the protocol.
*)
-let query (s,id) = Stm.query ~at:id s; ""
+let query (s,id) =
+ let pa = Pcoq.Gram.parsable (Stream.of_string s) in
+ Stm.query ~at:id pa; ""
let annotate phrase =
let (loc, ast) =
let pa = Pcoq.Gram.parsable (Stream.of_string phrase) in
- Vernac.parse_sentence (pa,None)
+ Stm.parse_sentence (Stm.get_current_state ()) pa
in
(* XXX: Width should be a parameter of annotate... *)
Richpp.richpp_of_pp 78 (Ppvernac.pr_vernac ast)
@@ -370,43 +359,28 @@ let init =
fun file ->
if !initialized then anomaly (str "Already initialized")
else begin
+ let init_sid = Stm.get_current_state () in
initialized := true;
match file with
- | None -> Stm.get_current_state ()
+ | None -> init_sid
| Some file ->
let dir = Filename.dirname file in
let open Loadpath in let open CUnix in
let initial_id, _ =
- if not (is_in_load_paths (physical_path_of_string dir)) then
- Stm.add false ~ontop:(Stm.get_current_state ())
- 0 (Printf.sprintf "Add LoadPath \"%s\". " dir)
- else Stm.get_current_state (), `NewTip in
+ if not (is_in_load_paths (physical_path_of_string dir)) then begin
+ let pa = Pcoq.Gram.parsable (Stream.of_string (Printf.sprintf "Add LoadPath \"%s\". " dir)) in
+ let loc_ast = Stm.parse_sentence init_sid pa in
+ Stm.add false ~ontop:init_sid loc_ast
+ end else init_sid, `NewTip in
if Filename.check_suffix file ".v" then
Stm.set_compilation_hints file;
Stm.finish ();
initial_id
end
-(* Retrocompatibility stuff *)
+(* Retrocompatibility stuff, disabled since 8.7 *)
let interp ((_raw, verbose), s) =
- let vernac_parse s =
- let pa = Pcoq.Gram.parsable (Stream.of_string s) in
- Flags.with_option Flags.we_are_parsing (fun () ->
- match Pcoq.Gram.entry_parse Pcoq.main_entry pa with
- | None -> raise (Invalid_argument "vernac_parse")
- | Some ast -> ast)
- () in
- Stm.interp verbose (vernac_parse s);
- (* TODO: the "" parameter is a leftover of the times the protocol
- * used to include stderr/stdout output.
- *
- * Currently, we force all the output meant for the to go via the
- * feedback mechanism, and we don't manipulate stderr/stdout, which
- * are left to the client's discrection. The parameter is still there
- * as not to break the core protocol for this minor change, but it should
- * be removed in the next version of the protocol.
- *)
- Stm.get_current_state (), CSig.Inl ""
+ Stateid.dummy, CSig.Inr "The interp call has been disabled, please use Add."
(** When receiving the Quit call, we don't directly do an [exit 0],
but rather set this reference, in order to send a final answer
@@ -494,9 +468,6 @@ let loop () =
let xml_ic = Xml_parser.make (Xml_parser.SLexbuf in_lb) in
let () = Xml_parser.check_eof xml_ic false in
ignore (Feedback.add_feeder (slave_feeder (!msg_format ()) xml_oc));
- (* We'll handle goal fetching and display in our own way *)
- Vernacentries.enable_goal_printing := false;
- Vernacentries.qed_display_script := false;
while not !quit do
try
let xml_query = Xml_parser.parse xml_ic in
@@ -535,12 +506,12 @@ let rec parse = function
let () = Coqtop.toploop_init := (fun args ->
let args = parse args in
- Flags.make_silent true;
+ Flags.quiet := true;
CoqworkmgrApi.(init Flags.High);
args)
let () = Coqtop.toploop_run := loop
let () = Usage.add_to_usage "coqidetop"
-" --xml_format=Ppcmds serialize pretty printing messages using the std_ppcmds format
- --help-XML-protocol print the documentation of the XML protocol used by CoqIDE\n"
+" --xml_format=Ppcmds serialize pretty printing messages using the std_ppcmds format\
+\n --help-XML-protocol print the documentation of the XML protocol used by CoqIDE\n"
diff --git a/ide/ideutils.ml b/ide/ideutils.ml
index da867e689e..a08ab07b5f 100644
--- a/ide/ideutils.ml
+++ b/ide/ideutils.ml
@@ -35,17 +35,6 @@ let flash_info =
let flash_context = status#new_context ~name:"Flash" in
(fun ?(delay=5000) s -> flash_context#flash ~delay s)
-let xml_to_string xml =
- let open Xml_datatype in
- let buf = Buffer.create 1024 in
- let rec iter = function
- | PCData s -> Buffer.add_string buf s
- | Element (_, _, children) ->
- List.iter iter children
- in
- let () = iter xml in
- Buffer.contents buf
-
let insert_with_tags (buf : #GText.buffer_skel) mark rmark tags text =
(** FIXME: LablGTK2 does not export the C insert_with_tags function, so that
it has to reimplement its own helper function. Unluckily, it relies on
@@ -58,7 +47,7 @@ let insert_with_tags (buf : #GText.buffer_skel) mark rmark tags text =
let () = buf#insert ~iter:(buf#get_iter_at_mark mark) text in
let start = buf#get_iter_at_mark mark in
let stop = buf#get_iter_at_mark rmark in
- let iter tag = buf#apply_tag tag start stop in
+ let iter tag = buf#apply_tag tag ~start ~stop in
List.iter iter tags
let insert_xml ?(mark = `INSERT) ?(tags = []) (buf : #GText.buffer_skel) msg =
diff --git a/ide/interface.mli b/ide/interface.mli
index 9ed6062588..62f63aefb9 100644
--- a/ide/interface.mli
+++ b/ide/interface.mli
@@ -111,8 +111,10 @@ type coq_info = {
(** Calls result *)
type location = (int * int) option (* start and end of the error *)
-type state_id = Feedback.state_id
-type edit_id = Feedback.edit_id
+type state_id = Stateid.t
+
+(* Obsolete *)
+type edit_id = int
(* The fail case carries the current state_id of the prover, the GUI
should probably retract to that point *)
diff --git a/ide/preferences.ml b/ide/preferences.ml
index f0fd45d77f..9fe9c6337d 100644
--- a/ide/preferences.ml
+++ b/ide/preferences.ml
@@ -73,8 +73,8 @@ end
let stick (pref : 'a preference) (obj : #GObj.widget as 'obj)
(cb : 'a -> unit) =
let _ = cb pref#get in
- let p_id = pref#connect#changed (fun v -> cb v) in
- let _ = obj#misc#connect#destroy (fun () -> pref#connect#disconnect p_id) in
+ let p_id = pref#connect#changed ~callback:(fun v -> cb v) in
+ let _ = obj#misc#connect#destroy ~callback:(fun () -> pref#connect#disconnect p_id) in
()
(** Useful marshallers *)
@@ -314,7 +314,7 @@ let attach_modifiers (pref : string preference) prefix =
in
GtkData.AccelMap.foreach change
in
- pref#connect#changed cb
+ pref#connect#changed ~callback:cb
let modifier_for_navigation =
new preference ~name:["modifier_for_navigation"] ~init:"<Control>" ~repr:Repr.(string)
@@ -360,7 +360,7 @@ object
~name:["doc_url"] ~init:Coq_config.wwwrefman ~repr:Repr.(string)
as super
- method set v =
+ method! set v =
if not (Flags.is_standard_doc_url v) &&
v <> use_default_doc_url &&
(* Extra hack to support links to last released doc version *)
@@ -408,10 +408,10 @@ let background_color =
new preference ~name:["background_color"] ~init:"cornsilk" ~repr:Repr.(string)
let attach_bg (pref : string preference) (tag : GText.tag) =
- pref#connect#changed (fun c -> tag#set_property (`BACKGROUND c))
+ pref#connect#changed ~callback:(fun c -> tag#set_property (`BACKGROUND c))
let attach_fg (pref : string preference) (tag : GText.tag) =
- pref#connect#changed (fun c -> tag#set_property (`FOREGROUND c))
+ pref#connect#changed ~callback:(fun c -> tag#set_property (`FOREGROUND c))
let processing_color =
new preference ~name:["processing_color"] ~init:"light blue" ~repr:Repr.(string)
@@ -468,7 +468,7 @@ let create_tag name default =
let iter table =
let tag = GText.tag ~name () in
table#add tag#as_tag;
- ignore (pref#connect#changed (fun _ -> set_tag tag));
+ ignore (pref#connect#changed ~callback:(fun _ -> set_tag tag));
set_tag tag;
in
List.iter iter [Tags.Script.table; Tags.Proof.table; Tags.Message.table];
@@ -601,8 +601,8 @@ object (self)
box#pack italic#coerce;
box#pack underline#coerce;
let cb but obj = obj#set_sensitive (not but#active) in
- let _ = fg_unset#connect#toggled (fun () -> cb fg_unset fg_color#misc) in
- let _ = bg_unset#connect#toggled (fun () -> cb bg_unset bg_color#misc) in
+ let _ = fg_unset#connect#toggled ~callback:(fun () -> cb fg_unset fg_color#misc) in
+ let _ = bg_unset#connect#toggled ~callback:(fun () -> cb bg_unset bg_color#misc) in
()
end
@@ -692,7 +692,7 @@ let configure ?(apply=(fun () -> ())) () =
~color:(Tags.color_of_string pref#get)
~packing:(table#attach ~left:1 ~top:i) ()
in
- let _ = button#connect#color_set begin fun () ->
+ let _ = button#connect#color_set ~callback:begin fun () ->
pref#set (Tags.string_of_color button#color)
end in
let reset _ =
@@ -754,7 +754,7 @@ let configure ?(apply=(fun () -> ())) () =
let button text (pref : bool preference) =
let active = pref#get in
let but = GButton.check_button ~label:text ~active ~packing:box#pack () in
- ignore (but#connect#toggled (fun () -> pref#set but#active))
+ ignore (but#connect#toggled ~callback:(fun () -> pref#set but#active))
in
let () = button "Dynamic word wrap" dynamic_word_wrap in
let () = button "Show line number" show_line_number in
diff --git a/ide/session.ml b/ide/session.ml
index fc6340d283..7aea75ac84 100644
--- a/ide/session.ml
+++ b/ide/session.ml
@@ -249,8 +249,8 @@ let make_table_widget ?sort cd cb =
let () = data#set_headers_visible true in
let () = data#set_headers_clickable true in
let refresh clr = data#misc#modify_base [`NORMAL, `NAME clr] in
- let _ = background_color#connect#changed refresh in
- let _ = data#misc#connect#realize (fun () -> refresh background_color#get) in
+ let _ = background_color#connect#changed ~callback:refresh in
+ let _ = data#misc#connect#realize ~callback:(fun () -> refresh background_color#get) in
let mk_rend c = GTree.cell_renderer_text [], ["text",c] in
let cols =
List.map2 (fun (_,c) (_,n,v) ->
@@ -308,8 +308,8 @@ let create_errpage (script : Wg_ScriptView.script_view) : errpage =
!callback errs;
List.iter (fun (lno, msg) -> access (fun columns store ->
let line = store#append () in
- store#set line (find_int_col "Line" columns) lno;
- store#set line (find_string_col "Error message" columns) msg))
+ store#set ~row:line ~column:(find_int_col "Line" columns) lno;
+ store#set ~row:line ~column:(find_string_col "Error message" columns) msg))
errs
end
method on_update ~callback:cb = callback := cb
@@ -348,8 +348,8 @@ let create_jobpage coqtop coqops : jobpage =
else false)
else
let line = store#append () in
- store#set line column id;
- store#set line (find_string_col "Job name" columns) job))
+ store#set ~row:line ~column id;
+ store#set ~row:line ~column:(find_string_col "Job name" columns) job))
jobs
end
method on_update ~callback:cb = callback := cb
@@ -386,12 +386,12 @@ let create file coqtop_args =
let proof = create_proof () in
let messages = create_messages () in
let segment = new Wg_Segment.segment () in
- let command = new Wg_Command.command_window basename coqtop in
let finder = new Wg_Find.finder basename (script :> GText.view) in
let fops = new FileOps.fileops (buffer :> GText.buffer) file reset in
let _ = fops#update_stats in
let cops =
new CoqOps.coqops script proof messages segment coqtop (fun () -> fops#filename) in
+ let command = new Wg_Command.command_window basename coqtop cops in
let errpage = create_errpage script in
let jobpage = create_jobpage coqtop cops in
let _ = set_buffer_handlers (buffer :> GText.buffer) script cops coqtop in
diff --git a/ide/texmacspp.ml b/ide/texmacspp.ml
index e787e48bf1..05f1820cf2 100644
--- a/ide/texmacspp.ml
+++ b/ide/texmacspp.ml
@@ -504,7 +504,6 @@ let rec tmpp v loc =
xmlApply loc (Element("timeout",["val",string_of_int s],[]) ::
[tmpp e loc])
| VernacFail e -> xmlApply loc (Element("fail",[],[]) :: [tmpp e loc])
- | VernacError _ -> xmlWithLoc loc "error" [] []
(* Syntax *)
| VernacSyntaxExtension (_, ((_, name), sml)) ->
@@ -553,7 +552,7 @@ let rec tmpp v loc =
let str_dk = Kindops.string_of_definition_kind (l, false, dk) in
let str_id = Id.to_string id in
(xmlDef str_dk str_id loc [pp_expr e])
- | VernacStartTheoremProof (tk, [ Some ((_,id),_), ([], statement, None) ], b) ->
+ | VernacStartTheoremProof (tk, [ Some ((_,id),_), ([], statement) ], b) ->
let str_tk = Kindops.string_of_theorem_kind tk in
let str_id = Id.to_string id in
(xmlThm str_tk str_id loc [pp_expr statement])
diff --git a/ide/wg_Command.ml b/ide/wg_Command.ml
index 47dad8f196..621c46b94a 100644
--- a/ide/wg_Command.ml
+++ b/ide/wg_Command.ml
@@ -8,7 +8,7 @@
open Preferences
-class command_window name coqtop =
+class command_window name coqtop coqops =
let frame = Wg_Detachable.detachable
~title:(Printf.sprintf "Query pane (%s)" name) () in
let _ = frame#hide in
@@ -26,6 +26,11 @@ object(self)
val notebook = notebook
+ (* We need access to coqops in order to place queries in the proper
+ document stint. This should remove access from this module to the
+ low-level Coq one. *)
+ val coqops = coqops
+
method pack_in (f : GObj.widget -> unit) = f frame#coerce
val mutable new_page : GObj.widget = (GMisc.label ())#coerce
@@ -86,8 +91,8 @@ object(self)
let result = GText.view ~packing:r_bin#add () in
views <- (frame#coerce, result, combo#entry) :: views;
let cb clr = result#misc#modify_base [`NORMAL, `NAME clr] in
- let _ = background_color#connect#changed cb in
- let _ = result#misc#connect#realize (fun () -> cb background_color#get) in
+ let _ = background_color#connect#changed ~callback:cb in
+ let _ = result#misc#connect#realize ~callback:(fun () -> cb background_color#get) in
let cb ft = result#misc#modify_font (Pango.Font.from_string ft) in
stick text_font result cb;
result#misc#set_can_focus true; (* false causes problems for selection *)
@@ -101,7 +106,10 @@ object(self)
else com ^ " " ^ arg ^" . "
in
let process =
- Coq.bind (Coq.query (phrase,Stateid.dummy)) (function
+ (* We need to adapt this to route_id and redirect to the result buffer below *)
+ coqops#raw_coq_query phrase
+ (*
+ Coq.bind (Coq.query (phrase,sid)) (function
| Interface.Fail (_,l,str) ->
let width = Ideutils.textview_width result in
Ideutils.insert_xml result#buffer (Richpp.richpp_of_pp width str);
@@ -111,6 +119,7 @@ object(self)
result#buffer#insert res;
notebook#set_page ~tab_label:(new_tab_lbl arg) frame#coerce;
Coq.return ())
+ *)
in
result#buffer#set_text ("Result for command " ^ phrase ^ ":\n");
Coq.try_grab coqtop process ignore
@@ -156,7 +165,7 @@ object(self)
self#new_page_maker;
self#new_query_aux ~grab_now:false ();
frame#misc#hide ();
- let _ = background_color#connect#changed self#refresh_color in
+ let _ = background_color#connect#changed ~callback:self#refresh_color in
self#refresh_color background_color#get;
ignore(notebook#event#connect#key_press ~callback:(fun ev ->
if GdkEvent.Key.keyval ev = GdkKeysyms._Escape then (self#hide; true)
diff --git a/ide/wg_Command.mli b/ide/wg_Command.mli
index fa50ba5fdd..341322be1b 100644
--- a/ide/wg_Command.mli
+++ b/ide/wg_Command.mli
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-class command_window : string -> Coq.coqtop ->
+class command_window : string -> Coq.coqtop -> CoqOps.coqops ->
object
method new_query : ?command:string -> ?term:string -> unit -> unit
method pack_in : (GObj.widget -> unit) -> unit
diff --git a/ide/wg_Completion.ml b/ide/wg_Completion.ml
index aeae3e1fdb..3bb6b780e6 100644
--- a/ide/wg_Completion.ml
+++ b/ide/wg_Completion.ml
@@ -154,7 +154,7 @@ object (self)
let () = store#clear () in
let iter prop =
let iter = store#append () in
- store#set iter column prop
+ store#set ~row:iter ~column prop
in
let () = current_completion <- (pref, props) in
Proposals.iter iter props
@@ -267,7 +267,7 @@ object (self)
(** Position of view w.r.t. window *)
let (ux, uy) = Gdk.Window.get_position view#misc#window in
(** Relative buffer position to view *)
- let (dx, dy) = view#window_to_buffer_coords `WIDGET 0 0 in
+ let (dx, dy) = view#window_to_buffer_coords ~tag:`WIDGET ~x:0 ~y:0 in
(** Iter position *)
let iter = view#buffer#get_iter pos in
let coords = view#get_iter_location iter in
@@ -397,11 +397,11 @@ object (self)
let () = self#select_first () in
let () = obj#misc#show () in
let () = self#manage_scrollbar () in
- obj#resize 1 1
+ obj#resize ~width:1 ~height:1
method private start_callback off =
let (x, y, w, h) = self#coordinates (`OFFSET off) in
- let () = obj#move x (y + 3 * h / 2) in
+ let () = obj#move ~x ~y:(y + 3 * h / 2) in
()
method private update_callback (off, word, props) =
@@ -433,21 +433,21 @@ object (self)
else false
in
(** Style handling *)
- let _ = view#misc#connect#style_set self#refresh_style in
+ let _ = view#misc#connect#style_set ~callback:self#refresh_style in
let _ = self#refresh_style () in
let _ = data#set_resize_mode `PARENT in
let _ = frame#set_resize_mode `PARENT in
(** Callback to model *)
- let _ = model#connect#start_completion self#start_callback in
- let _ = model#connect#update_completion self#update_callback in
- let _ = model#connect#end_completion self#end_callback in
+ let _ = model#connect#start_completion ~callback:self#start_callback in
+ let _ = model#connect#update_completion ~callback:self#update_callback in
+ let _ = model#connect#end_completion ~callback:self#end_callback in
(** Popup interaction *)
- let _ = view#event#connect#key_press key_cb in
+ let _ = view#event#connect#key_press ~callback:key_cb in
(** Hiding the popup when necessary*)
- let _ = view#misc#connect#hide obj#misc#hide in
- let _ = view#event#connect#button_press (fun _ -> self#hide (); false) in
- let _ = view#connect#move_cursor move_cb in
- let _ = view#event#connect#focus_out (fun _ -> self#hide (); false) in
+ let _ = view#misc#connect#hide ~callback:obj#misc#hide in
+ let _ = view#event#connect#button_press ~callback:(fun _ -> self#hide (); false) in
+ let _ = view#connect#move_cursor ~callback:move_cb in
+ let _ = view#event#connect#focus_out ~callback:(fun _ -> self#hide (); false) in
()
end
diff --git a/ide/wg_Detachable.ml b/ide/wg_Detachable.ml
index 3d1b63dfae..cbc34462e2 100644
--- a/ide/wg_Detachable.ml
+++ b/ide/wg_Detachable.ml
@@ -26,8 +26,8 @@ class detachable (obj : ([> Gtk.box] as 'a) Gobject.obj) =
val mutable attached_cb = (fun _ -> ())
method child = frame#child
- method add = frame#add
- method pack ?from ?expand ?fill ?padding w =
+ method! add = frame#add
+ method! pack ?from ?expand ?fill ?padding w =
if frame#all_children = [] then self#add w
else raise (Invalid_argument "detachable#pack")
diff --git a/ide/wg_Find.ml b/ide/wg_Find.ml
index 3d847ddcc1..f84b9063bf 100644
--- a/ide/wg_Find.ml
+++ b/ide/wg_Find.ml
@@ -186,8 +186,8 @@ class finder name (view : GText.view) =
in
let find_cb = generic_cb self#hide self#find_forward in
let replace_cb = generic_cb self#hide self#replace in
- let _ = find_entry#event#connect#key_press find_cb in
- let _ = replace_entry#event#connect#key_press replace_cb in
+ let _ = find_entry#event#connect#key_press ~callback:find_cb in
+ let _ = replace_entry#event#connect#key_press ~callback:replace_cb in
(** TextView interaction *)
let view_cb ev =
@@ -197,7 +197,7 @@ class finder name (view : GText.view) =
else false
else false
in
- let _ = view#event#connect#key_press view_cb in
+ let _ = view#event#connect#key_press ~callback:view_cb in
()
end
diff --git a/ide/wg_Notebook.ml b/ide/wg_Notebook.ml
index 08d7d19833..0e5284c2f9 100644
--- a/ide/wg_Notebook.ml
+++ b/ide/wg_Notebook.ml
@@ -50,7 +50,7 @@ object(self)
method pages = term_list
- method remove_page index =
+ method! remove_page index =
term_list <- Util.List.filteri (fun i x -> if i = index then kill_page x; i <> index) term_list;
super#remove_page index
diff --git a/ide/wg_ProofView.ml b/ide/wg_ProofView.ml
index 3cbe583881..0bf5afbfdb 100644
--- a/ide/wg_ProofView.ml
+++ b/ide/wg_ProofView.ml
@@ -47,7 +47,7 @@ let hook_tag_cb tag menu_content sel_cb hover_cb =
hover_cb start stop; false
| _ -> false))
-let mode_tactic sel_cb (proof : #GText.view_skel) goals hints = match goals with
+let mode_tactic sel_cb (proof : #GText.view_skel) goals ~unfoc_goals hints = match goals with
| [] -> assert false
| { Interface.goal_hyp = hyps; Interface.goal_ccl = cur_goal; } :: rem_goals ->
let on_hover sel_start sel_stop =
@@ -65,8 +65,11 @@ let mode_tactic sel_cb (proof : #GText.view_skel) goals hints = match goals with
let head_str = Printf.sprintf
"%d subgoal%s\n" goals_cnt (if 1 < goals_cnt then "s" else "")
in
- let goal_str index total = Printf.sprintf
- "______________________________________(%d/%d)\n" index total
+ let goal_str ?(shownum=false) index total =
+ if shownum then Printf.sprintf
+ "______________________________________(%d/%d)\n" index total
+ else Printf.sprintf
+ "______________________________________\n"
in
(* Insert current goal and its hypotheses *)
let hyps_hints, goal_hints = match hints with
@@ -97,18 +100,29 @@ let mode_tactic sel_cb (proof : #GText.view_skel) goals hints = match goals with
[tag]
else []
in
- proof#buffer#insert (goal_str 1 goals_cnt);
+ proof#buffer#insert (goal_str ~shownum:true 1 goals_cnt);
insert_xml proof#buffer (Richpp.richpp_of_pp width cur_goal);
proof#buffer#insert "\n"
in
(* Insert remaining goals (no hypotheses) *)
- let fold_goal i _ { Interface.goal_ccl = g } =
- proof#buffer#insert (goal_str i goals_cnt);
+ let fold_goal ?(shownum=false) i _ { Interface.goal_ccl = g } =
+ proof#buffer#insert (goal_str ~shownum i goals_cnt);
insert_xml proof#buffer (Richpp.richpp_of_pp width g);
proof#buffer#insert "\n"
in
- let () = Util.List.fold_left_i fold_goal 2 () rem_goals in
-
+ let () = Util.List.fold_left_i (fold_goal ~shownum:true) 2 () rem_goals in
+ (* show unfocused goal if option set *)
+ (* Insert remaining goals (no hypotheses) *)
+ if Coq.PrintOpt.printing_unfocused () then
+ begin
+ ignore(proof#buffer#place_cursor ~where:(proof#buffer#end_iter));
+ let unfoc = List.flatten (List.rev (List.map (fun (x,y) -> x@y) unfoc_goals)) in
+ if unfoc<>[] then
+ begin
+ proof#buffer#insert "\nUnfocused Goals:\n";
+ Util.List.fold_left_i (fold_goal ~shownum:false) 0 () unfoc
+ end
+ end;
ignore(proof#buffer#place_cursor
~where:(proof#buffer#end_iter#backward_to_tag_toggle
(Some Tags.Proof.goal)));
@@ -172,8 +186,9 @@ let display mode (view : #GText.view_skel) goals hints evars =
in
List.iteri iter bg
end
- | Some { Interface.fg_goals = fg } ->
- mode view fg hints
+ | Some { Interface.fg_goals = fg; bg_goals = bg } ->
+ mode view fg ~unfoc_goals:bg hints
+
let proof_view () =
let buffer = GSourceView2.source_buffer
@@ -188,8 +203,8 @@ let proof_view () =
let default_clipboard = GData.clipboard Gdk.Atom.primary in
let _ = buffer#add_selection_clipboard default_clipboard in
let cb clr = view#misc#modify_base [`NORMAL, `NAME clr] in
- let _ = background_color#connect#changed cb in
- let _ = view#misc#connect#realize (fun () -> cb background_color#get) in
+ let _ = background_color#connect#changed ~callback:cb in
+ let _ = view#misc#connect#realize ~callback:(fun () -> cb background_color#get) in
let cb ft = view#misc#modify_font (Pango.Font.from_string ft) in
stick text_font view cb;
@@ -226,5 +241,5 @@ let proof_view () =
(* Is there a better way to connect the signal ? *)
(* Can this be done in the object constructor? *)
let w_cb _ = pf#refresh ~force:false in
- ignore (view#misc#connect#size_allocate w_cb);
+ ignore (view#misc#connect#size_allocate ~callback:w_cb);
pf
diff --git a/ide/wg_ScriptView.ml b/ide/wg_ScriptView.ml
index 218cedb363..7430f07d47 100644
--- a/ide/wg_ScriptView.ml
+++ b/ide/wg_ScriptView.ml
@@ -301,28 +301,28 @@ object (self)
~use_align:false ~yalign:0.75 ~within_margin:0.25 `INSERT
(* HACK: missing gtksourceview features *)
- method right_margin_position =
+ method! right_margin_position =
let prop = {
Gobject.name = "right-margin-position";
conv = Gobject.Data.int;
} in
Gobject.get prop obj
- method set_right_margin_position pos =
+ method! set_right_margin_position pos =
let prop = {
Gobject.name = "right-margin-position";
conv = Gobject.Data.int;
} in
Gobject.set prop obj pos
- method show_right_margin =
+ method! show_right_margin =
let prop = {
Gobject.name = "show-right-margin";
conv = Gobject.Data.boolean;
} in
Gobject.get prop obj
- method set_show_right_margin show =
+ method! set_show_right_margin show =
let prop = {
Gobject.name = "show-right-margin";
conv = Gobject.Data.boolean;
@@ -460,8 +460,8 @@ object (self)
let _ = GtkSignal.connect ~sgn:move_line_signal ~callback obj in
(** Plug on preferences *)
let cb clr = self#misc#modify_base [`NORMAL, `NAME clr] in
- let _ = background_color#connect#changed cb in
- let _ = self#misc#connect#realize (fun () -> cb background_color#get) in
+ let _ = background_color#connect#changed ~callback:cb in
+ let _ = self#misc#connect#realize ~callback:(fun () -> cb background_color#get) in
let cb b = self#set_wrap_mode (if b then `WORD else `NONE) in
stick dynamic_word_wrap self cb;
diff --git a/ide/wg_Segment.ml b/ide/wg_Segment.ml
index dbc1740ef6..d527a0d13a 100644
--- a/ide/wg_Segment.ml
+++ b/ide/wg_Segment.ml
@@ -75,7 +75,7 @@ object (self)
self#redraw ();
end
in
- let _ = box#misc#connect#size_allocate cb in
+ let _ = box#misc#connect#size_allocate ~callback:cb in
let clicked_cb ev = match model with
| None -> true
| Some md ->
@@ -86,7 +86,7 @@ object (self)
let () = clicked#call idx in
true
in
- let _ = eventbox#event#connect#button_press clicked_cb in
+ let _ = eventbox#event#connect#button_press ~callback:clicked_cb in
let cb show = if show then self#misc#show () else self#misc#hide () in
stick show_progress_bar self cb;
(** Initial pixmap *)
@@ -102,7 +102,7 @@ object (self)
| `SET (i, color) ->
if self#misc#visible then self#fill_range color i (i + 1)
in
- md#changed changed_cb
+ md#changed ~callback:changed_cb
method private fill_range color i j = match model with
| None -> ()
diff --git a/ide/xmlprotocol.ml b/ide/xmlprotocol.ml
index d7950e5fd5..bf52b0b52b 100644
--- a/ide/xmlprotocol.ml
+++ b/ide/xmlprotocol.ml
@@ -907,9 +907,7 @@ let of_feedback_content = function
of_string filename ]
| Message (l,loc,m) -> constructor "feedback_content" "message" [ of_message l loc m ]
-let of_edit_or_state_id = function
- | Edit id -> ["object","edit"], of_edit_id id
- | State id -> ["object","state"], of_stateid id
+let of_edit_or_state_id id = ["object","state"], of_stateid id
let of_feedback msg =
let content = of_feedback_content msg.contents in
@@ -921,12 +919,8 @@ let of_feedback msg_fmt =
msg_format := msg_fmt; of_feedback
let to_feedback xml = match xml with
- | Element ("feedback", ["object","edit";"route",route], [id;content]) -> {
- id = Edit(to_edit_id id);
- route = int_of_string route;
- contents = to_feedback_content content }
| Element ("feedback", ["object","state";"route",route], [id;content]) -> {
- id = State(to_stateid id);
+ id = to_stateid id;
route = int_of_string route;
contents = to_feedback_content content }
| x -> raise (Marshal_error("feedback",x))
diff --git a/interp/constrexpr_ops.ml b/interp/constrexpr_ops.ml
index 53c97f6b6b..a592b4cff8 100644
--- a/interp/constrexpr_ops.ml
+++ b/interp/constrexpr_ops.ml
@@ -303,83 +303,51 @@ let add_name_in_env env n =
let (fresh_var, fresh_var_hook) = Hook.make ~default:(fun _ _ -> assert false) ()
-let expand_pattern_binders mkC bl c =
- let rec loop bl c =
+let expand_binders mkC loc bl c =
+ let rec loop loc bl c =
match bl with
- | [] -> ([], [], c)
+ | [] -> ([], c)
| b :: bl ->
- let (env, bl, c) = loop bl c in
match b with
- | CLocalDef (n, _, _) ->
+ | CLocalDef ((loc1,_) as n, oty, b) ->
+ let env, c = loop (Loc.merge loc1 loc) bl c in
let env = add_name_in_env env n in
- (env, b :: bl, c)
- | CLocalAssum (nl, _, _) ->
+ (env, CLetIn (loc,n,oty,b,c))
+ | CLocalAssum ((loc1,_)::_ as nl, bk, t) ->
+ let env, c = loop (Loc.merge loc1 loc) bl c in
let env = List.fold_left add_name_in_env env nl in
- (env, b :: bl, c)
- | CLocalPattern (loc, p, ty) ->
+ (env, mkC loc (nl,bk,t) c)
+ | CLocalAssum ([],_,_) -> loop loc bl c
+ | CLocalPattern (loc1, p, ty) ->
+ let env, c = loop (Loc.merge loc1 loc) bl c in
let ni = Hook.get fresh_var env c in
- let id = (loc, Name ni) in
- let b =
- CLocalAssum
- ([id], Default Explicit,
- match ty with
+ let id = (loc1, Name ni) in
+ let ty = match ty with
| Some ty -> ty
- | None -> CHole (loc, None, IntroAnonymous, None))
+ | None -> CHole (loc1, None, IntroAnonymous, None)
in
- let e = CRef (Libnames.Ident (loc, ni), None) in
+ let e = CRef (Libnames.Ident (loc1, ni), None) in
let c =
CCases
(loc, LetPatternStyle, None, [(e,None,None)],
- [(loc, [(loc,[p])], mkC loc bl c)])
+ [(loc1, [(loc1,[p])], c)])
in
- (ni :: env, [b], c)
+ (ni :: env, mkC loc ([id],Default Explicit,ty) c)
in
- let (_, bl, c) = loop bl c in
- (bl, c)
+ let (_, c) = loop loc bl c in
+ c
let mkCProdN loc bll c =
- let rec loop loc bll c =
- match bll with
- | CLocalAssum ((loc1,_)::_ as idl,bk,t) :: bll ->
- CProdN (loc,[idl,bk,t],loop (Loc.merge loc1 loc) bll c)
- | CLocalDef ((loc1,_) as id,b,t) :: bll ->
- CLetIn (loc,id,b,t,loop (Loc.merge loc1 loc) bll c)
- | [] -> c
- | CLocalAssum ([],_,_) :: bll -> loop loc bll c
- | CLocalPattern (loc,p,ty) :: bll -> assert false
- in
- let (bll, c) = expand_pattern_binders loop bll c in
- loop loc bll c
+ let mk loc b c = CProdN (loc,[b],c) in
+ expand_binders mk loc bll c
let mkCLambdaN loc bll c =
- let rec loop loc bll c =
- match bll with
- | CLocalAssum ((loc1,_)::_ as idl,bk,t) :: bll ->
- CLambdaN (loc,[idl,bk,t],loop (Loc.merge loc1 loc) bll c)
- | CLocalDef ((loc1,_) as id,b,t) :: bll ->
- CLetIn (loc,id,b,t,loop (Loc.merge loc1 loc) bll c)
- | [] -> c
- | CLocalAssum ([],_,_) :: bll -> loop loc bll c
- | CLocalPattern (loc,p,ty) :: bll -> assert false
- in
- let (bll, c) = expand_pattern_binders loop bll c in
- loop loc bll c
-
-let rec abstract_constr_expr c = function
- | [] -> c
- | CLocalDef (x,b,t)::bl -> mkLetInC(x,b,t,abstract_constr_expr c bl)
- | CLocalAssum (idl,bk,t)::bl ->
- List.fold_right (fun x b -> mkLambdaC([x],bk,t,b)) idl
- (abstract_constr_expr c bl)
- | CLocalPattern _::_ -> assert false
-
-let rec prod_constr_expr c = function
- | [] -> c
- | CLocalDef (x,b,t)::bl -> mkLetInC(x,b,t,prod_constr_expr c bl)
- | CLocalAssum (idl,bk,t)::bl ->
- List.fold_right (fun x b -> mkProdC([x],bk,t,b)) idl
- (prod_constr_expr c bl)
- | CLocalPattern _::_ -> assert false
+ let mk loc b c = CLambdaN (loc,[b],c) in
+ expand_binders mk loc bll c
+
+(* Deprecated *)
+let abstract_constr_expr c bl = mkCLambdaN (local_binders_loc bl) bl c
+let prod_constr_expr c bl = mkCProdN (local_binders_loc bl) bl c
let coerce_reference_to_id = function
| Ident (_,id) -> id
diff --git a/interp/constrexpr_ops.mli b/interp/constrexpr_ops.mli
index 45e3a19bc8..f6d97e107d 100644
--- a/interp/constrexpr_ops.mli
+++ b/interp/constrexpr_ops.mli
@@ -49,19 +49,19 @@ val mkLambdaC : Name.t located list * binder_kind * constr_expr * constr_expr ->
val mkLetInC : Name.t located * constr_expr * constr_expr option * constr_expr -> constr_expr
val mkProdC : Name.t located list * binder_kind * constr_expr * constr_expr -> constr_expr
-val abstract_constr_expr : constr_expr -> local_binder_expr list -> constr_expr
-val prod_constr_expr : constr_expr -> local_binder_expr list -> constr_expr
-
val mkCLambdaN : Loc.t -> local_binder_expr list -> constr_expr -> constr_expr
(** Same as [abstract_constr_expr], with location *)
val mkCProdN : Loc.t -> local_binder_expr list -> constr_expr -> constr_expr
(** Same as [prod_constr_expr], with location *)
+(** @deprecated variant of mkCLambdaN *)
+val abstract_constr_expr : constr_expr -> local_binder_expr list -> constr_expr
+
+(** @deprecated variant of mkCProdN *)
+val prod_constr_expr : constr_expr -> local_binder_expr list -> constr_expr
+
val fresh_var_hook : (Names.Id.t list -> Constrexpr.constr_expr -> Names.Id.t) Hook.t
-val expand_pattern_binders :
- (Loc.t -> local_binder_expr list -> constr_expr -> constr_expr) ->
- local_binder_expr list -> constr_expr -> local_binder_expr list * constr_expr
(** {6 Destructors}*)
diff --git a/interp/constrextern.ml b/interp/constrextern.ml
index f272d219aa..59b8b4e5b9 100644
--- a/interp/constrextern.ml
+++ b/interp/constrextern.ml
@@ -85,6 +85,20 @@ let without_specific_symbols l f =
(**********************************************************************)
(* Control printing of records *)
+(* Set Record Printing flag *)
+let record_print = ref true
+
+let _ =
+ let open Goptions in
+ declare_bool_option
+ { optsync = true;
+ optdepr = false;
+ optname = "record printing";
+ optkey = ["Printing";"Records"];
+ optread = (fun () -> !record_print);
+ optwrite = (fun b -> record_print := b) }
+
+
let is_record indsp =
try
let _ = Recordops.lookup_structure indsp in
@@ -658,7 +672,7 @@ let rec extern inctx scopes vars r =
()
else if PrintingConstructor.active (fst cstrsp) then
raise Exit
- else if not !Flags.record_print then
+ else if not !record_print then
raise Exit;
let projs = struc.Recordops.s_PROJ in
let locals = struc.Recordops.s_PROJKIND in
diff --git a/interp/constrintern.ml b/interp/constrintern.ml
index d75487ecf3..3f99a3c7c0 100644
--- a/interp/constrintern.ml
+++ b/interp/constrintern.ml
@@ -855,9 +855,9 @@ let intern_qualid loc qid intern env lvar us args =
| Some _, GApp (loc, GRef (loc', ref, None), arg) ->
GApp (loc, GRef (loc', ref, us), arg)
| Some _, _ ->
- user_err ~loc (str "Notation " ++ pr_qualid qid ++
- str " cannot have a universe instance, its expanded head
- does not start with a reference")
+ user_err ~loc (str "Notation " ++ pr_qualid qid
+ ++ str " cannot have a universe instance,"
+ ++ str " its expanded head does not start with a reference")
in
c, projapp, args2
@@ -2045,8 +2045,6 @@ let interp_binder_evars env evdref na t =
let t' = locate_if_hole (loc_of_glob_constr t) na t in
understand_tcc_evars env evdref ~expected_type:IsType t'
-open Environ
-
let my_intern_constr env lvar acc c =
internalize env acc false lvar c
diff --git a/interp/constrintern.mli b/interp/constrintern.mli
index 758d4e650b..fdd50c6a1e 100644
--- a/interp/constrintern.mli
+++ b/interp/constrintern.mli
@@ -18,7 +18,6 @@ open Constrexpr
open Notation_term
open Pretyping
open Misctypes
-open Decl_kinds
(** Translation from front abstract syntax of term to untyped terms (glob_constr) *)
diff --git a/interp/coqlib.mli b/interp/coqlib.mli
index 5ba26d8286..1facb47e1e 100644
--- a/interp/coqlib.mli
+++ b/interp/coqlib.mli
@@ -19,7 +19,7 @@ open Util
(** [find_reference caller_message [dir;subdir;...] s] returns a global
reference to the name dir.subdir.(...).s; the corresponding module
must have been required or in the process of being compiled so that
- it must be used lazyly; it raises an anomaly with the given message
+ it must be used lazily; it raises an anomaly with the given message
if not found *)
type message = string
diff --git a/interp/notation.ml b/interp/notation.ml
index 90ac7f7296..6aa6f54c05 100644
--- a/interp/notation.ml
+++ b/interp/notation.ml
@@ -22,7 +22,6 @@ open Glob_ops
open Ppextend
open Context.Named.Declaration
-module NamedDecl = Context.Named.Declaration
(*i*)
(*s A scope is a set of notations; it includes
diff --git a/interp/notation_ops.ml b/interp/notation_ops.ml
index 8b4fadb5a0..d08fb107be 100644
--- a/interp/notation_ops.ml
+++ b/interp/notation_ops.ml
@@ -1141,10 +1141,6 @@ let term_of_binder = function
| Name id -> GVar (Loc.ghost,id)
| Anonymous -> GHole (Loc.ghost,Evar_kinds.InternalHole,Misctypes.IntroAnonymous,None)
-type glob_decl2 =
- (name, cases_pattern) Util.union * Decl_kinds.binding_kind *
- glob_constr option * glob_constr
-
let match_notation_constr u c (metas,pat) =
let terms,binders,termlists,binderlists =
match_ false u ([],[]) metas ([],[],[],[]) c pat in
diff --git a/interp/stdarg.ml b/interp/stdarg.ml
index 341ff5662c..5920b0d508 100644
--- a/interp/stdarg.ml
+++ b/interp/stdarg.ml
@@ -6,9 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Loc
open Misctypes
-open Tactypes
open Genarg
open Geninterp
diff --git a/interp/stdarg.mli b/interp/stdarg.mli
index 113fe40ba7..ac40a23281 100644
--- a/interp/stdarg.mli
+++ b/interp/stdarg.mli
@@ -10,7 +10,6 @@
open Loc
open Names
-open Term
open EConstr
open Libnames
open Globnames
diff --git a/interp/syntax_def.ml b/interp/syntax_def.ml
index c3f4c4f302..ed7b0b70d4 100644
--- a/interp/syntax_def.ml
+++ b/interp/syntax_def.ml
@@ -106,5 +106,3 @@ let search_syntactic_definition kn =
let def = out_pat pat in
verbose_compat kn def v;
def
-
-open Goptions
diff --git a/interp/topconstr.ml b/interp/topconstr.ml
index 89e04b69d2..e05be65fb0 100644
--- a/interp/topconstr.ml
+++ b/interp/topconstr.ml
@@ -58,7 +58,9 @@ let rec cases_pattern_fold_names f a = function
| CPatDelimiters (_,_,pat) -> cases_pattern_fold_names f a pat
| CPatAtom (_,Some (Ident (_,id))) when not (is_constructor id) -> f id a
| CPatPrim _ | CPatAtom _ -> a
- | CPatCast _ -> assert false
+ | CPatCast (loc,_,_) ->
+ CErrors.user_err ~loc ~hdr:"cases_pattern_fold_names"
+ (Pp.strbrk "Casts are not supported here.")
let ids_of_pattern =
cases_pattern_fold_names Id.Set.add Id.Set.empty
@@ -176,7 +178,12 @@ let split_at_annot bl na =
in
(List.rev ans, CLocalAssum (r, k, t) :: rest)
end
- | CLocalDef _ as x :: rest -> aux (x :: acc) rest
+ | CLocalDef ((_,na),_,_) as x :: rest ->
+ if Name.equal (Name id) na then
+ user_err ~loc
+ (Nameops.pr_id id ++ str" must be a proper parameter and not a local definition.")
+ else
+ aux (x :: acc) rest
| CLocalPattern (loc,_,_) :: rest ->
Loc.raise ~loc (Stream.Error "pattern with quote not allowed after fix")
| [] ->
diff --git a/intf/constrexpr.mli b/intf/constrexpr.mli
index 49bafadc8e..a4a6eb9092 100644
--- a/intf/constrexpr.mli
+++ b/intf/constrexpr.mli
@@ -19,7 +19,7 @@ open Decl_kinds
type notation = string
type explicitation =
- | ExplByPos of int * Id.t option
+ | ExplByPos of int * Id.t option (* a reference to the n-th product starting from left *)
| ExplByName of Id.t
type binder_kind =
diff --git a/intf/misctypes.mli b/intf/misctypes.mli
index 33dc2a335c..7c2dc5177c 100644
--- a/intf/misctypes.mli
+++ b/intf/misctypes.mli
@@ -48,8 +48,8 @@ type 'a glob_sort_gen =
| GProp (** representation of [Prop] literal *)
| GSet (** representation of [Set] literal *)
| GType of 'a (** representation of [Type] literal *)
-type sort_info = string Loc.located list
-type level_info = string Loc.located option
+type sort_info = Name.t Loc.located list
+type level_info = Name.t Loc.located option
type glob_sort = sort_info glob_sort_gen
type glob_level = level_info glob_sort_gen
diff --git a/intf/tactypes.mli b/intf/tactypes.mli
index 02cfc44e29..ef90b911c5 100644
--- a/intf/tactypes.mli
+++ b/intf/tactypes.mli
@@ -13,7 +13,6 @@
open Loc
open Names
open Constrexpr
-open Glob_term
open Pattern
open Misctypes
diff --git a/intf/vernacexpr.mli b/intf/vernacexpr.mli
index 25d3c705f4..cb093d85d5 100644
--- a/intf/vernacexpr.mli
+++ b/intf/vernacexpr.mli
@@ -71,7 +71,7 @@ type printable =
| PrintScopes
| PrintScope of string
| PrintVisibility of string option
- | PrintAbout of reference or_by_notation*int option
+ | PrintAbout of reference or_by_notation * goal_selector option
| PrintImplicit of reference or_by_notation
| PrintAssumptions of bool * bool * reference or_by_notation
| PrintStrategy of reference or_by_notation option
@@ -209,7 +209,7 @@ type one_inductive_expr =
plident * local_binder_expr list * constr_expr option * constructor_expr list
type proof_expr =
- plident option * (local_binder_expr list * constr_expr * (lident option * recursion_order_expr) option)
+ plident option * (local_binder_expr list * constr_expr)
type syntax_modifier =
| SetItemLevel of string list * Extend.production_level
@@ -316,7 +316,6 @@ type vernac_expr =
| VernacRedirect of string * vernac_expr located
| VernacTimeout of int * vernac_expr
| VernacFail of vernac_expr
- | VernacError of exn (* always fails *)
(* Syntax *)
| VernacSyntaxExtension of
@@ -436,11 +435,11 @@ type vernac_expr =
| VernacRemoveOption of Goptions.option_name * option_ref_value list
| VernacMemOption of Goptions.option_name * option_ref_value list
| VernacPrintOption of Goptions.option_name
- | VernacCheckMayEval of Genredexpr.raw_red_expr option * int option * constr_expr
+ | VernacCheckMayEval of Genredexpr.raw_red_expr option * goal_selector option * constr_expr
| VernacGlobalCheck of constr_expr
| VernacDeclareReduction of string * Genredexpr.raw_red_expr
| VernacPrint of printable
- | VernacSearch of searchable * int option * search_restriction
+ | VernacSearch of searchable * goal_selector option * search_restriction
| VernacLocate of locatable
| VernacRegister of lident * register_kind
| VernacComments of comment list
diff --git a/kernel/constr.ml b/kernel/constr.ml
index 5a7561bf50..eecceb32a7 100644
--- a/kernel/constr.ml
+++ b/kernel/constr.ml
@@ -107,7 +107,16 @@ type constr = t
type existential = existential_key * constr array
type rec_declaration = Name.t array * constr array * constr array
type fixpoint = (int array * int) * rec_declaration
+ (* The array of [int]'s tells for each component of the array of
+ mutual fixpoints the number of lambdas to skip before finding the
+ recursive argument (e.g., value is 2 in "fix f (x:A) (y:=t) (z:B)
+ (v:=u) (w:I) {struct w}"), telling to skip x and z and that w is
+ the recursive argument);
+ The second component [int] tells which component of the block is
+ returned *)
type cofixpoint = int * rec_declaration
+ (* The component [int] tells which component of the block of
+ cofixpoint is returned *)
type types = constr
@@ -115,7 +124,7 @@ type types = constr
(* Term constructors *)
(*********************)
-(* Constructs a DeBrujin index with number n *)
+(* Constructs a de Bruijn index with number n *)
let rels =
[|Rel 1;Rel 2;Rel 3;Rel 4;Rel 5;Rel 6;Rel 7; Rel 8;
Rel 9;Rel 10;Rel 11;Rel 12;Rel 13;Rel 14;Rel 15; Rel 16|]
@@ -978,28 +987,6 @@ module Hcaseinfo = Hashcons.Make(CaseinfoHash)
let case_info_hash = CaseinfoHash.hash
-module Hsorts =
- Hashcons.Make(
- struct
- open Sorts
-
- type t = Sorts.t
- type u = universe -> universe
- let hashcons huniv = function
- Prop c -> Prop c
- | Type u -> Type (huniv u)
- let eq s1 s2 =
- s1 == s2 ||
- match (s1,s2) with
- (Prop c1, Prop c2) -> c1 == c2
- | (Type u1, Type u2) -> u1 == u2
- |_ -> false
- let hash = function
- | Prop Null -> 0 | Prop Pos -> 1
- | Type u -> 2 + Universe.hash u
- end)
-
-(* let hcons_sorts = Hashcons.simple_hcons Hsorts.generate hcons_univ *)
let hcons_caseinfo = Hashcons.simple_hcons Hcaseinfo.generate Hcaseinfo.hcons hcons_ind
let hcons =
diff --git a/kernel/constr.mli b/kernel/constr.mli
index 700c235e6a..e0954160f9 100644
--- a/kernel/constr.mli
+++ b/kernel/constr.mli
@@ -70,7 +70,7 @@ type types = constr
(** {6 Term constructors. } *)
-(** Constructs a DeBrujin index (DB indices begin at 1) *)
+(** Constructs a de Bruijn index (DB indices begin at 1) *)
val mkRel : int -> constr
(** Constructs a Variable *)
diff --git a/kernel/context.mli b/kernel/context.mli
index 0c666a25d9..24e69ebd6e 100644
--- a/kernel/context.mli
+++ b/kernel/context.mli
@@ -214,7 +214,7 @@ sig
val to_rel_decl : ('c, 't) pt -> ('c, 't) Rel.Declaration.pt
end
- (** Rel-context is represented as a list of declarations.
+ (** Named-context is represented as a list of declarations.
Inner-most declarations are at the beginning of the list.
Outer-most declarations are at the end of the list. *)
type ('constr, 'types) pt = ('constr, 'types) Declaration.pt list
@@ -223,7 +223,7 @@ sig
(** empty named-context *)
val empty : ('c, 't) pt
- (** Return a new rel-context enriched by with a given inner-most declaration. *)
+ (** Return a new named-context enriched by with a given inner-most declaration. *)
val add : ('c, 't) Declaration.pt -> ('c, 't) pt -> ('c, 't) pt
(** Return the number of {e local declarations} in a given named-context. *)
@@ -233,7 +233,7 @@ sig
@raise Not_found if the designated identifier is not bound in a given named-context. *)
val lookup : Id.t -> ('c, 't) pt -> ('c, 't) Declaration.pt
- (** Check whether given two rel-contexts are equal. *)
+ (** Check whether given two named-contexts are equal. *)
val equal : ('c -> 'c -> bool) -> ('c, 'c) pt -> ('c, 'c) pt -> bool
(** Map all terms in a given named-context. *)
@@ -253,8 +253,8 @@ sig
(** Return the set of all identifiers bound in a given named-context. *)
val to_vars : ('c, 't) pt -> Id.Set.t
- (** [instance_from_named_context Ω] builds an instance [args] such
- that [Ω ⊢ args:Ω] where [Ω] is a named context and with the local
+ (** [to_instance Ω] builds an instance [args] such
+ that [Ω ⊢ args:Ω] where [Ω] is a named-context and with the local
definitions of [Ω] skipped. Example: for [id1:T,id2:=c,id3:U], it
gives [Var id1, Var id3]. All [idj] are supposed distinct. *)
val to_instance : (Id.t -> 'r) -> ('c, 't) pt -> 'r list
diff --git a/kernel/declarations.mli b/kernel/declarations.mli
index 7821ea20ff..71e228b19c 100644
--- a/kernel/declarations.mli
+++ b/kernel/declarations.mli
@@ -77,7 +77,7 @@ type typing_flags = {
}
(* some contraints are in constant_constraints, some other may be in
- * the OpaueDef *)
+ * the OpaqueDef *)
type constant_body = {
const_hyps : Context.Named.t; (** New: younger hyp at top *)
const_body : constant_def;
diff --git a/kernel/names.ml b/kernel/names.ml
index ee8d838da1..811b4a62a5 100644
--- a/kernel/names.ml
+++ b/kernel/names.ml
@@ -162,21 +162,8 @@ module DirPath =
struct
type t = module_ident list
- let rec compare (p1 : t) (p2 : t) =
- if p1 == p2 then 0
- else begin match p1, p2 with
- | [], [] -> 0
- | [], _ -> -1
- | _, [] -> 1
- | id1 :: p1, id2 :: p2 ->
- let c = Id.compare id1 id2 in
- if Int.equal c 0 then compare p1 p2 else c
- end
-
- let rec equal p1 p2 = p1 == p2 || match p1, p2 with
- | [], [] -> true
- | id1 :: p1, id2 :: p2 -> Id.equal id1 id2 && equal p1 p2
- | _ -> false
+ let compare = List.compare Id.compare
+ let equal = List.equal Id.equal
let rec hash accu = function
| [] -> accu
@@ -191,7 +178,7 @@ struct
let empty = []
- let is_empty d = match d with [] -> true | _ -> false
+ let is_empty = List.is_empty
let to_string = function
| [] -> "<>"
@@ -555,7 +542,6 @@ module KerPair = struct
end
module SyntacticOrd = struct
- type t = kernel_pair
let compare x y = match x, y with
| Same knx, Same kny -> KerName.compare knx kny
| Dual (knux,kncx), Dual (knuy,kncy) ->
@@ -878,7 +864,6 @@ struct
let hash (c, b) = (if b then 0 else 1) + Constant.hash c
module SyntacticOrd = struct
- type t = constant * bool
let compare (c, b) (c', b') =
if b = b' then Constant.SyntacticOrd.compare c c' else -1
let equal (c, b as x) (c', b' as x') =
diff --git a/kernel/nativecode.ml b/kernel/nativecode.ml
index 33bd7d8ddc..5130aa9a4a 100644
--- a/kernel/nativecode.ml
+++ b/kernel/nativecode.ml
@@ -16,6 +16,8 @@ open Nativeinstr
open Nativelambda
open Pre_env
+[@@@ocaml.warning "-32-37"]
+
(** This file defines the mllambda code generation phase of the native
compiler. mllambda represents a fragment of ML, and can easily be printed
to OCaml code. *)
@@ -40,8 +42,6 @@ module LNset = Set.Make(LNord)
let lname_ctr = ref (-1)
-let reset_lname = lname_ctr := -1
-
let fresh_lname n =
incr lname_ctr;
{ lname = n; luid = !lname_ctr }
@@ -110,40 +110,30 @@ let gname_hash gn = match gn with
let case_ctr = ref (-1)
-let reset_gcase () = case_ctr := -1
-
let fresh_gcase l =
incr case_ctr;
Gcase (l,!case_ctr)
let pred_ctr = ref (-1)
-let reset_gpred () = pred_ctr := -1
-
let fresh_gpred l =
incr pred_ctr;
Gpred (l,!pred_ctr)
let fixtype_ctr = ref (-1)
-let reset_gfixtype () = fixtype_ctr := -1
-
let fresh_gfixtype l =
incr fixtype_ctr;
Gfixtype (l,!fixtype_ctr)
let norm_ctr = ref (-1)
-let reset_norm () = norm_ctr := -1
-
let fresh_gnorm l =
incr norm_ctr;
Gnorm (l,!norm_ctr)
let normtbl_ctr = ref (-1)
-let reset_normtbl () = normtbl_ctr := -1
-
let fresh_gnormtbl l =
incr normtbl_ctr;
Gnormtbl (l,!normtbl_ctr)
@@ -1848,9 +1838,10 @@ and apply_fv env sigma univ (fv_named,fv_rel) auxdefs ml =
auxdefs, MLlet(aux_name, ml, mkMLapp (MLlocal aux_name) (Array.of_list (fv_rel@fv_named)))
and compile_rel env sigma univ auxdefs n =
- let n = Context.Rel.length env.env_rel_context - n in
let open Context.Rel.Declaration in
- match Context.Rel.lookup n env.env_rel_context with
+ let decl = Context.Rel.lookup n env.env_rel_context in
+ let n = Context.Rel.length env.env_rel_context - n in
+ match decl with
| LocalDef (_,t,_) ->
let code = lambda_of_constr env sigma t in
let auxdefs,code = compile_with_fv env sigma univ auxdefs None code in
diff --git a/kernel/nativeconv.ml b/kernel/nativeconv.ml
index 3c0afe3805..3593d94c2c 100644
--- a/kernel/nativeconv.ml
+++ b/kernel/nativeconv.ml
@@ -141,7 +141,7 @@ let native_conv_gen pb sigma env univs t1 t2 =
let t1 = Sys.time () in
let time_info = Format.sprintf "Evaluation done in %.5f@." (t1 -. t0) in
if !Flags.debug then Feedback.msg_debug (Pp.str time_info);
- (* TODO change 0 when we can have deBruijn *)
+ (* TODO change 0 when we can have de Bruijn *)
fst (conv_val env pb 0 !rt1 !rt2 univs)
end
| _ -> anomaly (Pp.str "Compilation failure")
diff --git a/kernel/nativelambda.ml b/kernel/nativelambda.ml
index 366f9a0a6d..72d9c48513 100644
--- a/kernel/nativelambda.ml
+++ b/kernel/nativelambda.ml
@@ -16,7 +16,6 @@ open Nativeinstr
module RelDecl = Context.Rel.Declaration
-(** This file defines the lambda code generation phase of the native compiler *)
exception NotClosed
@@ -161,10 +160,6 @@ let rec lam_exsubst subst lam =
| Lrel(id,i) -> lam_subst_rel lam id i subst
| _ -> map_lam_with_binders liftn lam_exsubst subst lam
-let lam_subst subst lam =
- if is_subs_id subst then lam
- else lam_exsubst subst lam
-
let lam_subst_args subst args =
if is_subs_id subst then args
else Array.smartmap (lam_exsubst subst) args
@@ -278,71 +273,6 @@ and reduce_lapp substf lids body substa largs =
Llam(Array.of_list lids, simplify (liftn (List.length lids) substf) body)
| [], _::_ -> simplify_app substf body substa (Array.of_list largs)
-
-(* [occurrence kind k lam]:
- If [kind] is [true] return [true] if the variable [k] does not appear in
- [lam], return [false] if the variable appear one time and not
- under a lambda, a fixpoint, a cofixpoint; else raise Not_found.
- If [kind] is [false] return [false] if the variable does not appear in [lam]
- else raise [Not_found]
-*)
-
-let rec occurrence k kind lam =
- match lam with
- | Lrel (_,n) ->
- if Int.equal n k then
- if kind then false else raise Not_found
- else kind
- | Lvar _ | Lconst _ | Lproj _ | Luint _ | Lval _ | Lsort _ | Lind _
- | Lconstruct _ | Llazy | Lforce | Lmeta _ | Levar _ -> kind
- | Lprod(dom, codom) ->
- occurrence k (occurrence k kind dom) codom
- | Llam(ids,body) ->
- let _ = occurrence (k+Array.length ids) false body in kind
- | Llet(_,def,body) ->
- occurrence (k+1) (occurrence k kind def) body
- | Lapp(f, args) ->
- occurrence_args k (occurrence k kind f) args
- | Lprim(_,_,_,args) | Lmakeblock(_,_,_,args) ->
- occurrence_args k kind args
- | Lcase(_,t,a,br) ->
- let kind = occurrence k (occurrence k kind t) a in
- let r = ref kind in
- Array.iter (fun (_,ids,c) ->
- r := occurrence (k+Array.length ids) kind c && !r) br;
- !r
- | Lif (t, bt, bf) ->
- let kind = occurrence k kind t in
- kind && occurrence k kind bt && occurrence k kind bf
- | Lfix(_,(ids,ltypes,lbodies))
- | Lcofix(_,(ids,ltypes,lbodies)) ->
- let kind = occurrence_args k kind ltypes in
- let _ = occurrence_args (k+Array.length ids) false lbodies in
- kind
-
-and occurrence_args k kind args =
- Array.fold_left (occurrence k) kind args
-
-let occur_once lam =
- try let _ = occurrence 1 true lam in true
- with Not_found -> false
-
-(* [remove_let lam] remove let expression in [lam] if the variable is *)
-(* used at most once time in the body, and does not appear under *)
-(* a lambda or a fix or a cofix *)
-
-let rec remove_let subst lam =
- match lam with
- | Lrel(id,i) -> lam_subst_rel lam id i subst
- | Llet(id,def,body) ->
- let def' = remove_let subst def in
- if occur_once body then remove_let (cons def' subst) body
- else
- let body' = remove_let (lift subst) body in
- if def == def' && body == body' then lam else Llet(id,def',body')
- | _ -> map_lam_with_binders liftn remove_let subst lam
-
-
(*s Translation from [constr] to [lambda] *)
(* Translation of constructor *)
@@ -407,8 +337,6 @@ module Vect =
size = 0;
}
- let length v = v.size
-
let extend v =
if Int.equal v.size (Array.length v.elems) then
let new_size = min (2*v.size) Sys.max_array_length in
@@ -422,33 +350,15 @@ module Vect =
v.elems.(v.size) <- a;
v.size <- v.size + 1
- let push_pos v a =
- let pos = v.size in
- push v a;
- pos
-
let popn v n =
v.size <- max 0 (v.size - n)
let pop v = popn v 1
- let get v n =
- if v.size <= n then invalid_arg "Vect.get:index out of bounds";
- v.elems.(n)
-
let get_last v n =
if v.size <= n then invalid_arg "Vect.get:index out of bounds";
v.elems.(v.size - n - 1)
-
- let last v =
- if Int.equal v.size 0 then invalid_arg "Vect.last:index out of bounds";
- v.elems.(v.size - 1)
-
- let clear v = v.size <- 0
-
- let to_array v = Array.sub v.elems 0 v.size
-
end
let empty_args = [||]
diff --git a/kernel/nativevalues.ml b/kernel/nativevalues.ml
index 965ed67b07..8d5f6388cb 100644
--- a/kernel/nativevalues.ml
+++ b/kernel/nativevalues.ml
@@ -334,6 +334,7 @@ let l_or accu x y =
if is_int x && is_int y then no_check_l_or x y
else accu x y
+[@@@ocaml.warning "-37"]
type coq_carry =
| Caccu of t
| C0 of t
@@ -430,7 +431,7 @@ let addmuldiv accu x y z =
if is_int x && is_int y && is_int z then no_check_addmuldiv x y z
else accu x y z
-
+[@@@ocaml.warning "-34"]
type coq_bool =
| Baccu of t
| Btrue
diff --git a/kernel/pre_env.ml b/kernel/pre_env.ml
index d14a254d32..48d7ee9ec3 100644
--- a/kernel/pre_env.ml
+++ b/kernel/pre_env.ml
@@ -68,8 +68,8 @@ type named_context_val = {
}
type env = {
- env_globals : globals;
- env_named_context : named_context_val;
+ env_globals : globals; (* globals = constants + inductive types + modules + module-types *)
+ env_named_context : named_context_val; (* section variables *)
env_rel_context : Context.Rel.t;
env_rel_val : lazy_val list;
env_nb_rel : int;
@@ -161,19 +161,7 @@ let map_named_val f ctxt =
else { env_named_ctx = ctx; env_named_map = map }
let push_named d env =
-(* if not (env.env_rel_context = []) then raise (ASSERT env.env_rel_context);
- assert (env.env_rel_context = []); *)
- { env_globals = env.env_globals;
- env_named_context = push_named_context_val d env.env_named_context;
- env_rel_context = env.env_rel_context;
- env_rel_val = env.env_rel_val;
- env_nb_rel = env.env_nb_rel;
- env_stratification = env.env_stratification;
- env_typing_flags = env.env_typing_flags;
- env_conv_oracle = env.env_conv_oracle;
- retroknowledge = env.retroknowledge;
- indirect_pterms = env.indirect_pterms;
- }
+ {env with env_named_context = push_named_context_val d env.env_named_context}
let lookup_named id env =
fst (Id.Map.find id env.env_named_context.env_named_map)
diff --git a/kernel/reduction.ml b/kernel/reduction.ml
index 0d7f77edae..ba714ada20 100644
--- a/kernel/reduction.ml
+++ b/kernel/reduction.ml
@@ -107,7 +107,15 @@ let pure_stack lfts stk =
(****************************************************************************)
let whd_betaiota env t =
- whd_val (create_clos_infos betaiota env) (inject t)
+ match kind_of_term t with
+ | (Sort _|Var _|Meta _|Evar _|Const _|Ind _|Construct _|
+ Prod _|Lambda _|Fix _|CoFix _) -> t
+ | App (c, _) ->
+ begin match kind_of_term c with
+ | Ind _ | Construct _ | Evar _ | Meta _ | Const _ | LetIn _ -> t
+ | _ -> whd_val (create_clos_infos betaiota env) (inject t)
+ end
+ | _ -> whd_val (create_clos_infos betaiota env) (inject t)
let nf_betaiota env t =
norm_val (create_clos_infos betaiota env) (inject t)
@@ -116,18 +124,33 @@ let whd_betaiotazeta env x =
match kind_of_term x with
| (Sort _|Var _|Meta _|Evar _|Const _|Ind _|Construct _|
Prod _|Lambda _|Fix _|CoFix _) -> x
+ | App (c, _) ->
+ begin match kind_of_term c with
+ | Ind _ | Construct _ | Evar _ | Meta _ | Const _ -> x
+ | _ -> whd_val (create_clos_infos betaiotazeta env) (inject x)
+ end
| _ -> whd_val (create_clos_infos betaiotazeta env) (inject x)
let whd_all env t =
match kind_of_term t with
| (Sort _|Meta _|Evar _|Ind _|Construct _|
Prod _|Lambda _|Fix _|CoFix _) -> t
+ | App (c, _) ->
+ begin match kind_of_term c with
+ | Ind _ | Construct _ | Evar _ | Meta _ -> t
+ | _ -> whd_val (create_clos_infos all env) (inject t)
+ end
| _ -> whd_val (create_clos_infos all env) (inject t)
let whd_allnolet env t =
match kind_of_term t with
| (Sort _|Meta _|Evar _|Ind _|Construct _|
Prod _|Lambda _|Fix _|CoFix _|LetIn _) -> t
+ | App (c, _) ->
+ begin match kind_of_term c with
+ | Ind _ | Construct _ | Evar _ | Meta _ | LetIn _ -> t
+ | _ -> whd_val (create_clos_infos allnolet env) (inject t)
+ end
| _ -> whd_val (create_clos_infos allnolet env) (inject t)
(********************************************************************)
@@ -464,14 +487,14 @@ and eqappr cv_pb l2r infos (lft1,st1) (lft2,st2) cuniv =
| (FInd (ind1,u1), FInd (ind2,u2)) ->
if eq_ind ind1 ind2
then
- (let cuniv = convert_instances false u1 u2 cuniv in
+ (let cuniv = convert_instances ~flex:false u1 u2 cuniv in
convert_stacks l2r infos lft1 lft2 v1 v2 cuniv)
else raise NotConvertible
| (FConstruct ((ind1,j1),u1), FConstruct ((ind2,j2),u2)) ->
if Int.equal j1 j2 && eq_ind ind1 ind2
then
- (let cuniv = convert_instances false u1 u2 cuniv in
+ (let cuniv = convert_instances ~flex:false u1 u2 cuniv in
convert_stacks l2r infos lft1 lft2 v1 v2 cuniv)
else raise NotConvertible
diff --git a/kernel/subtyping.ml b/kernel/subtyping.ml
index c8ceb064d5..d0fdf9fdae 100644
--- a/kernel/subtyping.ml
+++ b/kernel/subtyping.ml
@@ -117,7 +117,7 @@ let check_inductive cst env mp1 l info1 mp2 mib2 spec2 subst1 subst2 reso1 reso2
let mib2 = Declareops.subst_mind_body subst2 mib2 in
let check_inductive_type cst name env t1 t2 =
- (* Due to sort-polymorphism in inductive types, the conclusions of
+ (* Due to template polymorphism, the conclusions of
t1 and t2, if in Type, are generated as the least upper bounds
of the types of the constructors.
diff --git a/kernel/term.ml b/kernel/term.ml
index e5a681375d..03562d9f31 100644
--- a/kernel/term.ml
+++ b/kernel/term.ml
@@ -169,7 +169,7 @@ let hcons_types = Constr.hcons
exception DestKO
-(* Destructs a DeBrujin index *)
+(* Destructs a de Bruijn index *)
let destRel c = match kind_of_term c with
| Rel n -> n
| _ -> raise DestKO
diff --git a/kernel/term.mli b/kernel/term.mli
index a9bb677050..241ef322fa 100644
--- a/kernel/term.mli
+++ b/kernel/term.mli
@@ -127,7 +127,7 @@ val is_small : sorts -> bool
exception DestKO
-(** Destructs a DeBrujin index *)
+(** Destructs a de Bruijn index *)
val destRel : constr -> int
(** Destructs an existential variable *)
diff --git a/kernel/term_typing.ml b/kernel/term_typing.ml
index f43b01d1bb..eeb9c421a1 100644
--- a/kernel/term_typing.ml
+++ b/kernel/term_typing.ml
@@ -223,7 +223,7 @@ let rec unzip ctx j =
let feedback_completion_typecheck =
let open Feedback in
Option.iter (fun state_id ->
- feedback ~id:(State state_id) Feedback.Complete)
+ feedback ~id:state_id Feedback.Complete)
let infer_declaration ~trust env kn dcl =
match dcl with
diff --git a/kernel/typeops.ml b/kernel/typeops.ml
index 7d9a2aac09..dbc0dcb73e 100644
--- a/kernel/typeops.ml
+++ b/kernel/typeops.ml
@@ -367,15 +367,13 @@ let rec execute env cstr =
let ft =
match kind_of_term f with
| Ind ind when Environ.template_polymorphic_pind ind env ->
- (* Template sort-polymorphism of inductive types *)
let args = Array.map (fun t -> lazy t) argst in
type_of_inductive_knowing_parameters env ind args
| Const cst when Environ.template_polymorphic_pconstant cst env ->
- (* Template sort-polymorphism of constants *)
let args = Array.map (fun t -> lazy t) argst in
type_of_constant_knowing_parameters env cst args
| _ ->
- (* Full or no sort-polymorphism *)
+ (* No template polymorphism *)
execute env f
in
diff --git a/kernel/uGraph.mli b/kernel/uGraph.mli
index e95cf4d1cb..c8ac7df5c6 100644
--- a/kernel/uGraph.mli
+++ b/kernel/uGraph.mli
@@ -61,3 +61,6 @@ val pr_universes : (Level.t -> Pp.std_ppcmds) -> universes -> Pp.std_ppcmds
val dump_universes :
(constraint_type -> string -> string -> unit) ->
universes -> unit
+
+(** {6 Debugging} *)
+val check_universes_invariants : universes -> unit
diff --git a/kernel/univ.ml b/kernel/univ.ml
index 09f884ecd0..afe9cbe8d5 100644
--- a/kernel/univ.ml
+++ b/kernel/univ.ml
@@ -440,10 +440,6 @@ struct
let set = make Level.set
let type1 = hcons (Level.set, 1)
- let is_prop = function
- | (l,0) -> Level.is_prop l
- | _ -> false
-
let is_small = function
| (l,0) -> Level.is_small l
| _ -> false
diff --git a/kernel/vars.ml b/kernel/vars.ml
index 4affb5f9fb..f1c0a4f08a 100644
--- a/kernel/vars.ml
+++ b/kernel/vars.ml
@@ -27,7 +27,7 @@ let closedn n c =
in
try closed_rec n c; true with LocalOccur -> false
-(* [closed0 M] is true iff [M] is a (deBruijn) closed term *)
+(* [closed0 M] is true iff [M] is a (de Bruijn) closed term *)
let closed0 c = closedn 0 c
diff --git a/kernel/vars.mli b/kernel/vars.mli
index adeac422e0..df5c55118f 100644
--- a/kernel/vars.mli
+++ b/kernel/vars.mli
@@ -11,10 +11,10 @@ open Constr
(** {6 Occur checks } *)
-(** [closedn n M] is true iff [M] is a (deBruijn) closed term under n binders *)
+(** [closedn n M] is true iff [M] is a (de Bruijn) closed term under n binders *)
val closedn : int -> constr -> bool
-(** [closed0 M] is true iff [M] is a (deBruijn) closed term *)
+(** [closed0 M] is true iff [M] is a (de Bruijn) closed term *)
val closed0 : constr -> bool
(** [noccurn n M] returns true iff [Rel n] does NOT occur in term [M] *)
diff --git a/lib/backtrace.ml b/lib/backtrace.ml
index b3b8bdea2e..be9f40c1fb 100644
--- a/lib/backtrace.ml
+++ b/lib/backtrace.ml
@@ -5,6 +5,7 @@
(* // * This file is distributed under the terms of the *)
(* * GNU Lesser General Public License Version 2.1 *)
(***********************************************************************)
+[@@@ocaml.warning "-37"]
type raw_frame =
| Known_location of bool (* is_raise *)
diff --git a/lib/cErrors.ml b/lib/cErrors.ml
index 1c1ff7e2fd..b55fd80c68 100644
--- a/lib/cErrors.ml
+++ b/lib/cErrors.ml
@@ -121,12 +121,14 @@ end
by inner functions during a [vernacinterp]. They should be handled
only at the very end of interp, to be displayed to the user. *)
+[@@@ocaml.warning "-52"]
let noncritical = function
| Sys.Break | Out_of_memory | Stack_overflow
| Assert_failure _ | Match_failure _ | Anomaly _
| Timeout | Drop | Quit -> false
| Invalid_argument "equal: functional value" -> false
| _ -> true
+[@@@ocaml.warning "+52"]
(** Check whether an exception is handled *)
diff --git a/lib/cWarnings.ml b/lib/cWarnings.ml
index 2f569d2849..71e02b3ba4 100644
--- a/lib/cWarnings.ml
+++ b/lib/cWarnings.ml
@@ -82,7 +82,7 @@ let set_all_warnings_status status =
let set_category_status ~name status =
let names = Hashtbl.find categories name in
- List.iter (fun name -> set_warning_status name status) names
+ List.iter (fun name -> set_warning_status ~name status) names
let is_all_keyword name = CString.equal name "all"
let is_none_keyword s = CString.equal s "none"
@@ -166,7 +166,7 @@ let normalize_flags_string s =
let flags = normalize_flags ~silent:false flags in
string_of_flags flags
-let rec parse_warnings items =
+let parse_warnings items =
CList.iter (fun (status, name) -> set_status ~name status) items
(* For compatibility, we accept "none" *)
diff --git a/lib/feedback.ml b/lib/feedback.ml
index 7d9d6bf7f0..0846e419b2 100644
--- a/lib/feedback.ml
+++ b/lib/feedback.ml
@@ -15,9 +15,6 @@ type level =
| Warning
| Error
-type edit_id = int
-type state_id = Stateid.t
-type edit_or_state_id = Edit of edit_id | State of state_id
type route_id = int
type feedback_content =
@@ -38,13 +35,11 @@ type feedback_content =
| Message of level * Loc.t option * Pp.std_ppcmds
type feedback = {
- id : edit_or_state_id;
+ id : Stateid.t;
+ route : route_id;
contents : feedback_content;
- route : route_id;
}
-let default_route = 0
-
(** Feeders *)
let feeders : (int, feedback -> unit) Hashtbl.t = Hashtbl.create 7
@@ -56,7 +51,8 @@ let add_feeder =
let del_feeder fid = Hashtbl.remove feeders fid
-let feedback_id = ref (Edit 0)
+let default_route = 0
+let feedback_id = ref Stateid.dummy
let feedback_route = ref default_route
let set_id_for_feedback ?(route=default_route) i =
diff --git a/lib/feedback.mli b/lib/feedback.mli
index 4bbdfcb5b6..bdd236ac78 100644
--- a/lib/feedback.mli
+++ b/lib/feedback.mli
@@ -16,11 +16,8 @@ type level =
| Warning
| Error
-(** Coq "semantic" infos obtained during parsing/execution *)
-type edit_id = int
-type state_id = Stateid.t
-type edit_or_state_id = Edit of edit_id | State of state_id
+(** Coq "semantic" infos obtained during execution *)
type route_id = int
val default_route : route_id
@@ -46,17 +43,16 @@ type feedback_content =
| Message of level * Loc.t option * Pp.std_ppcmds
type feedback = {
- id : edit_or_state_id; (* The document part concerned *)
- contents : feedback_content; (* The payload *)
+ id : Stateid.t; (* The document part concerned *)
route : route_id; (* Extra routing info *)
+ contents : feedback_content; (* The payload *)
}
(** {6 Feedback sent, even asynchronously, to the user interface} *)
-(* Morally the parser gets a string and an edit_id, and gives back an AST.
- * Feedbacks during the parsing phase are attached to this edit_id.
- * The interpreter assignes an exec_id to the ast, and feedbacks happening
- * during interpretation are attached to the exec_id.
- * Only one among state_id and edit_id can be provided. *)
+
+(* The interpreter assignes an state_id to the ast, and feedbacks happening
+ * during interpretation are attached to it.
+ *)
(** [add_feeder f] adds a feeder listiner [f], returning its id *)
val add_feeder : (feedback -> unit) -> int
@@ -67,11 +63,10 @@ val del_feeder : int -> unit
(** [feedback ?id ?route fb] produces feedback fb, with [route] and
[id] set appropiatedly, if absent, it will use the defaults set by
[set_id_for_feedback] *)
-val feedback :
- ?id:edit_or_state_id -> ?route:route_id -> feedback_content -> unit
+val feedback : ?id:Stateid.t -> ?route:route_id -> feedback_content -> unit
(** [set_id_for_feedback route id] Set the defaults for feedback *)
-val set_id_for_feedback : ?route:route_id -> edit_or_state_id -> unit
+val set_id_for_feedback : ?route:route_id -> Stateid.t -> unit
(** {6 output functions}
diff --git a/lib/flags.ml b/lib/flags.ml
index 5b080151cd..00f515b5a6 100644
--- a/lib/flags.ml
+++ b/lib/flags.ml
@@ -86,8 +86,6 @@ let in_toplevel = ref false
let profile = false
let print_emacs = ref false
-let coqtop_ui = ref false
-
let xml_export = ref false
let ide_slave = ref false
@@ -97,7 +95,6 @@ let time = ref false
let raw_print = ref false
-let record_print = ref true
let univ_print = ref false
@@ -146,16 +143,16 @@ let beautify = ref false
let beautify_file = ref false
(* Silent / Verbose *)
-let silent = ref false
-let make_silent flag = silent := flag; ()
-let is_silent () = !silent
-let is_verbose () = not !silent
+let quiet = ref false
+let silently f x = with_option quiet f x
+let verbosely f x = without_option quiet f x
-let silently f x = with_option silent f x
-let verbosely f x = without_option silent f x
+let if_silent f x = if !quiet then f x
+let if_verbose f x = if not !quiet then f x
-let if_silent f x = if !silent then f x
-let if_verbose f x = if not !silent then f x
+let make_silent flag = quiet := flag
+let is_silent () = !quiet
+let is_verbose () = not !quiet
let auto_intros = ref true
let make_auto_intros flag = auto_intros := flag
@@ -183,12 +180,6 @@ let warn = ref true
let make_warn flag = warn := flag; ()
let if_warn f x = if !warn then f x
-(* The number of printed hypothesis in a goal *)
-
-let print_hyps_limit = ref (None : int option)
-let set_print_hyps_limit n = print_hyps_limit := n
-let print_hyps_limit () = !print_hyps_limit
-
(* Flags for external tools *)
let browser_cmd_fmt =
diff --git a/lib/flags.mli b/lib/flags.mli
index bd365e6538..0b00ac13c2 100644
--- a/lib/flags.mli
+++ b/lib/flags.mli
@@ -8,6 +8,8 @@
(** Global options of the system. *)
+(** Command-line flags *)
+
val boot : bool ref
val load_init : bool ref
@@ -16,8 +18,11 @@ type compilation_mode = BuildVo | BuildVio | Vio2Vo
val compilation_mode : compilation_mode ref
val compilation_output_name : string option ref
+(* Flag set when the test-suite is called. Its only effect to display
+ verbose information for `Fail` *)
val test_mode : bool ref
+(** Async-related flags *)
type async_proofs = APoff | APonLazy | APon
val async_proofs_mode : async_proofs ref
type cache = Force
@@ -46,20 +51,27 @@ val in_toplevel : bool ref
val profile : bool
-val print_emacs : bool ref
-val coqtop_ui : bool ref
+(* Legacy flags *)
+(* -emacs option: printing includes emacs tags, will affect stm caching. *)
+val print_emacs : bool ref
+(* -xml option: xml hooks will be called *)
val xml_export : bool ref
+(* -ide_slave: printing will be more verbose, will affect stm caching *)
val ide_slave : bool ref
val ideslave_coqtop_flags : string option ref
+(* -time option: every command will be wrapped with `Time` *)
val time : bool ref
+(* development flag to detect race conditions, it should go away. *)
val we_are_parsing : bool ref
+(* Set Printing All flag. For some reason it is a global flag *)
val raw_print : bool ref
-val record_print : bool ref
+
+(* Univ print flag, never set anywere. Maybe should belong to Univ? *)
val univ_print : bool ref
type compat_version = V8_2 | V8_3 | V8_4 | V8_5 | V8_6 | Current
@@ -69,17 +81,27 @@ val version_strictly_greater : compat_version -> bool
val version_less_or_equal : compat_version -> bool
val pr_version : compat_version -> string
+(* Beautify command line flags, should move to printing? *)
val beautify : bool ref
val beautify_file : bool ref
-val make_silent : bool -> unit
-val is_silent : unit -> bool
-val is_verbose : unit -> bool
+(* Coq quiet mode. Note that normal mode is called "verbose" here,
+ whereas [quiet] supresses normal output such as goals in coqtop *)
+val quiet : bool ref
val silently : ('a -> 'b) -> 'a -> 'b
val verbosely : ('a -> 'b) -> 'a -> 'b
val if_silent : ('a -> unit) -> 'a -> unit
val if_verbose : ('a -> unit) -> 'a -> unit
+(* Deprecated *)
+val make_silent : bool -> unit
+[@@ocaml.deprecated "Please use Flags.quiet"]
+val is_silent : unit -> bool
+[@@ocaml.deprecated "Please use Flags.quiet"]
+val is_verbose : unit -> bool
+[@@ocaml.deprecated "Please use Flags.quiet"]
+
+(* Miscellaneus flags for vernac *)
val make_auto_intros : bool -> unit
val is_auto_intros : unit -> bool
@@ -111,10 +133,6 @@ val without_option : bool ref -> ('a -> 'b) -> 'a -> 'b
(** Temporarily extends the reference to a list *)
val with_extra_values : 'c list ref -> 'c list -> ('a -> 'b) -> 'a -> 'b
-(** If [None], no limit *)
-val set_print_hyps_limit : int option -> unit
-val print_hyps_limit : unit -> int option
-
(** Options for external tools *)
(** Returns string format for default browser to use from Coq or CoqIDE *)
diff --git a/lib/stateid.ml b/lib/stateid.ml
index ae25735c5f..c153f0e808 100644
--- a/lib/stateid.ml
+++ b/lib/stateid.ml
@@ -32,7 +32,6 @@ let compare = Int.compare
module Self = struct
type t = int
let compare = compare
- let equal = equal
end
module Set = Set.Make(Self)
diff --git a/library/declare.ml b/library/declare.ml
index 31c9c24bc3..91e0cb44b3 100644
--- a/library/declare.ml
+++ b/library/declare.ml
@@ -514,11 +514,10 @@ let do_constraint poly l =
match x with
| GProp -> Loc.dummy_loc, (false, Univ.Level.prop)
| GSet -> Loc.dummy_loc, (false, Univ.Level.set)
- | GType None ->
+ | GType None | GType (Some (_, Anonymous)) ->
user_err ~hdr:"Constraint"
(str "Cannot declare constraints on anonymous universes")
- | GType (Some (loc, id)) ->
- let id = Id.of_string id in
+ | GType (Some (loc, Name id)) ->
let names, _ = Global.global_universe_names () in
try loc, Idmap.find id names
with Not_found ->
diff --git a/library/goptions.ml b/library/goptions.ml
index 1c08b9539f..c111113ca0 100644
--- a/library/goptions.ml
+++ b/library/goptions.ml
@@ -235,7 +235,6 @@ with Not_found ->
then error "Sorry, this option name is already used."
open Libobject
-open Lib
let warn_deprecated_option =
CWarnings.create ~name:"deprecated-option" ~category:"deprecated"
diff --git a/library/libobject.ml b/library/libobject.ml
index 8757ca08c6..897591762c 100644
--- a/library/libobject.ml
+++ b/library/libobject.ml
@@ -8,7 +8,6 @@
open Libnames
open Pp
-open Util
module Dyn = Dyn.Make(struct end)
diff --git a/library/loadpath.ml b/library/loadpath.ml
index d03c6c5553..529b9502b0 100644
--- a/library/loadpath.ml
+++ b/library/loadpath.ml
@@ -113,5 +113,5 @@ let expand_path ?root dir =
let locate_file fname =
let paths = List.map physical !load_paths in
let _,longfname =
- System.find_file_in_path ~warn:(Flags.is_verbose()) paths fname in
+ System.find_file_in_path ~warn:(not !Flags.quiet) paths fname in
longfname
diff --git a/parsing/cLexer.ml4 b/parsing/cLexer.ml4
index 6d259e1b12..4629058083 100644
--- a/parsing/cLexer.ml4
+++ b/parsing/cLexer.ml4
@@ -99,7 +99,6 @@ module Error = struct
| Unterminated_string
| Undefined_token
| Bad_token of string
- | UnsupportedUnicode of int
exception E of t
@@ -110,12 +109,7 @@ module Error = struct
| Unterminated_comment -> "Unterminated comment"
| Unterminated_string -> "Unterminated string"
| Undefined_token -> "Undefined token"
- | Bad_token tok -> Format.sprintf "Bad token %S" tok
- | UnsupportedUnicode x ->
- Printf.sprintf "Unsupported Unicode character (0x%x)" x)
-
- (* Require to fix the Camlp4 signature *)
- let print ppf x = Pp.pp_with ppf (Pp.str (to_string x))
+ | Bad_token tok -> Format.sprintf "Bad token %S" tok)
end
open Error
@@ -153,10 +147,6 @@ let bump_loc_line_last loc bol_pos =
in
Ploc.encl loc loc'
-let set_loc_file loc fname =
- Ploc.make_loc fname (Ploc.line_nb loc) (Ploc.bol_pos loc)
- (Ploc.first_pos loc, Ploc.last_pos loc) (Ploc.comment loc)
-
(* For some reason, the [Ploc.after] function of Camlp5 does not update line
numbers, so we define our own function that does it. *)
let after loc =
@@ -345,13 +335,13 @@ let rec string loc ~comm_level bp len = parser
if esc then string loc ~comm_level bp (store len '"') s else (loc, len)
| [< ''('; s >] ->
(parser
- | [< ''*'; s >] ->
- string loc
- (Option.map succ comm_level)
+ | [< ''*'; s >] ->
+ let comm_level = Option.map succ comm_level in
+ string loc ~comm_level
bp (store (store len '(') '*')
s
| [< >] ->
- string loc comm_level bp (store len '(') s) s
+ string loc ~comm_level bp (store len '(') s) s
| [< ''*'; s >] ->
(parser
| [< '')'; s >] ->
@@ -361,9 +351,9 @@ let rec string loc ~comm_level bp len = parser
| _ -> ()
in
let comm_level = Option.map pred comm_level in
- string loc comm_level bp (store (store len '*') ')') s
+ string loc ~comm_level bp (store (store len '*') ')') s
| [< >] ->
- string loc comm_level bp (store len '*') s) s
+ string loc ~comm_level bp (store len '*') s) s
| [< ''\n' as c; s >] ep ->
(* If we are parsing a comment, the string if not part of a token so we
update the first line of the location. Otherwise, we update the last
@@ -372,8 +362,8 @@ let rec string loc ~comm_level bp len = parser
if Option.has_some comm_level then bump_loc_line loc ep
else bump_loc_line_last loc ep
in
- string loc comm_level bp (store len c) s
- | [< 'c; s >] -> string loc comm_level bp (store len c) s
+ string loc ~comm_level bp (store len c) s
+ | [< 'c; s >] -> string loc ~comm_level bp (store len c) s
| [< _ = Stream.empty >] ep ->
let loc = set_loc_pos loc bp ep in
err loc Unterminated_string
@@ -434,7 +424,6 @@ let push_char c =
real_push_char c
let push_string s = Buffer.add_string current_comment s
-let push_bytes s = Buffer.add_bytes current_comment s
let null_comment s =
let rec null i =
@@ -613,7 +602,7 @@ let rec next_token loc = parser bp
| [< ' ('0'..'9' as c); len = number (store 0 c) >] ep ->
comment_stop bp;
(INT (get_buff len), set_loc_pos loc bp ep)
- | [< ''\"'; (loc,len) = string loc None bp 0 >] ep ->
+ | [< ''\"'; (loc,len) = string loc ~comm_level:None bp 0 >] ep ->
comment_stop bp;
(STRING (get_buff len), set_loc_pos loc bp ep)
| [< ' ('(' as c);
diff --git a/parsing/egramcoq.ml b/parsing/egramcoq.ml
index 496b200020..86c66ec5f1 100644
--- a/parsing/egramcoq.ml
+++ b/parsing/egramcoq.ml
@@ -10,7 +10,6 @@ open CErrors
open Util
open Pcoq
open Constrexpr
-open Notation
open Notation_term
open Extend
open Libnames
@@ -80,10 +79,6 @@ let create_pos = function
| None -> Extend.First
| Some lev -> Extend.After (constr_level lev)
-type gram_level =
- gram_position option * gram_assoc option * string option *
- (** for reinitialization: *) gram_reinit option
-
let find_position_gen current ensure assoc lev =
match lev with
| None ->
diff --git a/parsing/egramcoq.mli b/parsing/egramcoq.mli
index 6dda3817ae..0a0430ba6c 100644
--- a/parsing/egramcoq.mli
+++ b/parsing/egramcoq.mli
@@ -6,14 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Names
-open Constrexpr
-open Notation_term
-open Pcoq
-open Extend
-open Genarg
-open Egramml
-
(** Mapping of grammar productions to camlp4 actions *)
(** This is the part specific to Coq-level Notation and Tactic Notation.
diff --git a/parsing/g_constr.ml4 b/parsing/g_constr.ml4
index 05cb74ddca..15f100c3b0 100644
--- a/parsing/g_constr.ml4
+++ b/parsing/g_constr.ml4
@@ -43,9 +43,6 @@ let binder_of_name expl (loc,na) =
let binders_of_names l =
List.map (binder_of_name Explicit) l
-let binders_of_lidents l =
- List.map (fun (loc, id) -> binder_of_name Explicit (loc, Name id)) l
-
let mk_fixb (id,bl,ann,body,(loc,tyc)) =
let ty = match tyc with
Some ty -> ty
@@ -149,12 +146,12 @@ GEXTEND Gram
[ [ "Set" -> GSet
| "Prop" -> GProp
| "Type" -> GType []
- | "Type"; "@{"; u = universe; "}" -> GType (List.map (fun (loc,x) -> (loc, Id.to_string x)) u)
+ | "Type"; "@{"; u = universe; "}" -> GType u
] ]
;
universe:
- [ [ IDENT "max"; "("; ids = LIST1 identref SEP ","; ")" -> ids
- | id = identref -> [id]
+ [ [ IDENT "max"; "("; ids = LIST1 name SEP ","; ")" -> ids
+ | id = name -> [id]
] ]
;
lconstr:
@@ -222,15 +219,14 @@ GEXTEND Gram
record_fields:
[ [ f = record_field_declaration; ";"; fs = record_fields -> f :: fs
- | f = record_field_declaration; ";" -> [f]
| f = record_field_declaration -> [f]
| -> []
] ]
;
record_field_declaration:
- [ [ id = global; params = LIST0 identref; ":="; c = lconstr ->
- (id, abstract_constr_expr c (binders_of_lidents params)) ] ]
+ [ [ id = global; bl = binders; ":="; c = lconstr ->
+ (id, mkCLambdaN (!@loc) bl c) ] ]
;
binder_constr:
[ [ "forall"; bl = open_binders; ","; c = operconstr LEVEL "200" ->
@@ -302,7 +298,7 @@ GEXTEND Gram
[ [ "Set" -> GSet
| "Prop" -> GProp
| "Type" -> GType None
- | id = identref -> GType (Some (fst id, Id.to_string (snd id)))
+ | id = name -> GType (Some id)
] ]
;
fix_constr:
diff --git a/parsing/g_prim.ml4 b/parsing/g_prim.ml4
index 2af4ed533b..abb463f821 100644
--- a/parsing/g_prim.ml4
+++ b/parsing/g_prim.ml4
@@ -8,7 +8,6 @@
open Names
open Libnames
-open Tok (* necessary for camlp4 *)
open Pcoq
open Pcoq.Prim
diff --git a/parsing/g_proofs.ml4 b/parsing/g_proofs.ml4
index 7ca2e4a4f7..68b8be6b87 100644
--- a/parsing/g_proofs.ml4
+++ b/parsing/g_proofs.ml4
@@ -9,7 +9,6 @@
open Constrexpr
open Vernacexpr
open Misctypes
-open Tok
open Pcoq
open Pcoq.Prim
diff --git a/parsing/g_vernac.ml4 b/parsing/g_vernac.ml4
index 71b93439bc..085c98e379 100644
--- a/parsing/g_vernac.ml4
+++ b/parsing/g_vernac.ml4
@@ -40,7 +40,6 @@ let def_body = Gram.entry_create "vernac:def_body"
let decl_notation = Gram.entry_create "vernac:decl_notation"
let record_field = Gram.entry_create "vernac:record_field"
let of_type_with_opt_coercion = Gram.entry_create "vernac:of_type_with_opt_coercion"
-let subgoal_command = Gram.entry_create "proof_mode:subgoal_command"
let instance_name = Gram.entry_create "vernac:instance_name"
let section_subset_expr = Gram.entry_create "vernac:section_subset_expr"
@@ -53,7 +52,7 @@ let make_bullet s =
| _ -> assert false
GEXTEND Gram
- GLOBAL: vernac gallina_ext noedit_mode subprf subgoal_command;
+ GLOBAL: vernac gallina_ext noedit_mode subprf;
vernac: FIRST
[ [ IDENT "Time"; c = located_vernac -> VernacTime c
| IDENT "Redirect"; s = ne_string; c = located_vernac -> VernacRedirect (s, c)
@@ -92,7 +91,7 @@ GEXTEND Gram
[ [ prfcom = command_entry -> prfcom ] ]
;
noedit_mode:
- [ [ c = subgoal_command -> c None] ]
+ [ [ c = query_command -> c None] ]
;
subprf:
@@ -102,15 +101,6 @@ GEXTEND Gram
] ]
;
- subgoal_command:
- [ [ c = query_command; "." ->
- begin function
- | Some (SelectNth g) -> c (Some g)
- | None -> c None
- | _ ->
- VernacError (UserError (None,str"Typing and evaluation commands, cannot be used with the \"all:\" selector."))
- end ] ]
- ;
located_vernac:
[ [ v = vernac -> !@loc, v ] ]
;
@@ -146,8 +136,8 @@ GEXTEND Gram
[ [ thm = thm_token; id = pidentref; bl = binders; ":"; c = lconstr;
l = LIST0
[ "with"; id = pidentref; bl = binders; ":"; c = lconstr ->
- (Some id,(bl,c,None)) ] ->
- VernacStartTheoremProof (thm, (Some id,(bl,c,None))::l, false)
+ (Some id,(bl,c)) ] ->
+ VernacStartTheoremProof (thm, (Some id,(bl,c))::l, false)
| stre = assumption_token; nl = inline; bl = assum_list ->
VernacAssumption (stre, nl, bl)
| (kwd,stre) = assumptions_token; nl = inline; bl = assum_list ->
@@ -236,16 +226,22 @@ GEXTEND Gram
(* Simple definitions *)
def_body:
[ [ bl = binders; ":="; red = reduce; c = lconstr ->
- let (bl, c) = expand_pattern_binders mkCLambdaN bl c in
- (match c with
- CCast(_,c, CastConv t) -> DefineBody (bl, red, c, Some t)
+ if List.exists (function CLocalPattern _ -> true | _ -> false) bl
+ then
+ (* FIXME: "red" will be applied to types in bl and Cast with remain *)
+ let c = mkCLambdaN (!@loc) bl c in
+ DefineBody ([], red, c, None)
+ else
+ (match c with
+ | CCast(_,c, CastConv t) -> DefineBody (bl, red, c, Some t)
| _ -> DefineBody (bl, red, c, None))
| bl = binders; ":"; t = lconstr; ":="; red = reduce; c = lconstr ->
let ((bl, c), tyo) =
if List.exists (function CLocalPattern _ -> true | _ -> false) bl
then
+ (* FIXME: "red" will be applied to types in bl and Cast with remain *)
let c = CCast (!@loc, c, CastConv t) in
- (expand_pattern_binders mkCLambdaN bl c, None)
+ (([],mkCLambdaN (!@loc) bl c), None)
else ((bl, c), Some t)
in
DefineBody (bl, red, c, tyo)
@@ -760,11 +756,6 @@ GEXTEND Gram
implicit_status = MaximallyImplicit}) items
]
];
- name_or_bang: [
- [ b = OPT "!"; id = name ->
- not (Option.is_empty b), id
- ]
- ];
(* Same as [argument_spec_block], but with only implicit status and names *)
more_implicits_block: [
[ name = name -> [(snd name, Vernacexpr.NotImplicit)]
@@ -912,29 +903,30 @@ GEXTEND Gram
VernacRemoveOption ([table], v) ]]
;
query_command: (* TODO: rapprocher Eval et Check *)
- [ [ IDENT "Eval"; r = red_expr; "in"; c = lconstr ->
+ [ [ IDENT "Eval"; r = red_expr; "in"; c = lconstr; "." ->
fun g -> VernacCheckMayEval (Some r, g, c)
- | IDENT "Compute"; c = lconstr ->
+ | IDENT "Compute"; c = lconstr; "." ->
fun g -> VernacCheckMayEval (Some (Genredexpr.CbvVm None), g, c)
- | IDENT "Check"; c = lconstr ->
+ | IDENT "Check"; c = lconstr; "." ->
fun g -> VernacCheckMayEval (None, g, c)
(* Searching the environment *)
- | IDENT "About"; qid = smart_global ->
+ | IDENT "About"; qid = smart_global; "." ->
fun g -> VernacPrint (PrintAbout (qid,g))
- | IDENT "SearchHead"; c = constr_pattern; l = in_or_out_modules ->
+ | IDENT "SearchHead"; c = constr_pattern; l = in_or_out_modules; "." ->
fun g -> VernacSearch (SearchHead c,g, l)
- | IDENT "SearchPattern"; c = constr_pattern; l = in_or_out_modules ->
+ | IDENT "SearchPattern"; c = constr_pattern; l = in_or_out_modules; "." ->
fun g -> VernacSearch (SearchPattern c,g, l)
- | IDENT "SearchRewrite"; c = constr_pattern; l = in_or_out_modules ->
+ | IDENT "SearchRewrite"; c = constr_pattern; l = in_or_out_modules; "." ->
fun g -> VernacSearch (SearchRewrite c,g, l)
- | IDENT "Search"; s = searchabout_query; l = searchabout_queries ->
+ | IDENT "Search"; s = searchabout_query; l = searchabout_queries; "." ->
let (sl,m) = l in fun g -> VernacSearch (SearchAbout (s::sl),g, m)
(* compatibility: SearchAbout *)
- | IDENT "SearchAbout"; s = searchabout_query; l = searchabout_queries ->
+ | IDENT "SearchAbout"; s = searchabout_query; l = searchabout_queries; "." ->
fun g -> let (sl,m) = l in VernacSearch (SearchAbout (s::sl),g, m)
(* compatibility: SearchAbout with "[ ... ]" *)
| IDENT "SearchAbout"; "["; sl = LIST1 searchabout_query; "]";
- l = in_or_out_modules -> fun g -> VernacSearch (SearchAbout sl,g, l)
+ l = in_or_out_modules; "." ->
+ fun g -> VernacSearch (SearchAbout sl,g, l)
] ]
;
printable:
diff --git a/parsing/pcoq.ml b/parsing/pcoq.ml
index 92d249e535..9a4766c0bf 100644
--- a/parsing/pcoq.ml
+++ b/parsing/pcoq.ml
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Pp
open CErrors
open Util
open Extend
@@ -171,7 +170,6 @@ module Symbols : sig
val sopt : G.symbol -> G.symbol
val snterml : G.internal_entry * string -> G.symbol
val snterm : G.internal_entry -> G.symbol
- val snterml_level : G.symbol -> string
end = struct
let stoken tok =
@@ -199,10 +197,6 @@ end = struct
let slist1 x = Gramext.Slist1 x
let sopt x = Gramext.Sopt x
- let snterml_level = function
- | Gramext.Snterml (_, l) -> l
- | _ -> failwith "snterml_level"
-
end
let camlp4_verbosity silent f x =
@@ -211,8 +205,6 @@ let camlp4_verbosity silent f x =
f x;
warning_verbose := a
-let camlp4_verbose f x = camlp4_verbosity (Flags.is_verbose ()) f x
-
(** Grammar extensions *)
(** NB: [extend_statment =
diff --git a/plugins/cc/cctac.ml b/plugins/cc/cctac.ml
index 2d9dec095a..7c5efaea3a 100644
--- a/plugins/cc/cctac.ml
+++ b/plugins/cc/cctac.ml
@@ -15,13 +15,11 @@ open Declarations
open Term
open EConstr
open Vars
-open Tacmach
open Tactics
open Typing
open Ccalgo
open Ccproof
open Pp
-open CErrors
open Util
open Proofview.Notations
@@ -239,21 +237,43 @@ let build_projection intype (cstr:pconstructor) special default gls=
(* generate an adhoc tactic following the proof tree *)
-let _M =mkMeta
-
let app_global f args k =
- Tacticals.pf_constr_of_global (Lazy.force f) (fun fc -> k (mkApp (fc, args)))
-
-let new_app_global f args k =
- Tacticals.New.pf_constr_of_global (Lazy.force f) (fun fc -> k (mkApp (fc, args)))
-
-let new_refine c = Proofview.V82.tactic (refine c)
-let refine c = refine c
+ Tacticals.New.pf_constr_of_global (Lazy.force f) >>= fun fc -> k (mkApp (fc, args))
+
+let rec gen_holes env sigma t n accu =
+ let open Sigma in
+ if Int.equal n 0 then (sigma, List.rev accu)
+ else match EConstr.kind sigma t with
+ | Prod (_, u, t) ->
+ let sigma = Sigma.Unsafe.of_evar_map sigma in
+ let Sigma (ev, sigma, _) = Evarutil.new_evar env sigma u in
+ let sigma = Sigma.to_evar_map sigma in
+ let t = EConstr.Vars.subst1 ev t in
+ gen_holes env sigma t (pred n) (ev :: accu)
+ | _ -> assert false
+
+let app_global_with_holes f args n =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ Tacticals.New.pf_constr_of_global (Lazy.force f) >>= fun fc ->
+ let env = Proofview.Goal.env gl in
+ let concl = Proofview.Goal.concl gl in
+ Refine.refine { Sigma.run = begin fun sigma ->
+ let sigma = Sigma.to_evar_map sigma in
+ let t = Tacmach.New.pf_get_type_of gl fc in
+ let t = Termops.prod_applist sigma t (Array.to_list args) in
+ let ans = mkApp (fc, args) in
+ let (sigma, holes) = gen_holes env sigma t n [] in
+ let ans = applist (ans, holes) in
+ let evdref = ref sigma in
+ let () = Typing.e_check env evdref ans concl in
+ Sigma.Unsafe.of_pair (ans, !evdref)
+ end }
+ end }
let assert_before n c =
- Proofview.Goal.enter { enter = begin fun gl ->
+ Proofview.Goal.s_enter { s_enter = begin fun gl ->
let evm, _ = Tacmach.New.pf_apply type_of gl c in
- Tacticals.New.tclTHEN (Proofview.V82.tactic (Refiner.tclEVARS evm)) (assert_before n c)
+ Sigma.Unsafe.of_pair (assert_before n c, evm)
end }
let refresh_type env evm ty =
@@ -281,18 +301,18 @@ let rec proof_tac p : unit Proofview.tactic =
let l=constr_of_term p.p_lhs and
r=constr_of_term p.p_rhs in
refresh_universes (type_of l) (fun typ ->
- new_app_global _sym_eq [|typ;r;l;c|] exact_check)
+ app_global _sym_eq [|typ;r;l;c|] exact_check)
| Refl t ->
let lr = constr_of_term t in
refresh_universes (type_of lr) (fun typ ->
- new_app_global _refl_equal [|typ;constr_of_term t|] exact_check)
+ app_global _refl_equal [|typ;constr_of_term t|] exact_check)
| Trans (p1,p2)->
let t1 = constr_of_term p1.p_lhs and
t2 = constr_of_term p1.p_rhs and
t3 = constr_of_term p2.p_rhs in
refresh_universes (type_of t2) (fun typ ->
- let prf = new_app_global _trans_eq [|typ;t1;t2;t3;_M 1;_M 2|] in
- Tacticals.New.tclTHENS (prf new_refine) [(proof_tac p1);(proof_tac p2)])
+ let prf = app_global_with_holes _trans_eq [|typ;t1;t2;t3;|] 2 in
+ Tacticals.New.tclTHENS prf [(proof_tac p1);(proof_tac p2)])
| Congr (p1,p2)->
let tf1=constr_of_term p1.p_lhs
and tx1=constr_of_term p2.p_lhs
@@ -303,18 +323,18 @@ let rec proof_tac p : unit Proofview.tactic =
refresh_universes (type_of (mkApp (tf1,[|tx1|]))) (fun typfx ->
let id = Tacmach.New.pf_get_new_id (Id.of_string "f") gl in
let appx1 = mkLambda(Name id,typf,mkApp(mkRel 1,[|tx1|])) in
- let lemma1 = app_global _f_equal [|typf;typfx;appx1;tf1;tf2;_M 1|] in
- let lemma2 = app_global _f_equal [|typx;typfx;tf2;tx1;tx2;_M 1|] in
+ let lemma1 = app_global_with_holes _f_equal [|typf;typfx;appx1;tf1;tf2|] 1 in
+ let lemma2 = app_global_with_holes _f_equal [|typx;typfx;tf2;tx1;tx2|] 1 in
let prf =
- app_global _trans_eq
+ app_global_with_holes _trans_eq
[|typfx;
mkApp(tf1,[|tx1|]);
mkApp(tf2,[|tx1|]);
- mkApp(tf2,[|tx2|]);_M 2;_M 3|] in
- Tacticals.New.tclTHENS (Proofview.V82.tactic (prf refine))
- [Tacticals.New.tclTHEN (Proofview.V82.tactic (lemma1 refine)) (proof_tac p1);
+ mkApp(tf2,[|tx2|])|] 2 in
+ Tacticals.New.tclTHENS prf
+ [Tacticals.New.tclTHEN lemma1 (proof_tac p1);
Tacticals.New.tclFIRST
- [Tacticals.New.tclTHEN (Proofview.V82.tactic (lemma2 refine)) (proof_tac p2);
+ [Tacticals.New.tclTHEN lemma2 (proof_tac p2);
reflexivity;
Tacticals.New.tclZEROMSG
(Pp.str
@@ -330,8 +350,8 @@ let rec proof_tac p : unit Proofview.tactic =
build_projection intype cstr special default gl
in
let injt=
- app_global _f_equal [|intype;outtype;proj;ti;tj;_M 1|] in
- Tacticals.New.tclTHEN (Proofview.V82.tactic (injt refine)) (proof_tac prf)))
+ app_global_with_holes _f_equal [|intype;outtype;proj;ti;tj|] 1 in
+ Tacticals.New.tclTHEN injt (proof_tac prf)))
with e when Proofview.V82.catchable_exception e -> Proofview.tclZERO e
end }
@@ -341,27 +361,29 @@ let refute_tac c t1 t2 p =
let hid = Tacmach.New.pf_get_new_id (Id.of_string "Heq") gl in
let false_t=mkApp (c,[|mkVar hid|]) in
let k intype =
- let neweq= new_app_global _eq [|intype;tt1;tt2|] in
+ let neweq= app_global _eq [|intype;tt1;tt2|] in
Tacticals.New.tclTHENS (neweq (assert_before (Name hid)))
[proof_tac p; simplest_elim false_t]
in refresh_universes (Tacmach.New.pf_unsafe_type_of gl tt1) k
end }
-let refine_exact_check c gl =
- let evm, _ = pf_apply type_of gl c in
- Tacticals.tclTHEN (Refiner.tclEVARS evm) (Proofview.V82.of_tactic (exact_check c)) gl
+let refine_exact_check c =
+ Proofview.Goal.s_enter { s_enter = begin fun gl ->
+ let evm, _ = Tacmach.New.pf_apply type_of gl c in
+ Sigma.Unsafe.of_pair (exact_check c, evm)
+ end }
let convert_to_goal_tac c t1 t2 p =
Proofview.Goal.enter { enter = begin fun gl ->
let tt1=constr_of_term t1 and tt2=constr_of_term t2 in
let k sort =
- let neweq= new_app_global _eq [|sort;tt1;tt2|] in
+ let neweq= app_global _eq [|sort;tt1;tt2|] in
let e = Tacmach.New.pf_get_new_id (Id.of_string "e") gl in
let x = Tacmach.New.pf_get_new_id (Id.of_string "X") gl in
let identity=mkLambda (Name x,sort,mkRel 1) in
- let endt=app_global _eq_rect [|sort;tt1;identity;c;tt2;mkVar e|] in
+ let endt = app_global _eq_rect [|sort;tt1;identity;c;tt2;mkVar e|] in
Tacticals.New.tclTHENS (neweq (assert_before (Name e)))
- [proof_tac p; Proofview.V82.tactic (endt refine_exact_check)]
+ [proof_tac p; endt refine_exact_check]
in refresh_universes (Tacmach.New.pf_unsafe_type_of gl tt2) k
end }
@@ -392,27 +414,25 @@ let discriminate_tac (cstr,u as cstru) p =
let pred = mkLambda(Name xid,outtype,mkRel 1) in
let hid = Tacmach.New.pf_get_new_id (Id.of_string "Heq") gl in
let proj = build_projection intype cstru trivial concl gl in
- let injt=app_global _f_equal
+ let injt = app_global _f_equal
[|intype;outtype;proj;t1;t2;mkVar hid|] in
let endt k =
injt (fun injt ->
app_global _eq_rect
[|outtype;trivial;pred;identity;concl;injt|] k) in
- let neweq=new_app_global _eq [|intype;t1;t2|] in
+ let neweq = app_global _eq [|intype;t1;t2|] in
Tacticals.New.tclTHEN (Proofview.Unsafe.tclEVARS evm)
(Tacticals.New.tclTHENS (neweq (assert_before (Name hid)))
- [proof_tac p; Proofview.V82.tactic (endt refine_exact_check)])
+ [proof_tac p; endt refine_exact_check])
end }
(* wrap everything *)
-let build_term_to_complete uf meta pac =
+let build_term_to_complete uf pac =
let cinfo = get_constructor_info uf pac.cnode in
- let real_args = List.map (fun i -> constr_of_term (term uf i)) pac.args in
- let dummy_args = List.rev (List.init pac.arity meta) in
- let all_args = List.rev_append real_args dummy_args in
+ let real_args = List.rev_map (fun i -> constr_of_term (term uf i)) pac.args in
let (kn, u) = cinfo.ci_constr in
- applist (mkConstructU (kn, EInstance.make u), all_args)
+ (applist (mkConstructU (kn, EInstance.make u), real_args), pac.arity)
let cc_tactic depth additionnal_terms =
Proofview.Goal.enter { enter = begin fun gl ->
@@ -434,16 +454,17 @@ let cc_tactic depth additionnal_terms =
let cstr=(get_constructor_info uf ipac.cnode).ci_constr in
discriminate_tac cstr p
| Incomplete ->
+ let open Glob_term in
let env = Proofview.Goal.env gl in
- let metacnt = ref 0 in
- let newmeta _ = incr metacnt; _M !metacnt in
- let terms_to_complete =
- List.map
- (build_term_to_complete uf newmeta)
- (epsilons uf) in
+ let terms_to_complete = List.map (build_term_to_complete uf) (epsilons uf) in
+ let hole = GHole (Loc.ghost, Evar_kinds.InternalHole, Misctypes.IntroAnonymous, None) in
+ let pr_missing (c, missing) =
+ let c = Detyping.detype ~lax:true false [] env sigma c in
+ let holes = List.init missing (fun _ -> hole) in
+ Printer.pr_glob_constr_env env (GApp (Loc.ghost, c, holes))
+ in
Feedback.msg_info
- (Pp.str "Goal is solvable by congruence but \
- some arguments are missing.");
+ (Pp.str "Goal is solvable by congruence but some arguments are missing.");
Feedback.msg_info
(Pp.str " Try " ++
hov 8
@@ -451,7 +472,7 @@ let cc_tactic depth additionnal_terms =
str "\"congruence with (" ++
prlist_with_sep
(fun () -> str ")" ++ spc () ++ str "(")
- (Termops.print_constr_env env sigma)
+ pr_missing
terms_to_complete ++
str ")\","
end ++
@@ -472,13 +493,13 @@ let cc_tactic depth additionnal_terms =
convert_to_hyp_tac ida ta idb tb p
end }
-let cc_fail gls =
- user_err ~hdr:"Congruence" (Pp.str "congruence failed.")
+let cc_fail =
+ Tacticals.New.tclZEROMSG (Pp.str "congruence failed.")
let congruence_tac depth l =
Tacticals.New.tclORELSE
(Tacticals.New.tclTHEN (Tacticals.New.tclREPEAT introf) (cc_tactic depth l))
- (Proofview.V82.tactic cc_fail)
+ cc_fail
(* Beware: reflexivity = constructor 1 = apply refl_equal
might be slow now, let's rather do something equivalent
@@ -492,16 +513,15 @@ let congruence_tac depth l =
*)
let mk_eq f c1 c2 k =
- Tacticals.New.pf_constr_of_global (Lazy.force f) (fun fc ->
- Proofview.Goal.enter { enter = begin fun gl ->
+ Tacticals.New.pf_constr_of_global (Lazy.force f) >>= fun fc ->
+ Proofview.Goal.s_enter { s_enter = begin fun gl ->
let open Tacmach.New in
let evm, ty = pf_apply type_of gl c1 in
let evm, ty = Evarsolve.refresh_universes (Some false) (pf_env gl) evm ty in
let term = mkApp (fc, [| ty; c1; c2 |]) in
let evm, _ = type_of (pf_env gl) evm term in
- Tacticals.New.tclTHEN (Proofview.V82.tactic (Refiner.tclEVARS evm))
- (k term)
- end })
+ Sigma.Unsafe.of_pair (k term, evm)
+ end }
let f_equal =
Proofview.Goal.enter { enter = begin fun gl ->
@@ -511,7 +531,7 @@ let f_equal =
try (* type_of can raise an exception *)
Tacticals.New.tclTHENS
(mk_eq _eq c1 c2 Tactics.cut)
- [Proofview.tclUNIT ();Tacticals.New.tclTRY ((new_app_global _refl_equal [||]) apply)]
+ [Proofview.tclUNIT ();Tacticals.New.tclTRY ((app_global _refl_equal [||]) apply)]
with e when Proofview.V82.catchable_exception e -> Proofview.tclZERO e
in
Proofview.tclORELSE
diff --git a/plugins/cc/cctac.mli b/plugins/cc/cctac.mli
index de6eb982ee..b4bb62be8e 100644
--- a/plugins/cc/cctac.mli
+++ b/plugins/cc/cctac.mli
@@ -8,13 +8,12 @@
(************************************************************************)
open EConstr
-open Proof_type
val proof_tac: Ccproof.proof -> unit Proofview.tactic
val cc_tactic : int -> constr list -> unit Proofview.tactic
-val cc_fail : tactic
+val cc_fail : unit Proofview.tactic
val congruence_tac : int -> constr list -> unit Proofview.tactic
diff --git a/plugins/extraction/extract_env.ml b/plugins/extraction/extract_env.ml
index 2b12462ad5..322fbcea74 100644
--- a/plugins/extraction/extract_env.ml
+++ b/plugins/extraction/extract_env.ml
@@ -657,7 +657,7 @@ let extraction_library is_rec m =
let l = List.rev (environment_until (Some dir_m)) in
let select l (mp,struc) =
if Visit.needed_mp mp
- then (mp, extract_structure env mp no_delta true struc) :: l
+ then (mp, extract_structure env mp no_delta ~all:true struc) :: l
else l
in
let struc = List.fold_left select [] l in
diff --git a/plugins/firstorder/formula.ml b/plugins/firstorder/formula.ml
index 7773f6a2fd..9900792cac 100644
--- a/plugins/firstorder/formula.ml
+++ b/plugins/firstorder/formula.ml
@@ -9,9 +9,9 @@
open Hipattern
open Names
open Term
+open EConstr
open Vars
open Termops
-open Tacmach
open Util
open Declarations
open Globnames
@@ -44,28 +44,27 @@ let rec nb_prod_after n c=
1+(nb_prod_after 0 b)
| _ -> 0
-let construct_nhyps ind gls =
+let construct_nhyps env ind =
let nparams = (fst (Global.lookup_inductive (fst ind))).mind_nparams in
- let constr_types = Inductiveops.arities_of_constructors (pf_env gls) ind in
+ let constr_types = Inductiveops.arities_of_constructors env ind in
let hyp = nb_prod_after nparams in
Array.map hyp constr_types
(* indhyps builds the array of arrays of constructor hyps for (ind largs)*)
-let ind_hyps nevar ind largs gls=
- let types= Inductiveops.arities_of_constructors (pf_env gls) ind in
+let ind_hyps env sigma nevar ind largs =
+ let types= Inductiveops.arities_of_constructors env ind in
let myhyps t =
- let t1=Term.prod_applist t largs in
- let t2=snd (decompose_prod_n_assum nevar t1) in
- fst (decompose_prod_assum t2) in
+ let t = EConstr.of_constr t in
+ let t1=Termops.prod_applist sigma t largs in
+ let t2=snd (decompose_prod_n_assum sigma nevar t1) in
+ fst (decompose_prod_assum sigma t2) in
Array.map myhyps types
-let special_nf gl=
- let infos=CClosure.create_clos_infos !red_flags (pf_env gl) in
- (fun t -> CClosure.norm_val infos (CClosure.inject t))
+let special_nf env sigma t =
+ Reductionops.clos_norm_flags !red_flags env sigma t
-let special_whd gl=
- let infos=CClosure.create_clos_infos !red_flags (pf_env gl) in
- (fun t -> CClosure.whd_val infos (CClosure.inject t))
+let special_whd env sigma t =
+ Reductionops.clos_whd_flags !red_flags env sigma t
type kind_of_formula=
Arrow of constr*constr
@@ -78,20 +77,19 @@ type kind_of_formula=
let pop t = Vars.lift (-1) t
-let kind_of_formula gl term =
- let normalize=special_nf gl in
- let cciterm=special_whd gl term in
- match match_with_imp_term (project gl) (EConstr.of_constr cciterm) with
- Some (a,b)-> Arrow(EConstr.Unsafe.to_constr a,(pop (EConstr.Unsafe.to_constr b)))
+let kind_of_formula env sigma term =
+ let normalize = special_nf env sigma in
+ let cciterm = special_whd env sigma term in
+ match match_with_imp_term sigma cciterm with
+ Some (a,b)-> Arrow (a, pop b)
|_->
- match match_with_forall_term (project gl) (EConstr.of_constr cciterm) with
- Some (_,a,b)-> Forall(EConstr.Unsafe.to_constr a,EConstr.Unsafe.to_constr b)
+ match match_with_forall_term sigma cciterm with
+ Some (_,a,b)-> Forall (a, b)
|_->
- match match_with_nodep_ind (project gl) (EConstr.of_constr cciterm) with
+ match match_with_nodep_ind sigma cciterm with
Some (i,l,n)->
- let l = List.map EConstr.Unsafe.to_constr l in
- let ind,u=EConstr.destInd (project gl) i in
- let u = EConstr.EInstance.kind (project gl) u in
+ let ind,u=EConstr.destInd sigma i in
+ let u = EConstr.EInstance.kind sigma u in
let (mib,mip) = Global.lookup_inductive ind in
let nconstr=Array.length mip.mind_consnames in
if Int.equal nconstr 0 then
@@ -100,7 +98,7 @@ let kind_of_formula gl term =
let has_realargs=(n>0) in
let is_trivial=
let is_constant c =
- Int.equal (nb_prod (project gl) (EConstr.of_constr c)) mib.mind_nparams in
+ Int.equal (nb_prod sigma (EConstr.of_constr c)) mib.mind_nparams in
Array.exists is_constant mip.mind_nf_lc in
if Inductiveops.mis_is_recursive (ind,mib,mip) ||
(has_realargs && not is_trivial)
@@ -112,11 +110,11 @@ let kind_of_formula gl term =
else
Or((ind,u),l,is_trivial)
| _ ->
- match match_with_sigma_type (project gl) (EConstr.of_constr cciterm) with
+ match match_with_sigma_type sigma cciterm with
Some (i,l)->
- let (ind, u) = EConstr.destInd (project gl) i in
- let u = EConstr.EInstance.kind (project gl) u in
- Exists((ind, u), List.map EConstr.Unsafe.to_constr l)
+ let (ind, u) = EConstr.destInd sigma i in
+ let u = EConstr.EInstance.kind sigma u in
+ Exists((ind, u), l)
|_-> Atom (normalize cciterm)
type atoms = {positive:constr list;negative:constr list}
@@ -127,29 +125,29 @@ let no_atoms = (false,{positive=[];negative=[]})
let dummy_id=VarRef (Id.of_string "_") (* "_" cannot be parsed *)
-let build_atoms gl metagen side cciterm =
+let build_atoms env sigma metagen side cciterm =
let trivial =ref false
and positive=ref []
and negative=ref [] in
- let normalize=special_nf gl in
- let rec build_rec env polarity cciterm=
- match kind_of_formula gl cciterm with
+ let normalize=special_nf env sigma in
+ let rec build_rec subst polarity cciterm=
+ match kind_of_formula env sigma cciterm with
False(_,_)->if not polarity then trivial:=true
| Arrow (a,b)->
- build_rec env (not polarity) a;
- build_rec env polarity b
+ build_rec subst (not polarity) a;
+ build_rec subst polarity b
| And(i,l,b) | Or(i,l,b)->
if b then
begin
- let unsigned=normalize (substnl env 0 cciterm) in
+ let unsigned=normalize (substnl subst 0 cciterm) in
if polarity then
positive:= unsigned :: !positive
else
negative:= unsigned :: !negative
end;
- let v = ind_hyps 0 i l gl in
+ let v = ind_hyps env sigma 0 i l in
let g i _ decl =
- build_rec env polarity (lift i (RelDecl.get_type decl)) in
+ build_rec subst polarity (lift i (RelDecl.get_type decl)) in
let f l =
List.fold_left_i g (1-(List.length l)) () l in
if polarity && (* we have a constant constructor *)
@@ -158,16 +156,16 @@ let build_atoms gl metagen side cciterm =
Array.iter f v
| Exists(i,l)->
let var=mkMeta (metagen true) in
- let v =(ind_hyps 1 i l gl).(0) in
+ let v =(ind_hyps env sigma 1 i l).(0) in
let g i _ decl =
- build_rec (var::env) polarity (lift i (RelDecl.get_type decl)) in
+ build_rec (var::subst) polarity (lift i (RelDecl.get_type decl)) in
List.fold_left_i g (2-(List.length l)) () v
| Forall(_,b)->
let var=mkMeta (metagen true) in
- build_rec (var::env) polarity b
+ build_rec (var::subst) polarity b
| Atom t->
- let unsigned=substnl env 0 t in
- if not (isMeta unsigned) then (* discarding wildcard atoms *)
+ let unsigned=substnl subst 0 t in
+ if not (isMeta sigma unsigned) then (* discarding wildcard atoms *)
if polarity then
positive:= unsigned :: !positive
else
@@ -177,9 +175,9 @@ let build_atoms gl metagen side cciterm =
Concl -> build_rec [] true cciterm
| Hyp -> build_rec [] false cciterm
| Hint ->
- let rels,head=decompose_prod cciterm in
- let env=List.rev_map (fun _->mkMeta (metagen true)) rels in
- build_rec env false head;trivial:=false (* special for hints *)
+ let rels,head=decompose_prod sigma cciterm in
+ let subst=List.rev_map (fun _->mkMeta (metagen true)) rels in
+ build_rec subst false head;trivial:=false (* special for hints *)
end;
(!trivial,
{positive= !positive;
@@ -215,32 +213,32 @@ type t={id:global_reference;
pat:(left_pattern,right_pattern) sum;
atoms:atoms}
-let build_formula side nam typ gl metagen=
- let normalize = special_nf gl in
+let build_formula env sigma side nam typ metagen=
+ let normalize = special_nf env sigma in
try
let m=meta_succ(metagen false) in
let trivial,atoms=
if !qflag then
- build_atoms gl metagen side typ
+ build_atoms env sigma metagen side typ
else no_atoms in
let pattern=
match side with
Concl ->
let pat=
- match kind_of_formula gl typ with
+ match kind_of_formula env sigma typ with
False(_,_) -> Rfalse
| Atom a -> raise (Is_atom a)
| And(_,_,_) -> Rand
| Or(_,_,_) -> Ror
| Exists (i,l) ->
- let d = RelDecl.get_type (List.last (ind_hyps 0 i l gl).(0)) in
+ let d = RelDecl.get_type (List.last (ind_hyps env sigma 0 i l).(0)) in
Rexists(m,d,trivial)
| Forall (_,a) -> Rforall
| Arrow (a,b) -> Rarrow in
Right pat
| _ ->
let pat=
- match kind_of_formula gl typ with
+ match kind_of_formula env sigma typ with
False(i,_) -> Lfalse
| Atom a -> raise (Is_atom a)
| And(i,_,b) ->
@@ -257,7 +255,7 @@ let build_formula side nam typ gl metagen=
| Arrow (a,b) ->
let nfa=normalize a in
LA (nfa,
- match kind_of_formula gl a with
+ match kind_of_formula env sigma a with
False(i,l)-> LLfalse(i,l)
| Atom t-> LLatom
| And(i,l,_)-> LLand(i,l)
diff --git a/plugins/firstorder/formula.mli b/plugins/firstorder/formula.mli
index 5db8ff59ad..3f438c04a0 100644
--- a/plugins/firstorder/formula.mli
+++ b/plugins/firstorder/formula.mli
@@ -7,6 +7,7 @@
(************************************************************************)
open Term
+open EConstr
open Globnames
val qflag : bool ref
@@ -23,10 +24,10 @@ type ('a,'b) sum = Left of 'a | Right of 'b
type counter = bool -> metavariable
-val construct_nhyps : pinductive -> Proof_type.goal Tacmach.sigma -> int array
+val construct_nhyps : Environ.env -> pinductive -> int array
-val ind_hyps : int -> pinductive -> constr list ->
- Proof_type.goal Tacmach.sigma -> Context.Rel.t array
+val ind_hyps : Environ.env -> Evd.evar_map -> int -> pinductive ->
+ constr list -> EConstr.rel_context array
type atoms = {positive:constr list;negative:constr list}
@@ -34,7 +35,7 @@ type side = Hyp | Concl | Hint
val dummy_id: global_reference
-val build_atoms : Proof_type.goal Tacmach.sigma -> counter ->
+val build_atoms : Environ.env -> Evd.evar_map -> counter ->
side -> constr -> bool * atoms
type right_pattern =
@@ -69,6 +70,6 @@ type t={id: global_reference;
(*exception Is_atom of constr*)
-val build_formula : side -> global_reference -> types ->
- Proof_type.goal Tacmach.sigma -> counter -> (t,types) sum
+val build_formula : Environ.env -> Evd.evar_map -> side -> global_reference -> types ->
+ counter -> (t,types) sum
diff --git a/plugins/firstorder/g_ground.ml4 b/plugins/firstorder/g_ground.ml4
index 3c03193196..b250175354 100644
--- a/plugins/firstorder/g_ground.ml4
+++ b/plugins/firstorder/g_ground.ml4
@@ -13,7 +13,9 @@ open Formula
open Sequent
open Ground
open Goptions
-open Tacticals
+open Tacmach.New
+open Tacticals.New
+open Proofview.Notations
open Tacinterp
open Libnames
open Stdarg
@@ -81,21 +83,29 @@ END
let fail_solver=tclFAIL 0 (Pp.str "GTauto failed")
-let gen_ground_tac flag taco ids bases gl=
+let gen_ground_tac flag taco ids bases =
let backup= !qflag in
- try
+ Proofview.tclOR begin
+ Proofview.Goal.enter { enter = begin fun gl ->
qflag:=flag;
let solver=
match taco with
Some tac-> tac
| None-> snd (default_solver ()) in
- let startseq gl=
+ let startseq k =
+ Proofview.Goal.s_enter { s_enter = begin fun gl ->
let seq=empty_seq !ground_depth in
- let seq,gl = extend_with_ref_list ids seq gl in
- extend_with_auto_hints bases seq gl in
- let result=ground_tac (Proofview.V82.of_tactic solver) startseq gl in
- qflag:=backup;result
- with reraise -> qflag:=backup;raise reraise
+ let seq, sigma = extend_with_ref_list (pf_env gl) (project gl) ids seq in
+ let seq, sigma = extend_with_auto_hints (pf_env gl) (project gl) bases seq in
+ Sigma.Unsafe.of_pair (k seq, sigma)
+ end }
+ in
+ let result=ground_tac solver startseq in
+ qflag := backup;
+ result
+ end }
+ end
+ (fun (e, info) -> qflag := backup; Proofview.tclZERO ~info e)
(* special for compatibility with Intuition
@@ -113,7 +123,6 @@ let normalize_evaluables=
unfold_in_hyp (Lazy.force defined_connectives)
(Tacexpr.InHypType id)) *)
-open Pp
open Genarg
open Ppconstr
open Printer
@@ -144,18 +153,15 @@ END
TACTIC EXTEND firstorder
[ "firstorder" tactic_opt(t) firstorder_using(l) ] ->
- [ Proofview.V82.tactic (gen_ground_tac true (Option.map (tactic_of_value ist) t) l []) ]
+ [ gen_ground_tac true (Option.map (tactic_of_value ist) t) l [] ]
| [ "firstorder" tactic_opt(t) "with" ne_preident_list(l) ] ->
- [ Proofview.V82.tactic (gen_ground_tac true (Option.map (tactic_of_value ist) t) [] l) ]
+ [ gen_ground_tac true (Option.map (tactic_of_value ist) t) [] l ]
| [ "firstorder" tactic_opt(t) firstorder_using(l)
"with" ne_preident_list(l') ] ->
- [ Proofview.V82.tactic (gen_ground_tac true (Option.map (tactic_of_value ist) t) l l') ]
+ [ gen_ground_tac true (Option.map (tactic_of_value ist) t) l l' ]
END
TACTIC EXTEND gintuition
[ "gintuition" tactic_opt(t) ] ->
- [ Proofview.V82.tactic (gen_ground_tac false (Option.map (tactic_of_value ist) t) [] []) ]
+ [ gen_ground_tac false (Option.map (tactic_of_value ist) t) [] [] ]
END
-
-open Proofview.Notations
-open Cc_plugin
diff --git a/plugins/firstorder/ground.ml b/plugins/firstorder/ground.ml
index d6cd7e2a08..ab1dd07c11 100644
--- a/plugins/firstorder/ground.ml
+++ b/plugins/firstorder/ground.ml
@@ -12,8 +12,9 @@ open Sequent
open Rules
open Instances
open Term
-open Tacmach
-open Tacticals
+open Tacmach.New
+open Tacticals.New
+open Proofview.Notations
let update_flags ()=
let predref=ref Names.Cpred.empty in
@@ -29,18 +30,24 @@ let update_flags ()=
CClosure.betaiotazeta
(Names.Id.Pred.full,Names.Cpred.complement !predref)
-let ground_tac solver startseq gl=
+let ground_tac solver startseq =
+ Proofview.Goal.enter { enter = begin fun gl ->
update_flags ();
- let rec toptac skipped seq gl=
- if Tacinterp.get_debug()=Tactic_debug.DebugOn 0
- then Feedback.msg_debug (Printer.pr_goal gl);
+ let rec toptac skipped seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let () =
+ if Tacinterp.get_debug()=Tactic_debug.DebugOn 0
+ then
+ let gl = { Evd.it = Proofview.Goal.goal (Proofview.Goal.assume gl); sigma = project gl } in
+ Feedback.msg_debug (Printer.pr_goal gl)
+ in
tclORELSE (axiom_tac seq.gl seq)
begin
try
- let (hd,seq1)=take_formula seq
- and re_add s=re_add_formula_list skipped s in
+ let (hd,seq1)=take_formula (project gl) seq
+ and re_add s=re_add_formula_list (project gl) skipped s in
let continue=toptac []
- and backtrack gl=toptac (hd::skipped) seq1 gl in
+ and backtrack =toptac (hd::skipped) seq1 in
match hd.pat with
Right rpat->
begin
@@ -60,7 +67,7 @@ let ground_tac solver startseq gl=
or_tac backtrack continue (re_add seq1)
| Rfalse->backtrack
| Rexists(i,dom,triv)->
- let (lfp,seq2)=collect_quantified seq in
+ let (lfp,seq2)=collect_quantified (project gl) seq in
let backtrack2=toptac (lfp@skipped) seq2 in
if !qflag && seq.depth>0 then
quantified_tac lfp backtrack2
@@ -80,7 +87,7 @@ let ground_tac solver startseq gl=
left_or_tac ind backtrack
hd.id continue (re_add seq1)
| Lforall (_,_,_)->
- let (lfp,seq2)=collect_quantified seq in
+ let (lfp,seq2)=collect_quantified (project gl) seq in
let backtrack2=toptac (lfp@skipped) seq2 in
if !qflag && seq.depth>0 then
quantified_tac lfp backtrack2
@@ -119,7 +126,8 @@ let ground_tac solver startseq gl=
ll_atom_tac typ la_tac hd.id continue (re_add seq1)
end
with Heap.EmptyHeap->solver
- end gl in
- let seq, gl' = startseq gl in
- wrap (List.length (pf_hyps gl)) true (toptac []) seq gl'
-
+ end
+ end } in
+ let n = List.length (Proofview.Goal.hyps gl) in
+ startseq (fun seq -> wrap n true (toptac []) seq)
+ end }
diff --git a/plugins/firstorder/ground.mli b/plugins/firstorder/ground.mli
index b5669463cd..4fd1e38a27 100644
--- a/plugins/firstorder/ground.mli
+++ b/plugins/firstorder/ground.mli
@@ -6,6 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-val ground_tac: Tacmach.tactic ->
- (Proof_type.goal Tacmach.sigma -> Sequent.t * Proof_type.goal Tacmach.sigma) -> Tacmach.tactic
+val ground_tac: unit Proofview.tactic ->
+ ((Sequent.t -> unit Proofview.tactic) -> unit Proofview.tactic) -> unit Proofview.tactic
diff --git a/plugins/firstorder/instances.ml b/plugins/firstorder/instances.ml
index 9dc2a51a61..5a1e7c26a1 100644
--- a/plugins/firstorder/instances.ml
+++ b/plugins/firstorder/instances.ml
@@ -10,12 +10,12 @@ open Unify
open Rules
open CErrors
open Util
-open Term
+open EConstr
open Vars
-open Tacmach
+open Tacmach.New
open Tactics
-open Tacticals
-open Termops
+open Tacticals.New
+open Proofview.Notations
open Reductionops
open Formula
open Sequent
@@ -25,11 +25,12 @@ open Sigma.Notations
open Context.Rel.Declaration
let compare_instance inst1 inst2=
+ let cmp c1 c2 = OrderedConstr.compare (EConstr.Unsafe.to_constr c1) (EConstr.Unsafe.to_constr c2) in
match inst1,inst2 with
Phantom(d1),Phantom(d2)->
- (OrderedConstr.compare d1 d2)
+ (cmp d1 d2)
| Real((m1,c1),n1),Real((m2,c2),n2)->
- ((-) =? (-) ==? OrderedConstr.compare) m2 m1 n1 n2 c1 c2
+ ((-) =? (-) ==? cmp) m2 m1 n1 n2 c1 c2
| Phantom(_),Real((m,_),_)-> if Int.equal m 0 then -1 else 1
| Real((m,_),_),Phantom(_)-> if Int.equal m 0 then 1 else -1
@@ -56,12 +57,12 @@ let make_simple_atoms seq=
| None->[]
in {negative=seq.latoms;positive=ratoms}
-let do_sequent setref triv id seq i dom atoms=
+let do_sequent sigma setref triv id seq i dom atoms=
let flag=ref true in
let phref=ref triv in
let do_atoms a1 a2 =
let do_pair t1 t2 =
- match unif_atoms i dom t1 t2 with
+ match unif_atoms sigma i dom t1 t2 with
None->()
| Some (Phantom _) ->phref:=true
| Some c ->flag:=false;setref:=IS.add (c,id) !setref in
@@ -71,26 +72,26 @@ let do_sequent setref triv id seq i dom atoms=
do_atoms atoms (make_simple_atoms seq);
!flag && !phref
-let match_one_quantified_hyp setref seq lf=
+let match_one_quantified_hyp sigma setref seq lf=
match lf.pat with
Left(Lforall(i,dom,triv))|Right(Rexists(i,dom,triv))->
- if do_sequent setref triv lf.id seq i dom lf.atoms then
+ if do_sequent sigma setref triv lf.id seq i dom lf.atoms then
setref:=IS.add ((Phantom dom),lf.id) !setref
| _ -> anomaly (Pp.str "can't happen")
-let give_instances lf seq=
+let give_instances sigma lf seq=
let setref=ref IS.empty in
- List.iter (match_one_quantified_hyp setref seq) lf;
+ List.iter (match_one_quantified_hyp sigma setref seq) lf;
IS.elements !setref
(* collector for the engine *)
-let rec collect_quantified seq=
+let rec collect_quantified sigma seq=
try
- let hd,seq1=take_formula seq in
+ let hd,seq1=take_formula sigma seq in
(match hd.pat with
Left(Lforall(_,_,_)) | Right(Rexists(_,_,_)) ->
- let (q,seq2)=collect_quantified seq1 in
+ let (q,seq2)=collect_quantified sigma seq1 in
((hd::q),seq2)
| _->[],seq)
with Heap.EmptyHeap -> [],seq
@@ -99,60 +100,61 @@ let rec collect_quantified seq=
let dummy_bvid=Id.of_string "x"
-let mk_open_instance id idc gl m t=
- let env=pf_env gl in
- let evmap=Refiner.project gl in
+let mk_open_instance env evmap id idc m t =
let var_id=
if id==dummy_id then dummy_bvid else
- let typ=pf_unsafe_type_of gl idc in
+ let typ=Typing.unsafe_type_of env evmap idc in
(* since we know we will get a product,
reduction is not too expensive *)
- let (nam,_,_)=destProd (EConstr.Unsafe.to_constr (whd_all env evmap typ)) in
+ let (nam,_,_)=destProd evmap (whd_all env evmap typ) in
match nam with
Name id -> id
| Anonymous -> dummy_bvid in
let revt=substl (List.init m (fun i->mkRel (m-i))) t in
let rec aux n avoid env evmap decls =
if Int.equal n 0 then evmap, decls else
- let nid=(fresh_id avoid var_id gl) in
+ let nid=(fresh_id_in_env avoid var_id env) in
let evmap = Sigma.Unsafe.of_evar_map evmap in
let Sigma ((c, _), evmap, _) = Evarutil.new_type_evar env evmap Evd.univ_flexible in
let evmap = Sigma.to_evar_map evmap in
let decl = LocalAssum (Name nid, c) in
aux (n-1) (nid::avoid) (EConstr.push_rel decl env) evmap (decl::decls) in
let evmap, decls = aux m [] env evmap [] in
- evmap, decls, revt
+ (evmap, decls, revt)
(* tactics *)
let left_instance_tac (inst,id) continue seq=
let open EConstr in
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let sigma = project gl in
match inst with
Phantom dom->
- if lookup (id,None) seq then
+ if lookup sigma (id,None) seq then
tclFAIL 0 (Pp.str "already done")
else
- tclTHENS (Proofview.V82.of_tactic (cut (EConstr.of_constr dom)))
+ tclTHENS (cut dom)
[tclTHENLIST
- [Proofview.V82.of_tactic introf;
- pf_constr_of_global id (fun idc ->
- (fun gls-> Proofview.V82.of_tactic (generalize
- [mkApp(idc,
- [|mkVar (Tacmach.pf_nth_hyp_id gls 1)|])]) gls));
- Proofview.V82.of_tactic introf;
+ [introf;
+ (pf_constr_of_global id >>= fun idc ->
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let id0 = List.nth (pf_ids_of_hyps gl) 0 in
+ generalize [mkApp(idc, [|mkVar id0|])]
+ end });
+ introf;
tclSOLVE [wrap 1 false continue
(deepen (record (id,None) seq))]];
- tclTRY (Proofview.V82.of_tactic assumption)]
- | Real((m,t) as c,_)->
- if lookup (id,Some c) seq then
+ tclTRY assumption]
+ | Real((m,t),_)->
+ let c = (m, EConstr.to_constr sigma t) in
+ if lookup sigma (id,Some c) seq then
tclFAIL 0 (Pp.str "already done")
else
let special_generalize=
if m>0 then
- pf_constr_of_global id (fun idc ->
- fun gl->
- let evmap,rc,ot = mk_open_instance id idc gl m t in
- let ot = EConstr.of_constr ot in
+ (pf_constr_of_global id >>= fun idc ->
+ Proofview.Goal.s_enter { s_enter = begin fun gl->
+ let (evmap, rc, ot) = mk_open_instance (pf_env gl) (project gl) id idc m t in
let gt=
it_mkLambda_or_LetIn
(mkApp(idc,[|ot|])) rc in
@@ -160,34 +162,38 @@ let left_instance_tac (inst,id) continue seq=
try Typing.type_of (pf_env gl) evmap gt
with e when CErrors.noncritical e ->
error "Untypable instance, maybe higher-order non-prenex quantification" in
- tclTHEN (Refiner.tclEVARS evmap) (Proofview.V82.of_tactic (generalize [gt])) gl)
+ Sigma.Unsafe.of_pair (generalize [gt], evmap)
+ end })
else
- let t = EConstr.of_constr t in
- pf_constr_of_global id (fun idc ->
- Proofview.V82.of_tactic (generalize [mkApp(idc,[|t|])]))
+ pf_constr_of_global id >>= fun idc -> generalize [mkApp(idc,[|t|])]
in
tclTHENLIST
[special_generalize;
- Proofview.V82.of_tactic introf;
+ introf;
tclSOLVE
[wrap 1 false continue (deepen (record (id,Some c) seq))]]
+ end }
let right_instance_tac inst continue seq=
+ let open EConstr in
+ Proofview.Goal.enter { enter = begin fun gl ->
match inst with
Phantom dom ->
- tclTHENS (Proofview.V82.of_tactic (cut (EConstr.of_constr dom)))
+ tclTHENS (cut dom)
[tclTHENLIST
- [Proofview.V82.of_tactic introf;
- (fun gls->
- Proofview.V82.of_tactic (split (ImplicitBindings
- [EConstr.mkVar (Tacmach.pf_nth_hyp_id gls 1)])) gls);
+ [introf;
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let id0 = List.nth (pf_ids_of_hyps gl) 0 in
+ split (ImplicitBindings [mkVar id0])
+ end };
tclSOLVE [wrap 0 true continue (deepen seq)]];
- tclTRY (Proofview.V82.of_tactic assumption)]
+ tclTRY assumption]
| Real ((0,t),_) ->
- (tclTHEN (Proofview.V82.of_tactic (split (ImplicitBindings [EConstr.of_constr t])))
+ (tclTHEN (split (ImplicitBindings [t]))
(tclSOLVE [wrap 0 true continue (deepen seq)]))
| Real ((m,t),_) ->
tclFAIL 0 (Pp.str "not implemented ... yet")
+ end }
let instance_tac inst=
if (snd inst)==dummy_id then
@@ -195,10 +201,10 @@ let instance_tac inst=
else
left_instance_tac inst
-let quantified_tac lf backtrack continue seq gl=
- let insts=give_instances lf seq in
+let quantified_tac lf backtrack continue seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let insts=give_instances (project gl) lf seq in
tclORELSE
(tclFIRST (List.map (fun inst->instance_tac inst continue seq) insts))
- backtrack gl
-
-
+ backtrack
+ end }
diff --git a/plugins/firstorder/instances.mli b/plugins/firstorder/instances.mli
index ce711f3f97..47550f314e 100644
--- a/plugins/firstorder/instances.mli
+++ b/plugins/firstorder/instances.mli
@@ -9,9 +9,9 @@
open Globnames
open Rules
-val collect_quantified : Sequent.t -> Formula.t list * Sequent.t
+val collect_quantified : Evd.evar_map -> Sequent.t -> Formula.t list * Sequent.t
-val give_instances : Formula.t list -> Sequent.t ->
+val give_instances : Evd.evar_map -> Formula.t list -> Sequent.t ->
(Unify.instance * global_reference) list
val quantified_tac : Formula.t list -> seqtac with_backtracking
diff --git a/plugins/firstorder/rules.ml b/plugins/firstorder/rules.ml
index a60fd4d8f1..86a6770070 100644
--- a/plugins/firstorder/rules.ml
+++ b/plugins/firstorder/rules.ml
@@ -9,11 +9,12 @@
open CErrors
open Util
open Names
-open Term
+open EConstr
open Vars
-open Tacmach
+open Tacmach.New
open Tactics
-open Tacticals
+open Tacticals.New
+open Proofview.Notations
open Termops
open Formula
open Sequent
@@ -22,148 +23,165 @@ open Locus
module NamedDecl = Context.Named.Declaration
+type tactic = unit Proofview.tactic
+
type seqtac= (Sequent.t -> tactic) -> Sequent.t -> tactic
type lseqtac= global_reference -> seqtac
type 'a with_backtracking = tactic -> 'a
-let wrap n b continue seq gls=
+let wrap n b continue seq =
+ Proofview.Goal.nf_enter { enter = begin fun gls ->
Control.check_for_interrupt ();
- let nc=pf_hyps gls in
+ let nc = Proofview.Goal.hyps gls in
let env=pf_env gls in
+ let sigma = project gls in
let rec aux i nc ctx=
if i<=0 then seq else
match nc with
[]->anomaly (Pp.str "Not the expected number of hyps")
| nd::q->
let id = NamedDecl.get_id nd in
- if occur_var env (project gls) id (pf_concl gls) ||
- List.exists (occur_var_in_decl env (project gls) id) ctx then
+ if occur_var env sigma id (pf_concl gls) ||
+ List.exists (occur_var_in_decl env sigma id) ctx then
(aux (i-1) q (nd::ctx))
else
- add_formula Hyp (VarRef id) (EConstr.Unsafe.to_constr (NamedDecl.get_type nd)) (aux (i-1) q (nd::ctx)) gls in
+ add_formula env sigma Hyp (VarRef id) (NamedDecl.get_type nd) (aux (i-1) q (nd::ctx)) in
let seq1=aux n nc [] in
let seq2=if b then
- add_formula Concl dummy_id (EConstr.Unsafe.to_constr (pf_concl gls)) seq1 gls else seq1 in
- continue seq2 gls
+ add_formula env sigma Concl dummy_id (pf_concl gls) seq1 else seq1 in
+ continue seq2
+ end }
let basename_of_global=function
VarRef id->id
| _->assert false
let clear_global=function
- VarRef id-> Proofview.V82.of_tactic (clear [id])
+ VarRef id-> clear [id]
| _->tclIDTAC
(* connection rules *)
-let axiom_tac t seq=
- try pf_constr_of_global (find_left t seq) (fun c -> Proofview.V82.of_tactic (exact_no_check c))
- with Not_found->tclFAIL 0 (Pp.str "No axiom link")
+let axiom_tac t seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ try
+ pf_constr_of_global (find_left (project gl) t seq) >>= fun c ->
+ exact_no_check c
+ with Not_found -> tclFAIL 0 (Pp.str "No axiom link")
+ end }
-let ll_atom_tac a backtrack id continue seq=
+let ll_atom_tac a backtrack id continue seq =
let open EConstr in
tclIFTHENELSE
- (try
- tclTHENLIST
- [pf_constr_of_global (find_left a seq) (fun left ->
- pf_constr_of_global id (fun id ->
- Proofview.V82.of_tactic (generalize [(mkApp(id, [|left|]))])));
+ (tclTHENLIST
+ [(Proofview.tclEVARMAP >>= fun sigma ->
+ let gr =
+ try Proofview.tclUNIT (find_left sigma a seq)
+ with Not_found -> tclFAIL 0 (Pp.str "No link")
+ in
+ gr >>= fun gr ->
+ pf_constr_of_global gr >>= fun left ->
+ pf_constr_of_global id >>= fun id ->
+ generalize [(mkApp(id, [|left|]))]);
clear_global id;
- Proofview.V82.of_tactic intro]
- with Not_found->tclFAIL 0 (Pp.str "No link"))
+ intro])
(wrap 1 false continue seq) backtrack
(* right connectives rules *)
let and_tac backtrack continue seq=
- tclIFTHENELSE (Proofview.V82.of_tactic simplest_split) (wrap 0 true continue seq) backtrack
+ tclIFTHENELSE simplest_split (wrap 0 true continue seq) backtrack
let or_tac backtrack continue seq=
tclORELSE
- (Proofview.V82.of_tactic (any_constructor false (Some (Proofview.V82.tactic (tclCOMPLETE (wrap 0 true continue seq))))))
+ (any_constructor false (Some (tclCOMPLETE (wrap 0 true continue seq))))
backtrack
let arrow_tac backtrack continue seq=
- tclIFTHENELSE (Proofview.V82.of_tactic intro) (wrap 1 true continue seq)
+ tclIFTHENELSE intro (wrap 1 true continue seq)
(tclORELSE
- (tclTHEN (Proofview.V82.of_tactic introf) (tclCOMPLETE (wrap 1 true continue seq)))
+ (tclTHEN introf (tclCOMPLETE (wrap 1 true continue seq)))
backtrack)
(* left connectives rules *)
-let left_and_tac ind backtrack id continue seq gls=
- let n=(construct_nhyps ind gls).(0) in
+let left_and_tac ind backtrack id continue seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let n=(construct_nhyps (pf_env gl) ind).(0) in
tclIFTHENELSE
(tclTHENLIST
- [Proofview.V82.of_tactic (Tacticals.New.pf_constr_of_global id simplest_elim);
+ [(pf_constr_of_global id >>= simplest_elim);
clear_global id;
- tclDO n (Proofview.V82.of_tactic intro)])
+ tclDO n intro])
(wrap n false continue seq)
- backtrack gls
+ backtrack
+ end }
-let left_or_tac ind backtrack id continue seq gls=
- let v=construct_nhyps ind gls in
+let left_or_tac ind backtrack id continue seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let v=construct_nhyps (pf_env gl) ind in
let f n=
tclTHENLIST
[clear_global id;
- tclDO n (Proofview.V82.of_tactic intro);
+ tclDO n intro;
wrap n false continue seq] in
tclIFTHENSVELSE
- (Proofview.V82.of_tactic (Tacticals.New.pf_constr_of_global id simplest_elim))
+ (pf_constr_of_global id >>= simplest_elim)
(Array.map f v)
- backtrack gls
+ backtrack
+ end }
let left_false_tac id=
- Proofview.V82.of_tactic (Tacticals.New.pf_constr_of_global id simplest_elim)
+ Tacticals.New.pf_constr_of_global id >>= simplest_elim
(* left arrow connective rules *)
(* We use this function for false, and, or, exists *)
-let ll_ind_tac (ind,u as indu) largs backtrack id continue seq gl=
- let rcs=ind_hyps 0 indu largs gl in
+let ll_ind_tac (ind,u as indu) largs backtrack id continue seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let rcs=ind_hyps (pf_env gl) (project gl) 0 indu largs in
let vargs=Array.of_list largs in
(* construire le terme H->B, le generaliser etc *)
let myterm idc i=
let rc=rcs.(i) in
let p=List.length rc in
+ let u = EInstance.make u in
let cstr=mkApp ((mkConstructU ((ind,(i+1)),u)),vargs) in
let vars=Array.init p (fun j->mkRel (p-j)) in
let capply=mkApp ((lift p cstr),vars) in
let head=mkApp ((lift p idc),[|capply|]) in
- EConstr.of_constr (it_mkLambda_or_LetIn head rc) in
+ EConstr.it_mkLambda_or_LetIn head rc in
let lp=Array.length rcs in
- let newhyps idc =List.init lp (myterm (EConstr.Unsafe.to_constr idc)) in
+ let newhyps idc =List.init lp (myterm idc) in
tclIFTHENELSE
(tclTHENLIST
- [pf_constr_of_global id (fun idc -> Proofview.V82.of_tactic (generalize (newhyps idc)));
+ [(pf_constr_of_global id >>= fun idc -> generalize (newhyps idc));
clear_global id;
- tclDO lp (Proofview.V82.of_tactic intro)])
- (wrap lp false continue seq) backtrack gl
+ tclDO lp intro])
+ (wrap lp false continue seq) backtrack
+ end }
let ll_arrow_tac a b c backtrack id continue seq=
let open EConstr in
let open Vars in
- let a = EConstr.of_constr a in
- let b = EConstr.of_constr b in
- let c = EConstr.of_constr c in
let cc=mkProd(Anonymous,a,(lift 1 b)) in
let d idc = mkLambda (Anonymous,b,
mkApp (idc, [|mkLambda (Anonymous,(lift 1 a),(mkRel 2))|])) in
tclORELSE
- (tclTHENS (Proofview.V82.of_tactic (cut c))
+ (tclTHENS (cut c)
[tclTHENLIST
- [Proofview.V82.of_tactic introf;
+ [introf;
clear_global id;
wrap 1 false continue seq];
- tclTHENS (Proofview.V82.of_tactic (cut cc))
- [pf_constr_of_global id (fun c -> Proofview.V82.of_tactic (exact_no_check c));
+ tclTHENS (cut cc)
+ [(pf_constr_of_global id >>= fun c -> exact_no_check c);
tclTHENLIST
- [pf_constr_of_global id (fun idc -> Proofview.V82.of_tactic (generalize [d idc]));
+ [(pf_constr_of_global id >>= fun idc -> generalize [d idc]);
clear_global id;
- Proofview.V82.of_tactic introf;
- Proofview.V82.of_tactic introf;
+ introf;
+ introf;
tclCOMPLETE (wrap 2 true continue seq)]]])
backtrack
@@ -171,38 +189,40 @@ let ll_arrow_tac a b c backtrack id continue seq=
let forall_tac backtrack continue seq=
tclORELSE
- (tclIFTHENELSE (Proofview.V82.of_tactic intro) (wrap 0 true continue seq)
+ (tclIFTHENELSE intro (wrap 0 true continue seq)
(tclORELSE
- (tclTHEN (Proofview.V82.of_tactic introf) (tclCOMPLETE (wrap 0 true continue seq)))
+ (tclTHEN introf (tclCOMPLETE (wrap 0 true continue seq)))
backtrack))
(if !qflag then
tclFAIL 0 (Pp.str "reversible in 1st order mode")
else
backtrack)
-let left_exists_tac ind backtrack id continue seq gls=
- let n=(construct_nhyps ind gls).(0) in
+let left_exists_tac ind backtrack id continue seq =
+ Proofview.Goal.enter { enter = begin fun gl ->
+ let n=(construct_nhyps (pf_env gl) ind).(0) in
tclIFTHENELSE
- (Proofview.V82.of_tactic (Tacticals.New.pf_constr_of_global id simplest_elim))
+ (Tacticals.New.pf_constr_of_global id >>= simplest_elim)
(tclTHENLIST [clear_global id;
- tclDO n (Proofview.V82.of_tactic intro);
+ tclDO n intro;
(wrap (n-1) false continue seq)])
backtrack
- gls
+ end }
let ll_forall_tac prod backtrack id continue seq=
tclORELSE
- (tclTHENS (Proofview.V82.of_tactic (cut (EConstr.of_constr prod)))
+ (tclTHENS (cut prod)
[tclTHENLIST
- [Proofview.V82.of_tactic intro;
- pf_constr_of_global id (fun idc ->
- (fun gls->
+ [intro;
+ (pf_constr_of_global id >>= fun idc ->
+ Proofview.Goal.enter { enter = begin fun gls->
let open EConstr in
- let id0=pf_nth_hyp_id gls 1 in
+ let id0 = List.nth (pf_ids_of_hyps gls) 0 in
let term=mkApp(idc,[|mkVar(id0)|]) in
- tclTHEN (Proofview.V82.of_tactic (generalize [term])) (Proofview.V82.of_tactic (clear [id0])) gls));
+ tclTHEN (generalize [term]) (clear [id0])
+ end });
clear_global id;
- Proofview.V82.of_tactic intro;
+ intro;
tclCOMPLETE (wrap 1 false continue (deepen seq))];
tclCOMPLETE (wrap 0 true continue (deepen seq))])
backtrack
@@ -214,12 +234,13 @@ let ll_forall_tac prod backtrack id continue seq=
let constant str = Coqlib.gen_constant "User" ["Init";"Logic"] str
let defined_connectives=lazy
- [AllOccurrences,EvalConstRef (fst (destConst (constant "not")));
- AllOccurrences,EvalConstRef (fst (destConst (constant "iff")))]
+ [AllOccurrences,EvalConstRef (fst (Term.destConst (constant "not")));
+ AllOccurrences,EvalConstRef (fst (Term.destConst (constant "iff")))]
let normalize_evaluables=
- onAllHypsAndConcl
- (function
- None-> Proofview.V82.of_tactic (unfold_in_concl (Lazy.force defined_connectives))
- | Some id ->
- Proofview.V82.of_tactic (unfold_in_hyp (Lazy.force defined_connectives) (id,InHypTypeOnly)))
+ Proofview.Goal.enter { enter = begin fun gl ->
+ unfold_in_concl (Lazy.force defined_connectives) <*>
+ tclMAP
+ (fun id -> unfold_in_hyp (Lazy.force defined_connectives) (id,InHypTypeOnly))
+ (pf_ids_of_hyps gl)
+ end }
diff --git a/plugins/firstorder/rules.mli b/plugins/firstorder/rules.mli
index 381b7cd87c..fb21730830 100644
--- a/plugins/firstorder/rules.mli
+++ b/plugins/firstorder/rules.mli
@@ -7,10 +7,12 @@
(************************************************************************)
open Term
-open Tacmach
+open EConstr
open Names
open Globnames
+type tactic = unit Proofview.tactic
+
type seqtac= (Sequent.t -> tactic) -> Sequent.t -> tactic
type lseqtac= global_reference -> seqtac
diff --git a/plugins/firstorder/sequent.ml b/plugins/firstorder/sequent.ml
index fb0c22c2b7..2d18b66054 100644
--- a/plugins/firstorder/sequent.ml
+++ b/plugins/firstorder/sequent.ml
@@ -7,11 +7,11 @@
(************************************************************************)
open Term
+open EConstr
open CErrors
open Util
open Formula
open Unify
-open Tacmach
open Globnames
open Pp
@@ -57,11 +57,11 @@ end
module OrderedConstr=
struct
- type t=constr
+ type t=Constr.t
let compare=constr_ord
end
-type h_item = global_reference * (int*constr) option
+type h_item = global_reference * (int*Constr.t) option
module Hitem=
struct
@@ -81,13 +81,15 @@ module CM=Map.Make(OrderedConstr)
module History=Set.Make(Hitem)
-let cm_add typ nam cm=
+let cm_add sigma typ nam cm=
+ let typ = EConstr.to_constr sigma typ in
try
let l=CM.find typ cm in CM.add typ (nam::l) cm
with
Not_found->CM.add typ [nam] cm
-let cm_remove typ nam cm=
+let cm_remove sigma typ nam cm=
+ let typ = EConstr.to_constr sigma typ in
try
let l=CM.find typ cm in
let l0=List.filter (fun id-> not (Globnames.eq_gr id nam)) l in
@@ -112,19 +114,19 @@ let deepen seq={seq with depth=seq.depth-1}
let record item seq={seq with history=History.add item seq.history}
-let lookup item seq=
+let lookup sigma item seq=
History.mem item seq.history ||
match item with
(_,None)->false
- | (id,Some ((m,t) as c))->
+ | (id,Some (m, t))->
let p (id2,o)=
match o with
None -> false
- | Some ((m2,t2) as c2)-> Globnames.eq_gr id id2 && m2>m && more_general c2 c in
+ | Some (m2, t2)-> Globnames.eq_gr id id2 && m2>m && more_general sigma (m2, EConstr.of_constr t2) (m, EConstr.of_constr t) in
History.exists p seq.history
-let add_formula side nam t seq gl=
- match build_formula side nam t gl seq.cnt with
+let add_formula env sigma side nam t seq =
+ match build_formula env sigma side nam t seq.cnt with
Left f->
begin
match side with
@@ -136,7 +138,7 @@ let add_formula side nam t seq gl=
| _ ->
{seq with
redexes=HP.add f seq.redexes;
- context=cm_add f.constr nam seq.context}
+ context=cm_add sigma f.constr nam seq.context}
end
| Right t->
match side with
@@ -144,18 +146,18 @@ let add_formula side nam t seq gl=
{seq with gl=t;glatom=Some t}
| _ ->
{seq with
- context=cm_add t nam seq.context;
+ context=cm_add sigma t nam seq.context;
latoms=t::seq.latoms}
-let re_add_formula_list lf seq=
+let re_add_formula_list sigma lf seq=
let do_one f cm=
if f.id == dummy_id then cm
- else cm_add f.constr f.id cm in
+ else cm_add sigma f.constr f.id cm in
{seq with
redexes=List.fold_right HP.add lf seq.redexes;
context=List.fold_right do_one lf seq.context}
-let find_left t seq=List.hd (CM.find t seq.context)
+let find_left sigma t seq=List.hd (CM.find (EConstr.to_constr sigma t) seq.context)
(*let rev_left seq=
try
@@ -164,7 +166,7 @@ let find_left t seq=List.hd (CM.find t seq.context)
with Heap.EmptyHeap -> false
*)
-let rec take_formula seq=
+let rec take_formula sigma seq=
let hd=HP.maximum seq.redexes
and hp=HP.remove seq.redexes in
if hd.id == dummy_id then
@@ -172,11 +174,11 @@ let rec take_formula seq=
if seq.gl==hd.constr then
hd,nseq
else
- take_formula nseq (* discarding deprecated goal *)
+ take_formula sigma nseq (* discarding deprecated goal *)
else
hd,{seq with
redexes=hp;
- context=cm_remove hd.constr hd.id seq.context}
+ context=cm_remove sigma hd.constr hd.id seq.context}
let empty_seq depth=
{redexes=HP.empty;
@@ -196,18 +198,17 @@ let expand_constructor_hints =
| gr ->
[gr])
-let extend_with_ref_list l seq gl =
+let extend_with_ref_list env sigma l seq =
let l = expand_constructor_hints l in
- let f gr (seq,gl) =
- let gl, c = pf_eapply Evd.fresh_global gl gr in
- let typ=(pf_unsafe_type_of gl (EConstr.of_constr c)) in
- let typ = EConstr.Unsafe.to_constr typ in
- (add_formula Hyp gr typ seq gl,gl) in
- List.fold_right f l (seq,gl)
+ let f gr (seq, sigma) =
+ let sigma, c = Evd.fresh_global env sigma gr in
+ let sigma, typ= Typing.type_of env sigma (EConstr.of_constr c) in
+ (add_formula env sigma Hyp gr typ seq, sigma) in
+ List.fold_right f l (seq, sigma)
open Hints
-let extend_with_auto_hints l seq gl=
+let extend_with_auto_hints env sigma l seq =
let seqref=ref seq in
let f p_a_t =
match repr_hint p_a_t.code with
@@ -215,10 +216,9 @@ let extend_with_auto_hints l seq gl=
| Res_pf_THEN_trivial_fail (c,_) ->
let (c, _, _) = c in
(try
- let (gr, _) = Termops.global_of_constr (project gl) c in
- let typ=(pf_unsafe_type_of gl c) in
- let typ = EConstr.Unsafe.to_constr typ in
- seqref:=add_formula Hint gr typ !seqref gl
+ let (gr, _) = Termops.global_of_constr sigma c in
+ let typ=(Typing.unsafe_type_of env sigma c) in
+ seqref:=add_formula env sigma Hint gr typ !seqref
with Not_found->())
| _-> () in
let g _ _ l = List.iter f l in
@@ -230,7 +230,7 @@ let extend_with_auto_hints l seq gl=
error ("Firstorder: "^dbname^" : No such Hint database") in
Hint_db.iter g hdb in
List.iter h l;
- !seqref, gl (*FIXME: forgetting about universes*)
+ !seqref, sigma (*FIXME: forgetting about universes*)
let print_cmap map=
let print_entry c l s=
diff --git a/plugins/firstorder/sequent.mli b/plugins/firstorder/sequent.mli
index 06c9251e7b..6ed251f34e 100644
--- a/plugins/firstorder/sequent.mli
+++ b/plugins/firstorder/sequent.mli
@@ -6,23 +6,22 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Term
+open EConstr
open Formula
-open Tacmach
open Globnames
-module OrderedConstr: Set.OrderedType with type t=constr
+module OrderedConstr: Set.OrderedType with type t=Constr.t
-module CM: CSig.MapS with type key=constr
+module CM: CSig.MapS with type key=Constr.t
-type h_item = global_reference * (int*constr) option
+type h_item = global_reference * (int*Constr.t) option
module History: Set.S with type elt = h_item
-val cm_add : constr -> global_reference -> global_reference list CM.t ->
+val cm_add : Evd.evar_map -> constr -> global_reference -> global_reference list CM.t ->
global_reference list CM.t
-val cm_remove : constr -> global_reference -> global_reference list CM.t ->
+val cm_remove : Evd.evar_map -> constr -> global_reference -> global_reference list CM.t ->
global_reference list CM.t
module HP: Heap.S with type elt=Formula.t
@@ -40,23 +39,22 @@ val deepen: t -> t
val record: h_item -> t -> t
-val lookup: h_item -> t -> bool
+val lookup: Evd.evar_map -> h_item -> t -> bool
-val add_formula : side -> global_reference -> constr -> t ->
- Proof_type.goal sigma -> t
+val add_formula : Environ.env -> Evd.evar_map -> side -> global_reference -> constr -> t -> t
-val re_add_formula_list : Formula.t list -> t -> t
+val re_add_formula_list : Evd.evar_map -> Formula.t list -> t -> t
-val find_left : constr -> t -> global_reference
+val find_left : Evd.evar_map -> constr -> t -> global_reference
-val take_formula : t -> Formula.t * t
+val take_formula : Evd.evar_map -> t -> Formula.t * t
val empty_seq : int -> t
-val extend_with_ref_list : global_reference list ->
- t -> Proof_type.goal sigma -> t * Proof_type.goal sigma
+val extend_with_ref_list : Environ.env -> Evd.evar_map -> global_reference list ->
+ t -> t * Evd.evar_map
-val extend_with_auto_hints : Hints.hint_db_name list ->
- t -> Proof_type.goal sigma -> t * Proof_type.goal sigma
+val extend_with_auto_hints : Environ.env -> Evd.evar_map -> Hints.hint_db_name list ->
+ t -> t * Evd.evar_map
val print_cmap: global_reference list CM.t -> Pp.std_ppcmds
diff --git a/plugins/firstorder/unify.ml b/plugins/firstorder/unify.ml
index 7cbfb8e7de..49bf07155f 100644
--- a/plugins/firstorder/unify.ml
+++ b/plugins/firstorder/unify.ml
@@ -8,6 +8,7 @@
open Util
open Term
+open EConstr
open Vars
open Termops
open Reductionops
@@ -21,13 +22,12 @@ exception UFAIL of constr*constr
to the equation set. Raises UFAIL with a pair of terms
*)
-let strip_outer_cast t =
- EConstr.Unsafe.to_constr (strip_outer_cast Evd.empty (EConstr.of_constr t)) (** FIXME *)
-
let pop t = Vars.lift (-1) t
+let subst_meta subst t =
+ let subst = List.map (fun (m, c) -> (m, EConstr.Unsafe.to_constr c)) subst in
+ EConstr.of_constr (subst_meta subst (EConstr.Unsafe.to_constr t))
-let unif t1 t2=
- let evd = Evd.empty in (** FIXME *)
+let unif evd t1 t2=
let bige=Queue.create ()
and sigma=ref [] in
let bind i t=
@@ -35,7 +35,7 @@ let unif t1 t2=
(List.map (function (n,tn)->(n,subst_meta [i,t] tn)) !sigma) in
let rec head_reduce t=
(* forbids non-sigma-normal meta in head position*)
- match kind_of_term t with
+ match EConstr.kind evd t with
Meta i->
(try
head_reduce (Int.List.assoc i !sigma)
@@ -44,25 +44,25 @@ let unif t1 t2=
Queue.add (t1,t2) bige;
try while true do
let t1,t2=Queue.take bige in
- let nt1=head_reduce (EConstr.Unsafe.to_constr (whd_betaiotazeta evd (EConstr.of_constr t1)))
- and nt2=head_reduce (EConstr.Unsafe.to_constr (whd_betaiotazeta evd (EConstr.of_constr t2))) in
- match (kind_of_term nt1),(kind_of_term nt2) with
+ let nt1=head_reduce (whd_betaiotazeta evd t1)
+ and nt2=head_reduce (whd_betaiotazeta evd t2) in
+ match (EConstr.kind evd nt1),(EConstr.kind evd nt2) with
Meta i,Meta j->
if not (Int.equal i j) then
if i<j then bind j nt1
else bind i nt2
| Meta i,_ ->
let t=subst_meta !sigma nt2 in
- if Int.Set.is_empty (free_rels evd (EConstr.of_constr t)) &&
- not (occur_term evd (EConstr.mkMeta i) (EConstr.of_constr t)) then
+ if Int.Set.is_empty (free_rels evd t) &&
+ not (occur_term evd (EConstr.mkMeta i) t) then
bind i t else raise (UFAIL(nt1,nt2))
| _,Meta i ->
let t=subst_meta !sigma nt1 in
- if Int.Set.is_empty (free_rels evd (EConstr.of_constr t)) &&
- not (occur_term evd (EConstr.mkMeta i) (EConstr.of_constr t)) then
+ if Int.Set.is_empty (free_rels evd t) &&
+ not (occur_term evd (EConstr.mkMeta i) t) then
bind i t else raise (UFAIL(nt1,nt2))
- | Cast(_,_,_),_->Queue.add (strip_outer_cast nt1,nt2) bige
- | _,Cast(_,_,_)->Queue.add (nt1,strip_outer_cast nt2) bige
+ | Cast(_,_,_),_->Queue.add (strip_outer_cast evd nt1,nt2) bige
+ | _,Cast(_,_,_)->Queue.add (nt1,strip_outer_cast evd nt2) bige
| (Prod(_,a,b),Prod(_,c,d))|(Lambda(_,a,b),Lambda(_,c,d))->
Queue.add (a,c) bige;Queue.add (pop b,pop d) bige
| Case (_,pa,ca,va),Case (_,pb,cb,vb)->
@@ -84,19 +84,19 @@ let unif t1 t2=
for i=0 to l-1 do
Queue.add (va.(i),vb.(i)) bige
done
- | _->if not (eq_constr_nounivs nt1 nt2) then raise (UFAIL (nt1,nt2))
+ | _->if not (eq_constr_nounivs evd nt1 nt2) then raise (UFAIL (nt1,nt2))
done;
assert false
(* this place is unreachable but needed for the sake of typing *)
with Queue.Empty-> !sigma
-let value i t=
+let value evd i t=
let add x y=
if x<0 then y else if y<0 then x else x+y in
let rec vaux term=
- if isMeta term && Int.equal (destMeta term) i then 0 else
+ if isMeta evd term && Int.equal (destMeta evd term) i then 0 else
let f v t=add v (vaux t) in
- let vr=fold_constr f (-1) term in
+ let vr=EConstr.fold evd f (-1) term in
if vr<0 then -1 else vr+1 in
vaux t
@@ -104,11 +104,11 @@ type instance=
Real of (int*constr)*int
| Phantom of constr
-let mk_rel_inst t=
+let mk_rel_inst evd t=
let new_rel=ref 1 in
let rel_env=ref [] in
let rec renum_rec d t=
- match kind_of_term t with
+ match EConstr.kind evd t with
Meta n->
(try
mkRel (d+(Int.List.assoc n !rel_env))
@@ -117,15 +117,15 @@ let mk_rel_inst t=
incr new_rel;
rel_env:=(n,m) :: !rel_env;
mkRel (m+d))
- | _ -> map_constr_with_binders succ renum_rec d t
+ | _ -> EConstr.map_with_binders evd succ renum_rec d t
in
let nt=renum_rec 0 t in (!new_rel - 1,nt)
-let unif_atoms i dom t1 t2=
+let unif_atoms evd i dom t1 t2=
try
- let t=Int.List.assoc i (unif t1 t2) in
- if isMeta t then Some (Phantom dom)
- else Some (Real(mk_rel_inst t,value i t1))
+ let t=Int.List.assoc i (unif evd t1 t2) in
+ if isMeta evd t then Some (Phantom dom)
+ else Some (Real(mk_rel_inst evd t,value evd i t1))
with
UFAIL(_,_) ->None
| Not_found ->Some (Phantom dom)
@@ -134,11 +134,11 @@ let renum_metas_from k n t= (* requires n = max (free_rels t) *)
let l=List.init n (fun i->mkMeta (k+i)) in
substl l t
-let more_general (m1,t1) (m2,t2)=
+let more_general evd (m1,t1) (m2,t2)=
let mt1=renum_metas_from 0 m1 t1
and mt2=renum_metas_from m1 m2 t2 in
try
- let sigma=unif mt1 mt2 in
- let p (n,t)= n<m1 || isMeta t in
+ let sigma=unif evd mt1 mt2 in
+ let p (n,t)= n<m1 || isMeta evd t in
List.for_all p sigma
with UFAIL(_,_)->false
diff --git a/plugins/firstorder/unify.mli b/plugins/firstorder/unify.mli
index 4fe9ad38d8..c9cca9bd8d 100644
--- a/plugins/firstorder/unify.mli
+++ b/plugins/firstorder/unify.mli
@@ -7,15 +7,16 @@
(************************************************************************)
open Term
+open EConstr
exception UFAIL of constr*constr
-val unif : constr -> constr -> (int*constr) list
+val unif : Evd.evar_map -> constr -> constr -> (int*constr) list
type instance=
Real of (int*constr)*int (* nb trous*terme*valeur heuristique *)
| Phantom of constr (* domaine de quantification *)
-val unif_atoms : metavariable -> constr -> constr -> constr -> instance option
+val unif_atoms : Evd.evar_map -> metavariable -> constr -> constr -> constr -> instance option
-val more_general : (int*constr) -> (int*constr) -> bool
+val more_general : Evd.evar_map -> (int*constr) -> (int*constr) -> bool
diff --git a/plugins/fourier/fourierR.ml b/plugins/fourier/fourierR.ml
index e11cbc279a..25d8f8c832 100644
--- a/plugins/fourier/fourierR.ml
+++ b/plugins/fourier/fourierR.ml
@@ -617,9 +617,9 @@ let rec fourier () =
[Tacticals.New.tclORELSE
(* TODO : Ring.polynom []*) (Proofview.tclUNIT ())
(Proofview.tclUNIT ());
- Tacticals.New.pf_constr_of_global (cget coq_sym_eqT) (fun symeq ->
+ Tacticals.New.pf_constr_of_global (cget coq_sym_eqT) >>= fun symeq ->
(Tacticals.New.tclTHEN (apply symeq)
- (apply (get coq_Rinv_1))))]
+ (apply (get coq_Rinv_1)))]
)
]));
diff --git a/plugins/funind/functional_principles_proofs.ml b/plugins/funind/functional_principles_proofs.ml
index 48c0f5f04c..55d361e3d2 100644
--- a/plugins/funind/functional_principles_proofs.ml
+++ b/plugins/funind/functional_principles_proofs.ml
@@ -19,12 +19,6 @@ open Context.Rel.Declaration
module RelDecl = Context.Rel.Declaration
-let local_assum (na, t) =
- RelDecl.LocalAssum (na, EConstr.Unsafe.to_constr t)
-
-let local_def (na, b, t) =
- RelDecl.LocalDef (na, EConstr.Unsafe.to_constr b, EConstr.Unsafe.to_constr t)
-
(* let msgnl = Pp.msgnl *)
(*
@@ -235,12 +229,13 @@ let nf_betaiotazeta = (* Reductionops.local_strong Reductionops.whd_betaiotazeta
Reductionops.clos_norm_flags CClosure.betaiotazeta Environ.empty_env Evd.empty
+exception NoChange
let change_eq env sigma hyp_id (context:rel_context) x t end_of_type =
let nochange ?t' msg =
begin
observe (str ("Not treating ( "^msg^" )") ++ pr_leconstr t ++ str " " ++ match t' with None -> str "" | Some t -> Printer.pr_leconstr t );
- failwith "NoChange";
+ raise NoChange;
end
in
let eq_constr c1 c2 = Evarconv.e_conv env (ref sigma) c1 c2 in
@@ -299,7 +294,7 @@ let change_eq env sigma hyp_id (context:rel_context) x t end_of_type =
Can be safely replaced by the next comment for Ocaml >= 3.08.4
*)
let sub = Int.Map.bindings sub in
- List.fold_left (fun end_of_type (i,t) -> lift 1 (substnl [t] (i-1) end_of_type))
+ List.fold_left (fun end_of_type (i,t) -> liftn 1 i (substnl [t] (i-1) end_of_type))
end_of_type_with_pop
sub
in
@@ -542,7 +537,7 @@ let clean_hyp_with_heq ptes_infos eq_hyps hyp_id env sigma =
tclTHEN
tac
(scan_type new_context new_t')
- with Failure "NoChange" ->
+ with NoChange ->
(* Last thing todo : push the rel in the context and continue *)
scan_type (LocalAssum (x,t_x) :: context) t'
end
@@ -1401,8 +1396,8 @@ let prove_princ_for_struct (evd:Evd.evar_map ref) interactive_proof fun_num fnam
let prove_with_tcc tcc_lemma_constr eqs : tactic =
match !tcc_lemma_constr with
- | None -> anomaly (Pp.str "No tcc proof !!")
- | Some lemma ->
+ | Undefined -> anomaly (Pp.str "No tcc proof !!")
+ | Value lemma ->
fun gls ->
(* let hid = next_ident_away_in_goal h_id (pf_ids_of_hyps gls) in *)
(* let ids = hid::pf_ids_of_hyps gls in *)
@@ -1420,7 +1415,7 @@ let prove_with_tcc tcc_lemma_constr eqs : tactic =
Proofview.V82.of_tactic (Eauto.gen_eauto (false,5) [] (Some []))
]
gls
-
+ | Not_needed -> tclIDTAC
let backtrack_eqs_until_hrec hrec eqs : tactic =
fun gls ->
@@ -1599,8 +1594,9 @@ let prove_principle_for_gen
let args_ids = List.map (get_name %> Nameops.out_name) princ_info.args in
let lemma =
match !tcc_lemma_ref with
- | None -> error "No tcc proof !!"
- | Some lemma -> EConstr.of_constr lemma
+ | Undefined -> error "No tcc proof !!"
+ | Value lemma -> EConstr.of_constr lemma
+ | Not_needed -> EConstr.of_constr (Coqlib.build_coq_I ())
in
(* let rec list_diff del_list check_list = *)
(* match del_list with *)
diff --git a/plugins/funind/functional_principles_proofs.mli b/plugins/funind/functional_principles_proofs.mli
index 769d726d70..61752aa339 100644
--- a/plugins/funind/functional_principles_proofs.mli
+++ b/plugins/funind/functional_principles_proofs.mli
@@ -1,5 +1,4 @@
open Names
-open Term
val prove_princ_for_struct :
Evd.evar_map ref ->
@@ -9,7 +8,7 @@ val prove_princ_for_struct :
val prove_principle_for_gen :
constant*constant*constant -> (* name of the function, the functional and the fixpoint equation *)
- constr option ref -> (* a pointer to the obligation proofs lemma *)
+ Indfun_common.tcc_lemma_value ref -> (* a pointer to the obligation proofs lemma *)
bool -> (* is that function uses measure *)
int -> (* the number of recursive argument *)
EConstr.types -> (* the type of the recursive argument *)
diff --git a/plugins/funind/g_indfun.ml4 b/plugins/funind/g_indfun.ml4
index 0dccd25d75..b5eacee818 100644
--- a/plugins/funind/g_indfun.ml4
+++ b/plugins/funind/g_indfun.ml4
@@ -8,7 +8,6 @@
(*i camlp4deps: "grammar/grammar.cma" i*)
open Ltac_plugin
open Util
-open Term
open Pp
open Constrexpr
open Indfun_common
diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml
index ebeddf5f65..d335836dfc 100644
--- a/plugins/funind/indfun.ml
+++ b/plugins/funind/indfun.ml
@@ -156,7 +156,7 @@ let build_newrecursive
let (rec_sign,rec_impls) =
List.fold_left
(fun (env,impls) (((_,recname),_),bl,arityc,_) ->
- let arityc = Constrexpr_ops.prod_constr_expr arityc bl in
+ let arityc = Constrexpr_ops.mkCProdN Loc.ghost bl arityc in
let arity,ctx = Constrintern.interp_type env0 sigma arityc in
let evdref = ref (Evd.from_env env0) in
let _, (_, impls') = Constrintern.interp_context_evars env evdref bl in
@@ -453,7 +453,7 @@ let generate_correction_proof_wf f_ref tcc_lemma_ref
let register_wf ?(is_mes=false) fname rec_impls wf_rel_expr wf_arg using_lemmas args ret_type body
pre_hook
=
- let type_of_f = Constrexpr_ops.prod_constr_expr ret_type args in
+ let type_of_f = Constrexpr_ops.mkCProdN Loc.ghost args ret_type in
let rec_arg_num =
let names =
List.map
@@ -484,7 +484,7 @@ let register_wf ?(is_mes=false) fname rec_impls wf_rel_expr wf_arg using_lemmas
Constrexpr.CApp (Loc.ghost,(None,Constrexpr_ops.mkRefC (Qualid (Loc.ghost,(qualid_of_string "Logic.eq")))),
[(f_app_args,None);(body,None)])
in
- let eq = Constrexpr_ops.prod_constr_expr unbounded_eq args in
+ let eq = Constrexpr_ops.mkCProdN Loc.ghost args unbounded_eq in
let hook ((f_ref,_) as fconst) tcc_lemma_ref (functional_ref,_) (eq_ref,_) rec_arg_num rec_arg_type
nb_args relation =
try
diff --git a/plugins/funind/indfun_common.ml b/plugins/funind/indfun_common.ml
index 20da12f395..848b44a603 100644
--- a/plugins/funind/indfun_common.ml
+++ b/plugins/funind/indfun_common.ml
@@ -21,12 +21,9 @@ let get_name avoid ?(default="H") = function
| Name n -> Name n
let array_get_start a =
- try
- Array.init
- (Array.length a - 1)
- (fun i -> a.(i))
- with Invalid_argument "index out of bounds" ->
- invalid_arg "array_get_start"
+ Array.init
+ (Array.length a - 1)
+ (fun i -> a.(i))
let id_of_name = function
Name id -> id
@@ -508,7 +505,6 @@ let list_rewrite (rev:bool) (eqs: (EConstr.constr*bool) list) =
(if rev then (List.rev eqs) else eqs) (tclFAIL 0 (mt())));;
let decompose_lam_n sigma n =
- let open EConstr in
if n < 0 then CErrors.error "decompose_lam_n: integer parameter must be positive";
let rec lamdec_rec l n c =
if Int.equal n 0 then l,c
@@ -543,3 +539,8 @@ let prodn n env b =
(* compose_prod [xn:Tn;..;x1:T1] b = (x1:T1)..(xn:Tn)b *)
let compose_prod l b = prodn (List.length l) l b
+
+type tcc_lemma_value =
+ | Undefined
+ | Value of Constr.constr
+ | Not_needed
diff --git a/plugins/funind/indfun_common.mli b/plugins/funind/indfun_common.mli
index 5c3e73e9d7..5ef8f05bb7 100644
--- a/plugins/funind/indfun_common.mli
+++ b/plugins/funind/indfun_common.mli
@@ -119,3 +119,8 @@ val decompose_lam_n : Evd.evar_map -> int -> EConstr.t ->
(Names.Name.t * EConstr.t) list * EConstr.t
val compose_lam : (Names.Name.t * EConstr.t) list -> EConstr.t -> EConstr.t
val compose_prod : (Names.Name.t * EConstr.t) list -> EConstr.t -> EConstr.t
+
+type tcc_lemma_value =
+ | Undefined
+ | Value of Constr.constr
+ | Not_needed
diff --git a/plugins/funind/invfun.ml b/plugins/funind/invfun.ml
index 94ec0a898a..6c0c28905e 100644
--- a/plugins/funind/invfun.ml
+++ b/plugins/funind/invfun.ml
@@ -7,7 +7,6 @@
(************************************************************************)
open Ltac_plugin
-open Tacexpr
open Declarations
open CErrors
open Util
@@ -1026,7 +1025,7 @@ let invfun qhyp f =
| Not_found -> error "No graph found"
| Option.IsNone -> error "Cannot use equivalence with graph!"
-
+exception NoFunction
let invfun qhyp f g =
match f with
| Some f -> invfun qhyp f g
@@ -1041,23 +1040,23 @@ let invfun qhyp f g =
begin
let f1,_ = decompose_app sigma args.(1) in
try
- if not (isConst sigma f1) then failwith "";
+ if not (isConst sigma f1) then raise NoFunction;
let finfos = find_Function_infos (fst (destConst sigma f1)) in
let f_correct = mkConst(Option.get finfos.correctness_lemma)
and kn = fst finfos.graph_ind
in
functional_inversion kn hid f1 f_correct g
- with | Failure "" | Option.IsNone | Not_found ->
+ with | NoFunction | Option.IsNone | Not_found ->
try
let f2,_ = decompose_app sigma args.(2) in
- if not (isConst sigma f2) then failwith "";
+ if not (isConst sigma f2) then raise NoFunction;
let finfos = find_Function_infos (fst (destConst sigma f2)) in
let f_correct = mkConst(Option.get finfos.correctness_lemma)
and kn = fst finfos.graph_ind
in
functional_inversion kn hid f2 f_correct g
with
- | Failure "" ->
+ | NoFunction ->
user_err (str "Hypothesis " ++ Ppconstr.pr_id hid ++ str " must contain at least one Function")
| Option.IsNone ->
if do_observe ()
diff --git a/plugins/funind/merge.ml b/plugins/funind/merge.ml
index f1ca575856..0af0898a0a 100644
--- a/plugins/funind/merge.ml
+++ b/plugins/funind/merge.ml
@@ -19,7 +19,6 @@ open Pp
open Names
open Term
open Vars
-open Termops
open Declarations
open Glob_term
open Glob_termops
diff --git a/plugins/funind/recdef.ml b/plugins/funind/recdef.ml
index 5460d6fb73..bd30f11596 100644
--- a/plugins/funind/recdef.ml
+++ b/plugins/funind/recdef.ml
@@ -45,12 +45,6 @@ open Indfun_common
open Sigma.Notations
open Context.Rel.Declaration
-let local_assum (na, t) =
- LocalAssum (na, EConstr.Unsafe.to_constr t)
-
-let local_def (na, b, t) =
- LocalDef (na, EConstr.Unsafe.to_constr b, EConstr.Unsafe.to_constr t)
-
(* Ugly things which should not be here *)
let coq_constant m s =
@@ -1231,6 +1225,7 @@ let get_current_subgoals_types () =
let { Evd.it=sgs ; sigma=sigma } = Proof.V82.subgoals p in
sigma, List.map (Goal.V82.abstract_type sigma) sgs
+exception EmptySubgoals
let build_and_l sigma l =
let and_constr = Coqlib.build_coq_and () in
let conj_constr = coq_conj () in
@@ -1252,7 +1247,7 @@ let build_and_l sigma l =
in
let l = List.sort compare l in
let rec f = function
- | [] -> failwith "empty list of subgoals!"
+ | [] -> raise EmptySubgoals
| [p] -> p,tclIDTAC,1
| p1::pl ->
let c,tac,nb = f pl in
@@ -1323,7 +1318,7 @@ let open_new_goal build_proof sigma using_lemmas ref_ goal_name (gls_type,decomp
| _ -> anomaly ~label:"equation_lemma" (Pp.str "not a constant")
in
let lemma = mkConst (Names.Constant.make1 (Lib.make_kn na)) in
- ref_ := Some (EConstr.Unsafe.to_constr lemma);
+ ref_ := Value (EConstr.Unsafe.to_constr lemma);
let lid = ref [] in
let h_num = ref (-1) in
let env = Global.env () in
@@ -1411,7 +1406,7 @@ let open_new_goal build_proof sigma using_lemmas ref_ goal_name (gls_type,decomp
let com_terminate
tcc_lemma_name
- (tcc_lemma_ref : Constr.t option ref)
+ tcc_lemma_ref
is_mes
fonctional_ref
input_type
@@ -1438,8 +1433,9 @@ let com_terminate
using_lemmas tcc_lemma_ref
(Some tcc_lemma_name)
(new_goal_type);
- with Failure "empty list of subgoals!" ->
+ with EmptySubgoals ->
(* a non recursive function declared with measure ! *)
+ tcc_lemma_ref := Not_needed;
defined ()
@@ -1515,7 +1511,6 @@ let (com_eqn : int -> Id.t ->
(* Pp.msgnl (str "eqn finished"); *)
);;
-
let recursive_definition is_mes function_name rec_impls type_of_f r rec_arg_num eq
generate_induction_principle using_lemmas : unit =
let open Term in
@@ -1561,7 +1556,7 @@ let recursive_definition is_mes function_name rec_impls type_of_f r rec_arg_num
in
let evm = Evd.from_ctx evuctx in
let tcc_lemma_name = add_suffix function_name "_tcc" in
- let tcc_lemma_constr = ref None in
+ let tcc_lemma_constr = ref Undefined in
(* let _ = Pp.msgnl (str "relation := " ++ Printer.pr_lconstr_env env_with_pre_rec_args relation) in *)
let hook _ _ =
let term_ref = Nametab.locate (qualid_of_ident term_id) in
@@ -1590,8 +1585,8 @@ let recursive_definition is_mes function_name rec_impls type_of_f r rec_arg_num
and eq_ref = destConst (constr_of_global eq_ref) in
generate_induction_principle f_ref tcc_lemma_constr
functional_ref eq_ref rec_arg_num (EConstr.of_constr rec_arg_type) (nb_prod evm (EConstr.of_constr res)) (EConstr.of_constr relation);
- if Flags.is_verbose ()
- then msgnl (h 1 (Ppconstr.pr_id function_name ++
+ Flags.if_verbose
+ msgnl (h 1 (Ppconstr.pr_id function_name ++
spc () ++ str"is defined" )++ fnl () ++
h 1 (Ppconstr.pr_id equation_id ++
spc () ++ str"is defined" )
diff --git a/plugins/funind/recdef.mli b/plugins/funind/recdef.mli
index 9c1081b9d2..80f02e01c4 100644
--- a/plugins/funind/recdef.mli
+++ b/plugins/funind/recdef.mli
@@ -13,7 +13,7 @@ bool ->
Constrexpr.constr_expr ->
Constrexpr.constr_expr ->
int -> Constrexpr.constr_expr -> (Term.pconstant ->
- Term.constr option ref ->
+ Indfun_common.tcc_lemma_value ref ->
Term.pconstant ->
Term.pconstant -> int -> EConstr.types -> int -> EConstr.constr -> 'a) -> Constrexpr.constr_expr list -> unit
diff --git a/plugins/ltac/evar_tactics.ml b/plugins/ltac/evar_tactics.ml
index 5d3f6df03d..bc9c300e23 100644
--- a/plugins/ltac/evar_tactics.ml
+++ b/plugins/ltac/evar_tactics.ml
@@ -9,7 +9,6 @@
open Util
open Names
open Term
-open EConstr
open CErrors
open Evar_refiner
open Tacmach
diff --git a/plugins/ltac/extratactics.ml4 b/plugins/ltac/extratactics.ml4
index 38fdfb7599..21419d1f92 100644
--- a/plugins/ltac/extratactics.ml4
+++ b/plugins/ltac/extratactics.ml4
@@ -21,7 +21,6 @@ open Tacexpr
open Glob_ops
open CErrors
open Util
-open Evd
open Termops
open Equality
open Misctypes
@@ -52,8 +51,6 @@ let replace_in_clause_maybe_by ist c1 c2 cl tac =
let replace_term ist dir_opt c cl =
with_delayed_uconstr ist c (fun c -> replace_term dir_opt c cl)
-let clause = Pltac.clause_dft_concl
-
TACTIC EXTEND replace
["replace" uconstr(c1) "with" constr(c2) clause(cl) by_arg_tac(tac) ]
-> [ replace_in_clause_maybe_by ist c1 c2 cl tac ]
diff --git a/plugins/ltac/g_auto.ml4 b/plugins/ltac/g_auto.ml4
index dfa8331ff2..50e8255a67 100644
--- a/plugins/ltac/g_auto.ml4
+++ b/plugins/ltac/g_auto.ml4
@@ -16,7 +16,6 @@ open Pcoq.Constr
open Pltac
open Hints
open Tacexpr
-open Proofview.Notations
open Names
DECLARE PLUGIN "g_auto"
diff --git a/plugins/ltac/g_class.ml4 b/plugins/ltac/g_class.ml4
index 40f30c7943..23ce368eea 100644
--- a/plugins/ltac/g_class.ml4
+++ b/plugins/ltac/g_class.ml4
@@ -8,9 +8,7 @@
(*i camlp4deps: "grammar/grammar.cma" i*)
-open Misctypes
open Class_tactics
-open Pltac
open Stdarg
open Tacarg
open Names
@@ -85,7 +83,7 @@ TACTIC EXTEND not_evar
END
TACTIC EXTEND is_ground
- [ "is_ground" constr(ty) ] -> [ Proofview.V82.tactic (is_ground ty) ]
+ [ "is_ground" constr(ty) ] -> [ is_ground ty ]
END
TACTIC EXTEND autoapply
@@ -95,7 +93,6 @@ END
(** TODO: DEPRECATE *)
(* A progress test that allows to see if the evars have changed *)
open Term
-open Proofview.Goal
open Proofview.Notations
let rec eq_constr_mod_evars sigma x y =
diff --git a/plugins/ltac/g_ltac.ml4 b/plugins/ltac/g_ltac.ml4
index ece0adb071..ca5d198c23 100644
--- a/plugins/ltac/g_ltac.ml4
+++ b/plugins/ltac/g_ltac.ml4
@@ -335,7 +335,7 @@ GEXTEND Gram
| IDENT "all"; ":" -> SelectAll ] ]
;
tactic_mode:
- [ [ g = OPT toplevel_selector; tac = G_vernac.subgoal_command -> tac g ] ]
+ [ [ g = OPT toplevel_selector; tac = G_vernac.query_command -> tac g ] ]
;
command:
[ [ IDENT "Proof"; "with"; ta = Pltac.tactic;
diff --git a/plugins/ltac/g_rewrite.ml4 b/plugins/ltac/g_rewrite.ml4
index c50100bf55..ac979bcf89 100644
--- a/plugins/ltac/g_rewrite.ml4
+++ b/plugins/ltac/g_rewrite.ml4
@@ -18,7 +18,7 @@ open Glob_term
open Geninterp
open Extraargs
open Tacmach
-open Tacticals
+open Proofview.Notations
open Rewrite
open Stdarg
open Pcoq.Vernac_
@@ -123,15 +123,19 @@ TACTIC EXTEND rewrite_strat
END
let clsubstitute o c =
+ Proofview.Goal.enter { enter = begin fun gl ->
let is_tac id = match fst (fst (snd c)) with GVar (_, id') when Id.equal id' id -> true | _ -> false in
- Tacticals.onAllHypsAndConcl
+ let hyps = Tacmach.New.pf_ids_of_hyps gl in
+ Tacticals.New.tclMAP
(fun cl ->
match cl with
- | Some id when is_tac id -> tclIDTAC
- | _ -> Proofview.V82.of_tactic (cl_rewrite_clause c o AllOccurrences cl))
+ | Some id when is_tac id -> Tacticals.New.tclIDTAC
+ | _ -> cl_rewrite_clause c o AllOccurrences cl)
+ (None :: List.map (fun id -> Some id) hyps)
+ end }
TACTIC EXTEND substitute
-| [ "substitute" orient(o) glob_constr_with_bindings(c) ] -> [ Proofview.V82.tactic (clsubstitute o c) ]
+| [ "substitute" orient(o) glob_constr_with_bindings(c) ] -> [ clsubstitute o c ]
END
diff --git a/plugins/ltac/pltac.ml b/plugins/ltac/pltac.ml
index 1d21118ae8..7e979d269d 100644
--- a/plugins/ltac/pltac.ml
+++ b/plugins/ltac/pltac.ml
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Names
open Pcoq
(* Main entry for extensions *)
diff --git a/plugins/ltac/pptactic.ml b/plugins/ltac/pptactic.ml
index 39ae1f41d2..b73b66e56f 100644
--- a/plugins/ltac/pptactic.ml
+++ b/plugins/ltac/pptactic.ml
@@ -250,7 +250,7 @@ type 'a extra_genarg_printer =
let pr_alias_key key =
try
let prods = (KNmap.find key !prnotation_tab).pptac_prods in
- let rec pr = function
+ let pr = function
| TacTerm s -> primitive s
| TacNonTerm (_, symb, _) -> str (Printf.sprintf "(%s)" (pr_user_symbol symb))
in
@@ -314,7 +314,7 @@ type 'a extra_genarg_printer =
| Extend.Uentry _ | Extend.Uentryl _ ->
str "ltac:(" ++ prtac (1, Any) arg ++ str ")"
- let rec pr_targ prtac symb arg = match symb with
+ let pr_targ prtac symb arg = match symb with
| Extend.Uentry tag when is_genarg tag (ArgumentType wit_tactic) ->
prtac (1, Any) arg
| Extend.Uentryl (_, l) -> prtac (l, Any) arg
diff --git a/plugins/ltac/profile_ltac.ml b/plugins/ltac/profile_ltac.ml
index 58123f63ef..a853576f25 100644
--- a/plugins/ltac/profile_ltac.ml
+++ b/plugins/ltac/profile_ltac.ml
@@ -136,7 +136,6 @@ let feedback_results results =
let format_sec x = (Printf.sprintf "%.3fs" x)
let format_ratio x = (Printf.sprintf "%.1f%%" (100. *. x))
let padl n s = ws (max 0 (n - utf8_length s)) ++ str s
-let padr n s = str s ++ ws (max 0 (n - utf8_length s))
let padr_with c n s =
let ulength = utf8_length s in
str (utf8_sub s 0 n) ++ str (String.make (max 0 (n - ulength)) c)
@@ -374,7 +373,7 @@ let data = ref SM.empty
let _ =
Feedback.(add_feeder (function
- | { id = State s; contents = Custom (_, "ltacprof_results", xml) } ->
+ | { id = s; contents = Custom (_, "ltacprof_results", xml) } ->
let results = to_ltacprof_results xml in
let other_results = (* Multi success can cause this *)
try SM.find s !data
diff --git a/plugins/ltac/rewrite.ml b/plugins/ltac/rewrite.ml
index b84be4600c..5630a2d7b6 100644
--- a/plugins/ltac/rewrite.ml
+++ b/plugins/ltac/rewrite.ml
@@ -17,7 +17,6 @@ open EConstr
open Vars
open Reduction
open Tacticals.New
-open Tacmach
open Tactics
open Pretype_errors
open Typeclasses
@@ -39,7 +38,7 @@ open Proofview.Notations
open Context.Named.Declaration
module NamedDecl = Context.Named.Declaration
-module RelDecl = Context.Rel.Declaration
+(* module RelDecl = Context.Rel.Declaration *)
(** Typeclass-based generalized rewriting. *)
@@ -2197,7 +2196,8 @@ let setoid_transitivity c =
(transitivity_red true c)
let setoid_symmetry_in id =
- Proofview.V82.tactic (fun gl ->
+ let open Tacmach.New in
+ Proofview.Goal.enter { enter = begin fun gl ->
let sigma = project gl in
let ctype = pf_unsafe_type_of gl (mkVar id) in
let binders,concl = decompose_prod_assum sigma ctype in
@@ -2211,11 +2211,10 @@ let setoid_symmetry_in id =
let he,c1,c2 = mkApp (equiv, Array.of_list others),c1,c2 in
let new_hyp' = mkApp (he, [| c2 ; c1 |]) in
let new_hyp = it_mkProd_or_LetIn new_hyp' binders in
- Proofview.V82.of_tactic
(tclTHENLAST
(Tactics.assert_after_replacing id new_hyp)
(tclTHENLIST [ intros; setoid_symmetry; apply (mkVar id); Tactics.assumption ]))
- gl)
+ end }
let _ = Hook.set Tactics.setoid_reflexivity setoid_reflexivity
let _ = Hook.set Tactics.setoid_symmetry setoid_symmetry
diff --git a/plugins/ltac/rewrite.mli b/plugins/ltac/rewrite.mli
index 7a20838a27..6683d753bc 100644
--- a/plugins/ltac/rewrite.mli
+++ b/plugins/ltac/rewrite.mli
@@ -14,7 +14,6 @@ open Constrexpr
open Tacexpr
open Misctypes
open Evd
-open Proof_type
open Tacinterp
(** TODO: document and clean me! *)
diff --git a/plugins/ltac/taccoerce.mli b/plugins/ltac/taccoerce.mli
index 9c4ac52657..4a44f86d92 100644
--- a/plugins/ltac/taccoerce.mli
+++ b/plugins/ltac/taccoerce.mli
@@ -8,7 +8,6 @@
open Util
open Names
-open Term
open EConstr
open Misctypes
open Pattern
diff --git a/plugins/ltac/tacentries.ml b/plugins/ltac/tacentries.ml
index cd8c9e471e..32750383b8 100644
--- a/plugins/ltac/tacentries.ml
+++ b/plugins/ltac/tacentries.ml
@@ -15,7 +15,6 @@ open Genarg
open Extend
open Pcoq
open Egramml
-open Egramcoq
open Vernacexpr
open Libnames
open Nameops
@@ -88,9 +87,6 @@ let rec parse_user_entry s sep =
else
Uentry s
-let arg_list = function Rawwit t -> Rawwit (ListArg t)
-let arg_opt = function Rawwit t -> Rawwit (OptArg t)
-
let interp_entry_name interp symb =
let rec eval = function
| Ulist1 e -> Ulist1 (eval e)
@@ -320,7 +316,7 @@ let add_tactic_notation local n prods e =
let ids = List.map_filter cons_production_parameter prods in
let prods = List.map interp_prod_item prods in
let tac = Tacintern.glob_tactic_env ids (Global.env()) e in
- add_glob_tactic_notation local n prods false ids tac
+ add_glob_tactic_notation local ~level:n prods false ids tac
(**********************************************************************)
(* ML Tactic entries *)
diff --git a/plugins/ltac/tacenv.mli b/plugins/ltac/tacenv.mli
index 94e14223aa..d1e2a7bbe6 100644
--- a/plugins/ltac/tacenv.mli
+++ b/plugins/ltac/tacenv.mli
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Genarg
open Names
open Tacexpr
open Geninterp
diff --git a/plugins/ltac/tacintern.ml b/plugins/ltac/tacintern.ml
index 3f83f104e9..75227def0f 100644
--- a/plugins/ltac/tacintern.ml
+++ b/plugins/ltac/tacintern.ml
@@ -118,12 +118,6 @@ let intern_constr_reference strict ist = function
GRef (loc,locate_global_with_alias lqid,None),
if strict then None else Some (CRef (r,None))
-let intern_move_location ist = function
- | MoveAfter id -> MoveAfter (intern_hyp ist id)
- | MoveBefore id -> MoveBefore (intern_hyp ist id)
- | MoveFirst -> MoveFirst
- | MoveLast -> MoveLast
-
(* Internalize an isolated reference in position of tactic *)
let intern_isolated_global_tactic_reference r =
diff --git a/plugins/ltac/tacinterp.ml b/plugins/ltac/tacinterp.ml
index 50f43931e9..b8c021f188 100644
--- a/plugins/ltac/tacinterp.ml
+++ b/plugins/ltac/tacinterp.ml
@@ -25,7 +25,6 @@ open Refiner
open Tacmach.New
open Tactic_debug
open Constrexpr
-open Term
open Termops
open Tacexpr
open Genarg
@@ -436,12 +435,6 @@ let interp_hyp_list_as_list ist env sigma (loc,id as x) =
let interp_hyp_list ist env sigma l =
List.flatten (List.map (interp_hyp_list_as_list ist env sigma) l)
-let interp_move_location ist env sigma = function
- | MoveAfter id -> MoveAfter (interp_hyp ist env sigma id)
- | MoveBefore id -> MoveBefore (interp_hyp ist env sigma id)
- | MoveFirst -> MoveFirst
- | MoveLast -> MoveLast
-
let interp_reference ist env sigma = function
| ArgArg (_,r) -> r
| ArgVar (loc, id) ->
diff --git a/plugins/ltac/tacinterp.mli b/plugins/ltac/tacinterp.mli
index 1e5f6bd42b..494f36a95a 100644
--- a/plugins/ltac/tacinterp.mli
+++ b/plugins/ltac/tacinterp.mli
@@ -8,7 +8,6 @@
open Names
open Tactic_debug
-open Term
open EConstr
open Tacexpr
open Genarg
diff --git a/plugins/ltac/tactic_debug.ml b/plugins/ltac/tactic_debug.ml
index b2601ad32f..dffeade298 100644
--- a/plugins/ltac/tactic_debug.ml
+++ b/plugins/ltac/tactic_debug.ml
@@ -108,6 +108,8 @@ let string_get s i =
try Proofview.NonLogical.return (String.get s i)
with e -> Proofview.NonLogical.raise e
+let run_invalid_arg () = Proofview.NonLogical.raise (Invalid_argument "run_com")
+
(* Gives the number of steps or next breakpoint of a run command *)
let run_com inst =
let open Proofview.NonLogical in
@@ -118,14 +120,14 @@ let run_com inst =
let s = String.sub inst i (String.length inst - i) in
if inst.[0] >= '0' && inst.[0] <= '9' then
int_of_string s >>= fun num ->
- (if num<0 then invalid_arg "run_com" else return ()) >>
+ (if num<0 then run_invalid_arg () else return ()) >>
(skip:=num) >> (skipped:=0)
else
breakpoint:=Some (possibly_unquote s)
else
- invalid_arg "run_com"
+ run_invalid_arg ()
else
- invalid_arg "run_com"
+ run_invalid_arg ()
(* Prints the run counter *)
let run ini =
diff --git a/plugins/ltac/tactic_debug.mli b/plugins/ltac/tactic_debug.mli
index 7745d9b7b6..0b4d35a22a 100644
--- a/plugins/ltac/tactic_debug.mli
+++ b/plugins/ltac/tactic_debug.mli
@@ -10,7 +10,6 @@ open Environ
open Pattern
open Names
open Tacexpr
-open Term
open EConstr
open Evd
diff --git a/plugins/ltac/tauto.ml b/plugins/ltac/tauto.ml
index dc7ee6a234..4de2081cf8 100644
--- a/plugins/ltac/tauto.ml
+++ b/plugins/ltac/tauto.ml
@@ -10,7 +10,6 @@ open Term
open EConstr
open Hipattern
open Names
-open Pp
open Geninterp
open Misctypes
open Tacexpr
@@ -242,7 +241,7 @@ let tauto_uniform_unit_flags = {
}
(* This is the compatibility mode (not used) *)
-let tauto_legacy_flags = {
+let _tauto_legacy_flags = {
binary_mode = true;
binary_mode_bugged_detection = true;
strict_in_contravariant_hyp = true;
diff --git a/plugins/micromega/coq_micromega.ml b/plugins/micromega/coq_micromega.ml
index 4b87e6e2ed..a36607ec38 100644
--- a/plugins/micromega/coq_micromega.ml
+++ b/plugins/micromega/coq_micromega.ml
@@ -331,7 +331,6 @@ module M =
struct
open Coqlib
- open Term
open Constr
open EConstr
@@ -901,16 +900,13 @@ struct
coq_Qeq, Mc.OpEq
]
- let has_typ gl t1 typ =
- let ty = Retyping.get_type_of (Tacmach.pf_env gl) (Tacmach.project gl) t1 in
- EConstr.eq_constr (Tacmach.project gl) ty typ
-
+ type gl = { env : Environ.env; sigma : Evd.evar_map }
let is_convertible gl t1 t2 =
- Reductionops.is_conv (Tacmach.pf_env gl) (Tacmach.project gl) t1 t2
+ Reductionops.is_conv gl.env gl.sigma t1 t2
let parse_zop gl (op,args) =
- let sigma = Tacmach.project gl in
+ let sigma = gl.sigma in
match EConstr.kind sigma op with
| Const (x,_) -> (assoc_const sigma op zop_table, args.(0) , args.(1))
| Ind((n,0),_) ->
@@ -920,7 +916,7 @@ struct
| _ -> failwith "parse_zop"
let parse_rop gl (op,args) =
- let sigma = Tacmach.project gl in
+ let sigma = gl.sigma in
match EConstr.kind sigma op with
| Const (x,_) -> (assoc_const sigma op rop_table, args.(0) , args.(1))
| Ind((n,0),_) ->
@@ -930,7 +926,7 @@ struct
| _ -> failwith "parse_zop"
let parse_qop gl (op,args) =
- (assoc_const (Tacmach.project gl) op qop_table, args.(0) , args.(1))
+ (assoc_const gl.sigma op qop_table, args.(0) , args.(1))
let is_constant sigma t = (* This is an approx *)
match EConstr.kind sigma t with
@@ -1154,7 +1150,7 @@ struct
rop_spec
let parse_arith parse_op parse_expr env cstr gl =
- let sigma = Tacmach.project gl in
+ let sigma = gl.sigma in
if debug
then Feedback.msg_debug (Pp.str "parse_arith: " ++ Printer.pr_leconstr cstr ++ fnl ());
match EConstr.kind sigma cstr with
@@ -1199,7 +1195,7 @@ struct
*)
let parse_formula gl parse_atom env tg term =
- let sigma = Tacmach.project gl in
+ let sigma = gl.sigma in
let parse_atom env tg t =
try
@@ -1208,7 +1204,7 @@ struct
with e when CErrors.noncritical e -> (X(t),env,tg) in
let is_prop term =
- let sort = Retyping.get_sort_of (Tacmach.pf_env gl) (Tacmach.project gl) term in
+ let sort = Retyping.get_sort_of gl.env gl.sigma term in
Sorts.is_prop sort in
let rec xparse_formula env tg term =
@@ -1720,7 +1716,6 @@ let micromega_order_change spec cert cert_typ env ff (*: unit Proofview.tactic*
let vm = dump_varmap (spec.typ) (vm_of_list env) in
(* todo : directly generate the proof term - or generalize before conversion? *)
Proofview.Goal.nf_enter { enter = begin fun gl ->
- let gl = Tacmach.New.of_old (fun x -> x) gl in
Tacticals.New.tclTHENLIST
[
Tactics.change_concl
@@ -1730,7 +1725,7 @@ let micromega_order_change spec cert cert_typ env ff (*: unit Proofview.tactic*
("__varmap", vm, Term.mkApp(Lazy.force coq_VarMap, [|spec.typ|]));
("__wit", cert, cert_typ)
]
- (Tacmach.pf_concl gl))
+ (Tacmach.New.pf_concl gl))
]
end }
@@ -1967,11 +1962,13 @@ let micromega_tauto negate normalise unsat deduce spec prover env polys1 polys2
Some (ids,ff',res')
-
(**
* Parse the proof environment, and call micromega_tauto
*)
+let fresh_id avoid id gl =
+ Tactics.fresh_id_in_env avoid id (Proofview.Goal.env gl)
+
let micromega_gen
parse_arith
(negate:'cst atom -> 'cst mc_cnf)
@@ -1979,17 +1976,17 @@ let micromega_gen
unsat deduce
spec dumpexpr prover tac =
Proofview.Goal.nf_enter { enter = begin fun gl ->
- let gl = Tacmach.New.of_old (fun x -> x) gl in
- let sigma = Tacmach.project gl in
- let concl = Tacmach.pf_concl gl in
- let hyps = Tacmach.pf_hyps_types gl in
+ let sigma = Tacmach.New.project gl in
+ let concl = Tacmach.New.pf_concl gl in
+ let hyps = Tacmach.New.pf_hyps_types gl in
try
- let (hyps,concl,env) = parse_goal gl parse_arith Env.empty hyps concl in
+ let gl0 = { env = Tacmach.New.pf_env gl; sigma } in
+ let (hyps,concl,env) = parse_goal gl0 parse_arith Env.empty hyps concl in
let env = Env.elements env in
let spec = Lazy.force spec in
let dumpexpr = Lazy.force dumpexpr in
- match micromega_tauto negate normalise unsat deduce spec prover env hyps concl gl with
+ match micromega_tauto negate normalise unsat deduce spec prover env hyps concl gl0 with
| None -> Tacticals.New.tclFAIL 0 (Pp.str " Cannot find witness")
| Some (ids,ff',res') ->
let (arith_goal,props,vars,ff_arith) = make_goal_of_formula sigma dumpexpr ff' in
@@ -1998,7 +1995,7 @@ let micromega_gen
let intro_vars = Tacticals.New.tclTHENLIST (List.map intro vars) in
let intro_props = Tacticals.New.tclTHENLIST (List.map intro props) in
let ipat_of_name id = Some (Loc.ghost, Misctypes.IntroNaming (Misctypes.IntroIdentifier id)) in
- let goal_name = Tactics.fresh_id [] (Names.Id.of_string "__arith") gl in
+ let goal_name = fresh_id [] (Names.Id.of_string "__arith") gl in
let env' = List.map (fun (id,i) -> Term.mkVar id,i) vars in
let tac_arith = Tacticals.New.tclTHENLIST [ intro_props ; intro_vars ;
@@ -2057,7 +2054,6 @@ let micromega_order_changer cert env ff =
let ff = dump_formula formula_typ (dump_cstr coeff dump_coeff) ff in
let vm = dump_varmap (typ) (vm_of_list env) in
Proofview.Goal.nf_enter { enter = begin fun gl ->
- let gl = Tacmach.New.of_old (fun x -> x) gl in
Tacticals.New.tclTHENLIST
[
(Tactics.change_concl
@@ -2069,7 +2065,7 @@ let micromega_order_changer cert env ff =
[["Coq" ; "micromega" ; "VarMap"] ; ["VarMap"]] "t"), [|typ|]));
("__wit", cert, cert_typ)
]
- (Tacmach.pf_concl gl)));
+ (Tacmach.New.pf_concl gl)));
(* Tacticals.New.tclTHENLIST (List.map (fun id -> (Tactics.introduction id)) ids)*)
]
end }
@@ -2088,20 +2084,20 @@ let micromega_genr prover tac =
dump_proof = dump_psatz coq_Q dump_q
} in
Proofview.Goal.nf_enter { enter = begin fun gl ->
- let gl = Tacmach.New.of_old (fun x -> x) gl in
- let sigma = Tacmach.project gl in
- let concl = Tacmach.pf_concl gl in
- let hyps = Tacmach.pf_hyps_types gl in
+ let sigma = Tacmach.New.project gl in
+ let concl = Tacmach.New.pf_concl gl in
+ let hyps = Tacmach.New.pf_hyps_types gl in
try
- let (hyps,concl,env) = parse_goal gl parse_arith Env.empty hyps concl in
+ let gl0 = { env = Tacmach.New.pf_env gl; sigma } in
+ let (hyps,concl,env) = parse_goal gl0 parse_arith Env.empty hyps concl in
let env = Env.elements env in
let spec = Lazy.force spec in
let hyps' = List.map (fun (n,f) -> (n, map_atoms (Micromega.map_Formula Micromega.q_of_Rcst) f)) hyps in
let concl' = map_atoms (Micromega.map_Formula Micromega.q_of_Rcst) concl in
- match micromega_tauto negate normalise unsat deduce spec prover env hyps' concl' gl with
+ match micromega_tauto negate normalise unsat deduce spec prover env hyps' concl' gl0 with
| None -> Tacticals.New.tclFAIL 0 (Pp.str " Cannot find witness")
| Some (ids,ff',res') ->
let (ff,ids) = formula_hyps_concl
@@ -2114,7 +2110,7 @@ let micromega_genr prover tac =
let intro_vars = Tacticals.New.tclTHENLIST (List.map intro vars) in
let intro_props = Tacticals.New.tclTHENLIST (List.map intro props) in
let ipat_of_name id = Some (Loc.ghost, Misctypes.IntroNaming (Misctypes.IntroIdentifier id)) in
- let goal_name = Tactics.fresh_id [] (Names.Id.of_string "__arith") gl in
+ let goal_name = fresh_id [] (Names.Id.of_string "__arith") gl in
let env' = List.map (fun (id,i) -> Term.mkVar id,i) vars in
let tac_arith = Tacticals.New.tclTHENLIST [ intro_props ; intro_vars ;
diff --git a/plugins/micromega/mfourier.ml b/plugins/micromega/mfourier.ml
index f4f9b3c2f1..3779944154 100644
--- a/plugins/micromega/mfourier.ml
+++ b/plugins/micromega/mfourier.ml
@@ -99,7 +99,7 @@ module PSet = ISet
module System = Hashtbl.Make(Vect)
type proof =
-| Hyp of int
+| Assum of int
| Elim of var * proof * proof
| And of proof * proof
@@ -134,7 +134,7 @@ exception SystemContradiction of proof
let hyps prf =
let rec hyps prf acc =
match prf with
- | Hyp i -> ISet.add i acc
+ | Assum i -> ISet.add i acc
| Elim(_,prf1,prf2)
| And(prf1,prf2) -> hyps prf1 (hyps prf2 acc) in
hyps prf ISet.empty
@@ -143,7 +143,7 @@ let hyps prf =
(** Pretty printing *)
let rec pp_proof o prf =
match prf with
- | Hyp i -> Printf.fprintf o "H%i" i
+ | Assum i -> Printf.fprintf o "H%i" i
| Elim(v, prf1,prf2) -> Printf.fprintf o "E(%i,%a,%a)" v pp_proof prf1 pp_proof prf2
| And(prf1,prf2) -> Printf.fprintf o "A(%a,%a)" pp_proof prf1 pp_proof prf2
@@ -270,7 +270,7 @@ let norm_cstr {coeffs = v ; op = o ; cst = c} idx =
(match o with
| Eq -> Some c , Some c
| Ge -> Some c , None) ;
- prf = Hyp idx }
+ prf = Assum idx }
(** [load_system l] takes a list of constraints of type [cstr_compat]
@@ -285,7 +285,7 @@ let load_system l =
let vars = List.fold_left (fun vrs (cstr,i) ->
match norm_cstr cstr i with
- | Contradiction -> raise (SystemContradiction (Hyp i))
+ | Contradiction -> raise (SystemContradiction (Assum i))
| Redundant -> vrs
| Cstr(vect,info) ->
xadd_cstr vect info sys ;
@@ -867,7 +867,7 @@ let mk_proof hyps prf =
let rec mk_proof prf =
match prf with
- | Hyp i -> [ ([i, Int 1] , List.nth hyps i) ]
+ | Assum i -> [ ([i, Int 1] , List.nth hyps i) ]
| Elim(v,prf1,prf2) ->
let prfsl = mk_proof prf1
diff --git a/plugins/micromega/sos.ml b/plugins/micromega/sos.ml
index cc89e2b9d8..e1ceabe9e2 100644
--- a/plugins/micromega/sos.ml
+++ b/plugins/micromega/sos.ml
@@ -21,8 +21,6 @@ let debugging = ref false;;
exception Sanity;;
-exception Unsolvable;;
-
(* ------------------------------------------------------------------------- *)
(* Turn a rational into a decimal string with d sig digits. *)
(* ------------------------------------------------------------------------- *)
@@ -99,28 +97,11 @@ let vector_const c n =
if c =/ Int 0 then vector_0 n
else (n,itlist (fun k -> k |-> c) (1--n) undefined :vector);;
-let vector_1 = vector_const (Int 1);;
-
let vector_cmul c (v:vector) =
let n = dim v in
if c =/ Int 0 then vector_0 n
else n,mapf (fun x -> c */ x) (snd v)
-let vector_neg (v:vector) = (fst v,mapf minus_num (snd v) :vector);;
-
-let vector_add (v1:vector) (v2:vector) =
- let m = dim v1 and n = dim v2 in
- if m <> n then failwith "vector_add: incompatible dimensions" else
- (n,combine (+/) (fun x -> x =/ Int 0) (snd v1) (snd v2) :vector);;
-
-let vector_sub v1 v2 = vector_add v1 (vector_neg v2);;
-
-let vector_dot (v1:vector) (v2:vector) =
- let m = dim v1 and n = dim v2 in
- if m <> n then failwith "vector_add: incompatible dimensions" else
- foldl (fun a i x -> x +/ a) (Int 0)
- (combine ( */ ) (fun x -> x =/ Int 0) (snd v1) (snd v2));;
-
let vector_of_list l =
let n = List.length l in
(n,itlist2 (|->) (1--n) l undefined :vector);;
@@ -133,13 +114,6 @@ let matrix_0 (m,n) = ((m,n),undefined:matrix);;
let dimensions (m:matrix) = fst m;;
-let matrix_const c (m,n as mn) =
- if m <> n then failwith "matrix_const: needs to be square"
- else if c =/ Int 0 then matrix_0 mn
- else (mn,itlist (fun k -> (k,k) |-> c) (1--n) undefined :matrix);;
-
-let matrix_1 = matrix_const (Int 1);;
-
let matrix_cmul c (m:matrix) =
let (i,j) = dimensions m in
if c =/ Int 0 then matrix_0 (i,j)
@@ -152,8 +126,6 @@ let matrix_add (m1:matrix) (m2:matrix) =
if d1 <> d2 then failwith "matrix_add: incompatible dimensions"
else (d1,combine (+/) (fun x -> x =/ Int 0) (snd m1) (snd m2) :matrix);;
-let matrix_sub m1 m2 = matrix_add m1 (matrix_neg m2);;
-
let row k (m:matrix) =
let i,j = dimensions m in
(j,
@@ -166,20 +138,10 @@ let column k (m:matrix) =
foldl (fun a (i,j) c -> if j = k then (i |-> c) a else a) undefined (snd m)
: vector);;
-let transp (m:matrix) =
- let i,j = dimensions m in
- ((j,i),foldl (fun a (i,j) c -> ((j,i) |-> c) a) undefined (snd m) :matrix);;
-
let diagonal (v:vector) =
let n = dim v in
((n,n),foldl (fun a i c -> ((i,i) |-> c) a) undefined (snd v) : matrix);;
-let matrix_of_list l =
- let m = List.length l in
- if m = 0 then matrix_0 (0,0) else
- let n = List.length (List.hd l) in
- (m,n),itern 1 l (fun v i -> itern 1 v (fun c j -> (i,j) |-> c)) undefined;;
-
(* ------------------------------------------------------------------------- *)
(* Monomials. *)
(* ------------------------------------------------------------------------- *)
@@ -195,24 +157,8 @@ let monomial_var x = (x |=> 1 :monomial);;
let (monomial_mul:monomial->monomial->monomial) =
combine (+) (fun x -> false);;
-let monomial_pow (m:monomial) k =
- if k = 0 then monomial_1
- else mapf (fun x -> k * x) m;;
-
-let monomial_divides (m1:monomial) (m2:monomial) =
- foldl (fun a x k -> tryapplyd m2 x 0 >= k && a) true m1;;
-
-let monomial_div (m1:monomial) (m2:monomial) =
- let m = combine (+) (fun x -> x = 0) m1 (mapf (fun x -> -x) m2) in
- if foldl (fun a x k -> k >= 0 && a) true m then m
- else failwith "monomial_div: non-divisible";;
-
let monomial_degree x (m:monomial) = tryapplyd m x 0;;
-let monomial_lcm (m1:monomial) (m2:monomial) =
- (itlist (fun x -> x |-> max (monomial_degree x m1) (monomial_degree x m2))
- (union (dom m1) (dom m2)) undefined :monomial);;
-
let monomial_multidegree (m:monomial) = foldl (fun a x k -> k + a) 0 m;;
let monomial_variables m = dom m;;
@@ -252,12 +198,6 @@ let poly_cmmul (c,m) (p:poly) =
let poly_mul (p1:poly) (p2:poly) =
foldl (fun a m c -> poly_add (poly_cmmul (c,m) p2) a) poly_0 p1;;
-let poly_div (p1:poly) (p2:poly) =
- if not(poly_isconst p2) then failwith "poly_div: non-constant" else
- let c = eval undefined p2 in
- if c =/ Int 0 then failwith "poly_div: division by zero"
- else poly_cmul (Int 1 // c) p1;;
-
let poly_square p = poly_mul p p;;
let rec poly_pow p k =
@@ -266,10 +206,6 @@ let rec poly_pow p k =
else let q = poly_square(poly_pow p (k / 2)) in
if k mod 2 = 1 then poly_mul p q else q;;
-let poly_exp p1 p2 =
- if not(poly_isconst p2) then failwith "poly_exp: not a constant" else
- poly_pow p1 (Num.int_of_num (eval undefined p2));;
-
let degree x (p:poly) = foldl (fun a m c -> max (monomial_degree x m) a) 0 p;;
let multidegree (p:poly) =
@@ -282,14 +218,14 @@ let poly_variables (p:poly) =
(* Order monomials for human presentation. *)
(* ------------------------------------------------------------------------- *)
-let humanorder_varpow (x1,k1) (x2,k2) = x1 < x2 or x1 = x2 && k1 > k2;;
+let humanorder_varpow (x1,k1) (x2,k2) = x1 < x2 || x1 = x2 && k1 > k2;;
let humanorder_monomial =
let rec ord l1 l2 = match (l1,l2) with
_,[] -> true
| [],_ -> false
- | h1::t1,h2::t2 -> humanorder_varpow h1 h2 or h1 = h2 && ord t1 t2 in
- fun m1 m2 -> m1 = m2 or
+ | h1::t1,h2::t2 -> humanorder_varpow h1 h2 || h1 = h2 && ord t1 t2 in
+ fun m1 m2 -> m1 = m2 ||
ord (sort humanorder_varpow (graph m1))
(sort humanorder_varpow (graph m2));;
@@ -297,42 +233,8 @@ let humanorder_monomial =
(* Conversions to strings. *)
(* ------------------------------------------------------------------------- *)
-let string_of_vector min_size max_size (v:vector) =
- let n_raw = dim v in
- if n_raw = 0 then "[]" else
- let n = max min_size (min n_raw max_size) in
- let xs = List.map ((o) string_of_num (element v)) (1--n) in
- "[" ^ end_itlist (fun s t -> s ^ ", " ^ t) xs ^
- (if n_raw > max_size then ", ...]" else "]");;
-
-let string_of_matrix max_size (m:matrix) =
- let i_raw,j_raw = dimensions m in
- let i = min max_size i_raw and j = min max_size j_raw in
- let rstr = List.map (fun k -> string_of_vector j j (row k m)) (1--i) in
- "["^end_itlist(fun s t -> s^";\n "^t) rstr ^
- (if j > max_size then "\n ...]" else "]");;
-
let string_of_vname (v:vname): string = (v: string);;
-let rec string_of_term t =
- match t with
- Opp t1 -> "(- " ^ string_of_term t1 ^ ")"
-| Add (t1, t2) ->
- "(" ^ (string_of_term t1) ^ " + " ^ (string_of_term t2) ^ ")"
-| Sub (t1, t2) ->
- "(" ^ (string_of_term t1) ^ " - " ^ (string_of_term t2) ^ ")"
-| Mul (t1, t2) ->
- "(" ^ (string_of_term t1) ^ " * " ^ (string_of_term t2) ^ ")"
-| Inv t1 -> "(/ " ^ string_of_term t1 ^ ")"
-| Div (t1, t2) ->
- "(" ^ (string_of_term t1) ^ " / " ^ (string_of_term t2) ^ ")"
-| Pow (t1, n1) ->
- "(" ^ (string_of_term t1) ^ " ^ " ^ (string_of_int n1) ^ ")"
-| Zero -> "0"
-| Var v -> "x" ^ (string_of_vname v)
-| Const x -> string_of_num x;;
-
-
let string_of_varpow x k =
if k = 1 then string_of_vname x else string_of_vname x^"^"^string_of_int k;;
@@ -363,6 +265,7 @@ let string_of_poly (p:poly) =
(* Printers. *)
(* ------------------------------------------------------------------------- *)
+(*
let print_vector v = Format.print_string(string_of_vector 0 20 v);;
let print_matrix m = Format.print_string(string_of_matrix 20 m);;
@@ -371,7 +274,6 @@ let print_monomial m = Format.print_string(string_of_monomial m);;
let print_poly m = Format.print_string(string_of_poly m);;
-(*
#install_printer print_vector;;
#install_printer print_matrix;;
#install_printer print_monomial;;
@@ -411,19 +313,6 @@ let sdpa_of_vector (v:vector) =
end_itlist (fun x y -> x ^ " " ^ y) strs ^ "\n";;
(* ------------------------------------------------------------------------- *)
-(* String for block diagonal matrix numbered k. *)
-(* ------------------------------------------------------------------------- *)
-
-let sdpa_of_blockdiagonal k m =
- let pfx = string_of_int k ^" " in
- let ents =
- foldl (fun a (b,i,j) c -> if i > j then a else ((b,i,j),c)::a) [] m in
- let entss = sort (increasing fst) ents in
- itlist (fun ((b,i,j),c) a ->
- pfx ^ string_of_int b ^ " " ^ string_of_int i ^ " " ^ string_of_int j ^
- " " ^ decimalize 20 c ^ "\n" ^ a) entss "";;
-
-(* ------------------------------------------------------------------------- *)
(* String for a matrix numbered k, in SDPA sparse format. *)
(* ------------------------------------------------------------------------- *)
@@ -466,6 +355,7 @@ let token s =
>> (fun ((_,t),_) -> t);;
let decimal =
+ let (||) = parser_or in
let numeral = some isnum in
let decimalint = atleast 1 numeral >> ((o) Num.num_of_string implode) in
let decimalfrac = atleast 1 numeral
@@ -485,13 +375,12 @@ let mkparser p s =
let x,rst = p(explode s) in
if rst = [] then x else failwith "mkparser: unparsed input";;
-let parse_decimal = mkparser decimal;;
-
(* ------------------------------------------------------------------------- *)
(* Parse back a vector. *)
(* ------------------------------------------------------------------------- *)
-let parse_sdpaoutput,parse_csdpoutput =
+let _parse_sdpaoutput, parse_csdpoutput =
+ let (||) = parser_or in
let vector =
token "{" ++ listof decimal (token ",") "decimal" ++ token "}"
>> (fun ((_,v),_) -> vector_of_list v) in
@@ -508,23 +397,10 @@ let parse_sdpaoutput,parse_csdpoutput =
mkparser sdpaoutput,mkparser csdpoutput;;
(* ------------------------------------------------------------------------- *)
-(* Also parse the SDPA output to test success (CSDP yields a return code). *)
-(* ------------------------------------------------------------------------- *)
-
-let sdpa_run_succeeded =
- let rec skipupto dscr prs inp =
- (dscr ++ prs >> snd
- || some (fun c -> true) ++ skipupto dscr prs >> snd) inp in
- let prs = skipupto (word "phase.value" ++ token "=")
- (possibly (a "p") ++ possibly (a "d") ++
- (word "OPT" || word "FEAS")) in
- fun s -> try ignore (prs (explode s)); true with Noparse -> false;;
-
-(* ------------------------------------------------------------------------- *)
(* The default parameters. Unfortunately this goes to a fixed file. *)
(* ------------------------------------------------------------------------- *)
-let sdpa_default_parameters =
+let _sdpa_default_parameters =
"100 unsigned int maxIteration;\
\n1.0E-7 double 0.0 < epsilonStar;\
\n1.0E2 double 0.0 < lambdaStar;\
@@ -555,7 +431,7 @@ let sdpa_alt_parameters =
\n1.0E-7 double 0.0 < epsilonDash;\
\n";;
-let sdpa_params = sdpa_alt_parameters;;
+let _sdpa_params = sdpa_alt_parameters;;
(* ------------------------------------------------------------------------- *)
(* CSDP parameters; so far I'm sticking with the defaults. *)
@@ -588,10 +464,10 @@ let run_csdp dbg obj mats =
let input_file = Filename.temp_file "sos" ".dat-s" in
let output_file =
String.sub input_file 0 (String.length input_file - 6) ^ ".out"
- and params_file = Filename.concat (!temp_path) "param.csdp" in
+ and params_file = Filename.concat temp_path "param.csdp" in
file_of_string input_file (sdpa_of_problem "" obj mats);
file_of_string params_file csdp_params;
- let rv = Sys.command("cd "^(!temp_path)^"; csdp "^input_file ^
+ let rv = Sys.command("cd "^temp_path^"; csdp "^input_file ^
" " ^ output_file ^
(if dbg then "" else "> /dev/null")) in
let op = string_of_file output_file in
@@ -600,16 +476,6 @@ let run_csdp dbg obj mats =
else (Sys.remove input_file; Sys.remove output_file));
rv,res);;
-let csdp obj mats =
- let rv,res = run_csdp (!debugging) obj mats in
- (if rv = 1 or rv = 2 then failwith "csdp: Problem is infeasible"
- else if rv = 3 then ()
- (* Format.print_string "csdp warning: Reduced accuracy";
- Format.print_newline() *)
- else if rv <> 0 then failwith("csdp: error "^string_of_int rv)
- else ());
- res;;
-
(* ------------------------------------------------------------------------- *)
(* Try some apparently sensible scaling first. Note that this is purely to *)
(* get a cleaner translation to floating-point, and doesn't affect any of *)
@@ -653,21 +519,7 @@ let linear_program_basic a =
let mats = List.map (fun j -> diagonal (column j a)) (1--n)
and obj = vector_const (Int 1) m in
let rv,res = run_csdp false obj mats in
- if rv = 1 or rv = 2 then false
- else if rv = 0 then true
- else failwith "linear_program: An error occurred in the SDP solver";;
-
-(* ------------------------------------------------------------------------- *)
-(* Alternative interface testing A x >= b for matrix A, vector b. *)
-(* ------------------------------------------------------------------------- *)
-
-let linear_program a b =
- let m,n = dimensions a in
- if dim b <> m then failwith "linear_program: incompatible dimensions" else
- let mats = diagonal b :: List.map (fun j -> diagonal (column j a)) (1--n)
- and obj = vector_const (Int 1) m in
- let rv,res = run_csdp false obj mats in
- if rv = 1 or rv = 2 then false
+ if rv = 1 || rv = 2 then false
else if rv = 0 then true
else failwith "linear_program: An error occurred in the SDP solver";;
@@ -716,40 +568,6 @@ let equation_eval assig eq =
foldl (fun a v c -> a +/ value(v) */ c) (Int 0) eq;;
(* ------------------------------------------------------------------------- *)
-(* Eliminate among linear equations: return unconstrained variables and *)
-(* assignments for the others in terms of them. We give one pseudo-variable *)
-(* "one" that's used for a constant term. *)
-(* ------------------------------------------------------------------------- *)
-
-let failstore = ref [];;
-
-let eliminate_equations =
- let rec extract_first p l =
- match l with
- [] -> failwith "extract_first"
- | h::t -> if p(h) then h,t else
- let k,s = extract_first p t in
- k,h::s in
- let rec eliminate vars dun eqs =
- match vars with
- [] -> if forall is_undefined eqs then dun
- else (failstore := [vars,dun,eqs]; raise Unsolvable)
- | v::vs ->
- try let eq,oeqs = extract_first (fun e -> defined e v) eqs in
- let a = apply eq v in
- let eq' = equation_cmul (Int(-1) // a) (undefine v eq) in
- let elim e =
- let b = tryapplyd e v (Int 0) in
- if b =/ Int 0 then e else
- equation_add e (equation_cmul (minus_num b // a) eq) in
- eliminate vs ((v |-> eq') (mapf elim dun)) (List.map elim oeqs)
- with Failure _ -> eliminate vs dun eqs in
- fun one vars eqs ->
- let assig = eliminate vars undefined eqs in
- let vs = foldl (fun a x f -> subtract (dom f) [one] @ a) [] assig in
- setify vs,assig;;
-
-(* ------------------------------------------------------------------------- *)
(* Eliminate all variables, in an essentially arbitrary order. *)
(* ------------------------------------------------------------------------- *)
@@ -780,18 +598,6 @@ let eliminate_all_equations one =
setify vs,assig;;
(* ------------------------------------------------------------------------- *)
-(* Solve equations by assigning arbitrary numbers. *)
-(* ------------------------------------------------------------------------- *)
-
-let solve_equations one eqs =
- let vars,assigs = eliminate_all_equations one eqs in
- let vfn = itlist (fun v -> (v |-> Int 0)) vars (one |=> Int(-1)) in
- let ass =
- combine (+/) (fun c -> false) (mapf (equation_eval vfn) assigs) vfn in
- if forall (fun e -> equation_eval ass e =/ Int 0) eqs
- then undefine one ass else raise Sanity;;
-
-(* ------------------------------------------------------------------------- *)
(* Hence produce the "relevant" monomials: those whose squares lie in the *)
(* Newton polytope of the monomials in the input. (This is enough according *)
(* to Reznik: "Extremal PSD forms with few terms", Duke Math. Journal, *)
@@ -898,19 +704,6 @@ let epoly_pmul p q acc =
a q) acc p;;
(* ------------------------------------------------------------------------- *)
-(* Usual operations on equation-parametrized poly. *)
-(* ------------------------------------------------------------------------- *)
-
-let epoly_cmul c l =
- if c =/ Int 0 then undefined else mapf (equation_cmul c) l;;
-
-let epoly_neg = epoly_cmul (Int(-1));;
-
-let epoly_add = combine equation_add is_undefined;;
-
-let epoly_sub p q = epoly_add p (epoly_neg q);;
-
-(* ------------------------------------------------------------------------- *)
(* Convert regular polynomial. Note that we treat (0,0,0) as -1. *)
(* ------------------------------------------------------------------------- *)
@@ -953,11 +746,11 @@ let run_csdp dbg nblocks blocksizes obj mats =
let input_file = Filename.temp_file "sos" ".dat-s" in
let output_file =
String.sub input_file 0 (String.length input_file - 6) ^ ".out"
- and params_file = Filename.concat (!temp_path) "param.csdp" in
+ and params_file = Filename.concat temp_path "param.csdp" in
file_of_string input_file
(sdpa_of_blockproblem "" nblocks blocksizes obj mats);
file_of_string params_file csdp_params;
- let rv = Sys.command("cd "^(!temp_path)^"; csdp "^input_file ^
+ let rv = Sys.command("cd "^temp_path^"; csdp "^input_file ^
" " ^ output_file ^
(if dbg then "" else "> /dev/null")) in
let op = string_of_file output_file in
@@ -968,7 +761,7 @@ let run_csdp dbg nblocks blocksizes obj mats =
let csdp nblocks blocksizes obj mats =
let rv,res = run_csdp (!debugging) nblocks blocksizes obj mats in
- (if rv = 1 or rv = 2 then failwith "csdp: Problem is infeasible"
+ (if rv = 1 || rv = 2 then failwith "csdp: Problem is infeasible"
else if rv = 3 then ()
(*Format.print_string "csdp warning: Reduced accuracy";
Format.print_newline() *)
@@ -988,8 +781,6 @@ let bmatrix_cmul c bm =
let bmatrix_neg = bmatrix_cmul (Int(-1));;
-let bmatrix_sub m1 m2 = bmatrix_add m1 (bmatrix_neg m2);;
-
(* ------------------------------------------------------------------------- *)
(* Smash a block matrix into components. *)
(* ------------------------------------------------------------------------- *)
@@ -1102,15 +893,6 @@ let real_positivnullstellensatz_general linf d eqs leqs pol =
cfs,List.map (fun (a,b) -> snd a,b) msq;;
(* ------------------------------------------------------------------------- *)
-(* Iterative deepening. *)
-(* ------------------------------------------------------------------------- *)
-
-let rec deepen f n =
- try print_string "Searching with depth limit ";
- print_int n; print_newline(); f n
- with Failure _ -> deepen f (n + 1);;
-
-(* ------------------------------------------------------------------------- *)
(* The ordering so we can create canonical HOL polynomials. *)
(* ------------------------------------------------------------------------- *)
@@ -1136,10 +918,6 @@ let monomial_order =
if deg1 < deg2 then false else if deg1 > deg2 then true
else lexorder mon1 mon2;;
-let dest_poly p =
- List.map (fun (m,c) -> c,dest_monomial m)
- (sort (fun (m1,_) (m2,_) -> monomial_order m1 m2) (graph p));;
-
(* ------------------------------------------------------------------------- *)
(* Map back polynomials and their composites to HOL. *)
(* ------------------------------------------------------------------------- *)
@@ -1373,9 +1151,6 @@ let rec allpermutations l =
itlist (fun h acc -> List.map (fun t -> h::t)
(allpermutations (subtract l [h])) @ acc) l [];;
-let allvarorders l =
- List.map (fun vlis x -> index x vlis) (allpermutations l);;
-
let changevariables_monomial zoln (m:monomial) =
foldl (fun a x k -> (List.assoc x zoln |-> k) a) monomial_1 m;;
@@ -1392,15 +1167,6 @@ let sdpa_of_vector (v:vector) =
let strs = List.map (o (decimalize 20) (element v)) (1--n) in
end_itlist (fun x y -> x ^ " " ^ y) strs ^ "\n";;
-let sdpa_of_blockdiagonal k m =
- let pfx = string_of_int k ^" " in
- let ents =
- foldl (fun a (b,i,j) c -> if i > j then a else ((b,i,j),c)::a) [] m in
- let entss = sort (increasing fst) ents in
- itlist (fun ((b,i,j),c) a ->
- pfx ^ string_of_int b ^ " " ^ string_of_int i ^ " " ^ string_of_int j ^
- " " ^ decimalize 20 c ^ "\n" ^ a) entss "";;
-
let sdpa_of_matrix k (m:matrix) =
let pfx = string_of_int k ^ " 1 " in
let ms = foldr (fun (i,j) c a -> if i > j then a else ((i,j),c)::a)
@@ -1425,10 +1191,10 @@ let run_csdp dbg obj mats =
let input_file = Filename.temp_file "sos" ".dat-s" in
let output_file =
String.sub input_file 0 (String.length input_file - 6) ^ ".out"
- and params_file = Filename.concat (!temp_path) "param.csdp" in
+ and params_file = Filename.concat temp_path "param.csdp" in
file_of_string input_file (sdpa_of_problem "" obj mats);
file_of_string params_file csdp_params;
- let rv = Sys.command("cd "^(!temp_path)^"; csdp "^input_file ^
+ let rv = Sys.command("cd "^temp_path^"; csdp "^input_file ^
" " ^ output_file ^
(if dbg then "" else "> /dev/null")) in
let op = string_of_file output_file in
@@ -1439,7 +1205,7 @@ let run_csdp dbg obj mats =
let csdp obj mats =
let rv,res = run_csdp (!debugging) obj mats in
- (if rv = 1 or rv = 2 then failwith "csdp: Problem is infeasible"
+ (if rv = 1 || rv = 2 then failwith "csdp: Problem is infeasible"
else if rv = 3 then ()
(* (Format.print_string "csdp warning: Reduced accuracy";
Format.print_newline()) *)
diff --git a/plugins/micromega/sos_lib.ml b/plugins/micromega/sos_lib.ml
index f54914f252..6b8b820ac6 100644
--- a/plugins/micromega/sos_lib.ml
+++ b/plugins/micromega/sos_lib.ml
@@ -525,7 +525,7 @@ let isspace,issep,isbra,issymb,isalpha,isnum,isalnum =
and isalnum c = Array.get ctable (charcode c) >= 16 in
isspace,issep,isbra,issymb,isalpha,isnum,isalnum;;
-let (||) parser1 parser2 input =
+let parser_or parser1 parser2 input =
try parser1 input
with Noparse -> parser2 input;;
@@ -571,7 +571,7 @@ let finished input =
(* ------------------------------------------------------------------------- *)
-let temp_path = ref Filename.temp_dir_name;;
+let temp_path = Filename.get_temp_dir_name ();;
(* ------------------------------------------------------------------------- *)
(* Convenient conversion between files and (lists of) strings. *)
diff --git a/plugins/nsatz/Nsatz.v b/plugins/nsatz/Nsatz.v
index b11d15e5ca..403f664e2b 100644
--- a/plugins/nsatz/Nsatz.v
+++ b/plugins/nsatz/Nsatz.v
@@ -462,6 +462,11 @@ try (try apply Rsth;
exact Rplus_opp_r.
Defined.
+Class can_compute_Z (z : Z) := dummy_can_compute_Z : True.
+Hint Extern 0 (can_compute_Z ?v) =>
+ match isZcst v with true => exact I end : typeclass_instances.
+Instance reify_IZR z lvar {_ : can_compute_Z z} : reify (PEc z) lvar (IZR z).
+
Lemma R_one_zero: 1%R <> 0%R.
discrR.
Qed.
diff --git a/plugins/nsatz/ideal.ml b/plugins/nsatz/ideal.ml
index b1ff59e780..a120d4efb2 100644
--- a/plugins/nsatz/ideal.ml
+++ b/plugins/nsatz/ideal.ml
@@ -153,7 +153,6 @@ module Make (P:Polynom.S) = struct
type coef = P.t
let coef0 = P.of_num (Num.Int 0)
let coef1 = P.of_num (Num.Int 1)
- let coefm1 = P.of_num (Num.Int (-1))
let string_of_coef c = "["^(P.to_string c)^"]"
(***********************************************************************
@@ -197,8 +196,6 @@ module Hashpol = Hashtbl.Make(
(* A pretty printer for polynomials, with Maple-like syntax. *)
-open Format
-
let getvar lv i =
try (List.nth lv i)
with Failure _ -> (List.fold_left (fun r x -> r^" "^x) "lv= " lv)
@@ -252,59 +249,6 @@ let string_of_pol zeroP hdP tlP coefterm monterm string_of_coef
in
(stringP p true)
-
-
-let print_pol zeroP hdP tlP coefterm monterm string_of_coef
- dimmon string_of_exp lvar p =
-
- let rec print_mon m coefone =
- let s=ref [] in
- for i=1 to (dimmon m) do
- (match (string_of_exp m i) with
- "0" -> ()
- | "1" -> s:= (!s) @ [(getvar lvar (i-1))]
- | e -> s:= (!s) @ [((getvar lvar (i-1)) ^ "^" ^ e)]);
- done;
- (match !s with
- [] -> if coefone
- then print_string "1"
- else ()
- | l -> if coefone
- then print_string (String.concat "*" l)
- else (print_string "*";
- print_string (String.concat "*" l)))
- and print_term t start = let a = coefterm t and m = monterm t in
- match (string_of_coef a) with
- "0" -> ()
- | "1" ->(match start with
- true -> print_mon m true
- |false -> (print_string "+ ";
- print_mon m true))
- | "-1" ->(print_string "-";print_space();print_mon m true)
- | c -> if (String.get c 0)='-'
- then (print_string "- ";
- print_string (String.sub c 1
- ((String.length c)-1));
- print_mon m false)
- else (match start with
- true -> (print_string c;print_mon m false)
- |false -> (print_string "+ ";
- print_string c;print_mon m false))
- and printP p start =
- if (zeroP p)
- then (if start
- then print_string("0")
- else ())
- else (print_term (hdP p) start;
- if start then open_hovbox 0;
- print_space();
- print_cut();
- printP (tlP p) false)
- in open_hovbox 3;
- printP p true;
- print_flush()
-
-
let stringP metadata (p : poly) =
string_of_pol
(fun p -> match p with [] -> true | _ -> false)
@@ -595,9 +539,6 @@ let addS x l = l @ [x] (* oblige de mettre en queue sinon le certificat decon
critical pairs/s-polynomials
*)
-let ordcpair ((i1,j1),m1) ((i2,j2),m2) =
- compare_mon m1 m2
-
module CPair =
struct
type t = (int * int) * Monomial.t
diff --git a/plugins/nsatz/nsatz.ml b/plugins/nsatz/nsatz.ml
index db8f3e4b21..632b9dac14 100644
--- a/plugins/nsatz/nsatz.ml
+++ b/plugins/nsatz/nsatz.ml
@@ -22,7 +22,6 @@ open Utile
let num_0 = Int 0
and num_1 = Int 1
and num_2 = Int 2
-and num_10 = Int 10
let numdom r =
let r' = Ratio.normalize_ratio (ratio_of_num r) in
@@ -35,7 +34,6 @@ module BigInt = struct
type t = big_int
let of_int = big_int_of_int
let coef0 = of_int 0
- let coef1 = of_int 1
let of_num = Num.big_int_of_num
let to_num = Num.num_of_big_int
let equal = eq_big_int
@@ -49,7 +47,6 @@ module BigInt = struct
let div = div_big_int
let modulo = mod_big_int
let to_string = string_of_big_int
- let to_int x = int_of_big_int x
let hash x =
try (int_of_big_int x)
with Failure _ -> 1
@@ -61,15 +58,6 @@ module BigInt = struct
then a
else if lt a b then pgcd b a else pgcd b (modulo a b)
-
- (* signe du pgcd = signe(a)*signe(b) si non nuls. *)
- let pgcd2 a b =
- if equal a coef0 then b
- else if equal b coef0 then a
- else let c = pgcd (abs a) (abs b) in
- if ((lt coef0 a)&&(lt b coef0))
- ||((lt coef0 b)&&(lt a coef0))
- then opp c else c
end
(*
@@ -146,8 +134,6 @@ let mul = function
| (Const n,q) when eq_num n num_1 -> q
| (p,q) -> Mul(p,q)
-let unconstr = mkRel 1
-
let tpexpr =
lazy (gen_constant "CC" ["setoid_ring";"Ring_polynom"] "PExpr")
let ttconst = lazy (gen_constant "CC" ["setoid_ring";"Ring_polynom"] "PEc")
@@ -271,20 +257,6 @@ let set_nvars_term nvars t =
| Pow (t1,n) -> aux t1 nvars
in aux t nvars
-let string_of_term p =
- let rec aux p =
- match p with
- | Zero -> "0"
- | Const r -> string_of_num r
- | Var v -> "x"^v
- | Opp t1 -> "(-"^(aux t1)^")"
- | Add (t1,t2) -> "("^(aux t1)^"+"^(aux t2)^")"
- | Sub (t1,t2) -> "("^(aux t1)^"-"^(aux t2)^")"
- | Mul (t1,t2) -> "("^(aux t1)^"*"^(aux t2)^")"
- | Pow (t1,n) -> (aux t1)^"^"^(string_of_int n)
- in aux p
-
-
(***********************************************************************
Coefficients: recursive polynomials
*)
@@ -437,7 +409,7 @@ open Ideal
that has the same size than lp and where true indicates an
element that has been removed
*)
-let rec clean_pol lp =
+let clean_pol lp =
let t = Hashpol.create 12 in
let find p = try Hashpol.find t p
with
diff --git a/plugins/omega/coq_omega.ml b/plugins/omega/coq_omega.ml
index 7780de7127..92b092ffe9 100644
--- a/plugins/omega/coq_omega.ml
+++ b/plugins/omega/coq_omega.ml
@@ -19,8 +19,8 @@ open Names
open Nameops
open Term
open EConstr
-open Tacticals
-open Tacmach
+open Tacticals.New
+open Tacmach.New
open Tactics
open Logic
open Libnames
@@ -41,7 +41,9 @@ let elim_id id =
Proofview.Goal.enter { enter = begin fun gl ->
simplest_elim (Tacmach.New.pf_global id gl)
end }
-let resolve_id id gl = Proofview.V82.of_tactic (apply (pf_global gl id)) gl
+let resolve_id id = Proofview.Goal.enter { enter = begin fun gl ->
+ apply (Tacmach.New.pf_global id gl)
+end }
let timing timer_name f arg = f arg
@@ -146,14 +148,14 @@ let intern_id,unintern_id,reset_intern_tables =
Hashtbl.add table v idx; Hashtbl.add co_table idx v; v),
(fun () -> cpt := 0; Hashtbl.clear table)
-let mk_then = tclTHENLIST
+let mk_then tacs = tclTHENLIST tacs
let exists_tac c = constructor_tac false (Some 1) 1 (ImplicitBindings [c])
let generalize_tac t = generalize t
let elim t = simplest_elim t
-let exact t = Tacmach.refine t
let unfold s = Tactics.unfold_in_concl [Locus.AllOccurrences, Lazy.force s]
+let pf_nf gl c = pf_apply Tacred.simpl gl c
let rev_assoc k =
let rec loop = function
@@ -580,9 +582,12 @@ let abstract_path sigma typ path t =
let abstract = context sigma (fun i t -> term_occur:= t; mkRel i) path t in
mkLambda (Name (Id.of_string "x"), typ, abstract), !term_occur
-let focused_simpl path gl =
+let focused_simpl path =
+ let open Tacmach.New in
+ Proofview.Goal.nf_enter { enter = begin fun gl ->
let newc = context (project gl) (fun i t -> pf_nf gl t) (List.rev path) (pf_concl gl) in
- Proofview.V82.of_tactic (convert_concl_no_check newc DEFAULTcast) gl
+ convert_concl_no_check newc DEFAULTcast
+ end }
let focused_simpl path = focused_simpl path
@@ -640,11 +645,19 @@ let decompile af =
in
loop af.body
-let mkNewMeta () = mkMeta (Evarutil.new_meta())
+(** Backward compat to emulate the old Refine: normalize the goal conclusion *)
+let new_hole env sigma c =
+ let c = Reductionops.nf_betaiota (Sigma.to_evar_map sigma) c in
+ Evarutil.new_evar env sigma c
-let clever_rewrite_base_poly typ p result theorem gl =
+let clever_rewrite_base_poly typ p result theorem =
+ let open Tacmach.New in
+ let open Sigma in
+ Proofview.Goal.nf_enter { enter = begin fun gl ->
let full = pf_concl gl in
+ let env = pf_env gl in
let (abstracted,occ) = abstract_path (project gl) typ (List.rev p) full in
+ Refine.refine { run = begin fun sigma ->
let t =
applist
(mkLambda
@@ -657,13 +670,17 @@ let clever_rewrite_base_poly typ p result theorem gl =
[| typ; result; mkRel 2; mkRel 1; occ; theorem |]))),
[abstracted])
in
- exact (applist(t,[mkNewMeta()])) gl
+ let argt = mkApp (abstracted, [|result|]) in
+ let Sigma (hole, sigma, p) = new_hole env sigma argt in
+ Sigma (applist (t, [hole]), sigma, p)
+ end }
+ end }
-let clever_rewrite_base p result theorem gl =
- clever_rewrite_base_poly (Lazy.force coq_Z) p result theorem gl
+let clever_rewrite_base p result theorem =
+ clever_rewrite_base_poly (Lazy.force coq_Z) p result theorem
-let clever_rewrite_base_nat p result theorem gl =
- clever_rewrite_base_poly (Lazy.force coq_nat) p result theorem gl
+let clever_rewrite_base_nat p result theorem =
+ clever_rewrite_base_poly (Lazy.force coq_nat) p result theorem
let clever_rewrite_gen p result (t,args) =
let theorem = applist(t, args) in
@@ -673,12 +690,29 @@ let clever_rewrite_gen_nat p result (t,args) =
let theorem = applist(t, args) in
clever_rewrite_base_nat p result theorem
-let clever_rewrite p vpath t gl =
+(** Solve using the term the term [t _] *)
+let refine_app gl t =
+ let open Tacmach.New in
+ let open Sigma in
+ Refine.refine { run = begin fun sigma ->
+ let env = pf_env gl in
+ let ht = match EConstr.kind (Sigma.to_evar_map sigma) (pf_get_type_of gl t) with
+ | Prod (_, t, _) -> t
+ | _ -> assert false
+ in
+ let Sigma (hole, sigma, p) = new_hole env sigma ht in
+ Sigma (applist (t, [hole]), sigma, p)
+ end }
+
+let clever_rewrite p vpath t =
+ let open Tacmach.New in
+ Proofview.Goal.nf_enter { enter = begin fun gl ->
let full = pf_concl gl in
let (abstracted,occ) = abstract_path (project gl) (Lazy.force coq_Z) (List.rev p) full in
let vargs = List.map (fun p -> occurrence (project gl) p occ) vpath in
let t' = applist(t, (vargs @ [abstracted])) in
- exact (applist(t',[mkNewMeta()])) gl
+ refine_app gl t'
+ end }
let rec shuffle p (t1,t2) =
match t1,t2 with
@@ -942,15 +976,15 @@ let rec transform sigma p t =
transform sigma p
(mkApp (Lazy.force coq_Zplus,
[| t1; (mkApp (Lazy.force coq_Zopp, [| t2 |])) |])) in
- Proofview.V82.of_tactic (unfold sp_Zminus) :: tac,t
+ unfold sp_Zminus :: tac,t
| Kapp(Zsucc,[t1]) ->
let tac,t = transform sigma p (mkApp (Lazy.force coq_Zplus,
[| t1; mk_integer one |])) in
- Proofview.V82.of_tactic (unfold sp_Zsucc) :: tac,t
+ unfold sp_Zsucc :: tac,t
| Kapp(Zpred,[t1]) ->
let tac,t = transform sigma p (mkApp (Lazy.force coq_Zplus,
[| t1; mk_integer negone |])) in
- Proofview.V82.of_tactic (unfold sp_Zpred) :: tac,t
+ unfold sp_Zpred :: tac,t
| Kapp(Zmult,[t1;t2]) ->
let tac1,t1' = transform sigma (P_APP 1 :: p) t1
and tac2,t2' = transform sigma (P_APP 2 :: p) t2 in
@@ -1068,7 +1102,7 @@ let replay_history tactic_normalisation =
| HYP e :: l ->
begin
try
- Tacticals.New.tclTHEN
+ tclTHEN
(Id.List.assoc (hyp_of_tag e.id) tactic_normalisation)
(loop l)
with Not_found -> loop l end
@@ -1080,16 +1114,16 @@ let replay_history tactic_normalisation =
let k = if b then negone else one in
let p_initial = [P_APP 1;P_TYPE] in
let tac= shuffle_mult_right p_initial e1.body k e2.body in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
generalize_tac
[mkApp (Lazy.force coq_OMEGA17, [|
val_of eq1;
val_of eq2;
mk_integer k;
mkVar id1; mkVar id2 |])];
- Proofview.V82.tactic (mk_then tac);
+ mk_then tac;
(intros_using [aux]);
- Proofview.V82.tactic (resolve_id aux);
+ resolve_id aux;
reflexivity
]
| CONTRADICTION (e1,e2) :: l ->
@@ -1104,8 +1138,8 @@ let replay_history tactic_normalisation =
Lazy.force coq_Gt;
Lazy.force coq_Gt |])
in
- Tacticals.New.tclTHENS
- (Tacticals.New.tclTHENLIST [
+ tclTHENS
+ (tclTHENLIST [
unfold sp_Zle;
simpl_in_concl;
intro;
@@ -1118,7 +1152,7 @@ let replay_history tactic_normalisation =
mkVar (hyp_of_tag e1.id);
mkVar (hyp_of_tag e2.id) |])
in
- Proofview.tclTHEN (Proofview.V82.tactic (tclTHEN (Proofview.V82.of_tactic (generalize_tac [theorem])) (mk_then tac))) (solve_le)
+ Proofview.tclTHEN (tclTHEN (generalize_tac [theorem]) (mk_then tac)) solve_le
| DIVIDE_AND_APPROX (e1,e2,k,d) :: l ->
let id = hyp_of_tag e1.id in
let eq1 = val_of(decompile e1)
@@ -1128,10 +1162,10 @@ let replay_history tactic_normalisation =
let rhs = mk_plus (mk_times eq2 kk) dd in
let state_eg = mk_eq eq1 rhs in
let tac = scalar_norm_add [P_APP 3] e2.body in
- Tacticals.New.tclTHENS
+ tclTHENS
(cut state_eg)
- [ Tacticals.New.tclTHENS
- (Tacticals.New.tclTHENLIST [
+ [ tclTHENS
+ (tclTHENLIST [
(intros_using [aux]);
(generalize_tac
[mkApp (Lazy.force coq_OMEGA1,
@@ -1139,9 +1173,9 @@ let replay_history tactic_normalisation =
(clear [aux;id]);
(intros_using [id]);
(cut (mk_gt kk dd)) ])
- [ Tacticals.New.tclTHENS
+ [ tclTHENS
(cut (mk_gt kk izero))
- [ Tacticals.New.tclTHENLIST [
+ [ tclTHENLIST [
(intros_using [aux1; aux2]);
(generalize_tac
[mkApp (Lazy.force coq_Zmult_le_approx,
@@ -1149,13 +1183,13 @@ let replay_history tactic_normalisation =
(clear [aux1;aux2;id]);
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(unfold sp_Zgt);
simpl_in_concl;
reflexivity ] ];
- Tacticals.New.tclTHENLIST [ unfold sp_Zgt; simpl_in_concl; reflexivity ]
+ tclTHENLIST [ unfold sp_Zgt; simpl_in_concl; reflexivity ]
];
- Tacticals.New.tclTHEN (Proofview.V82.tactic (mk_then tac)) reflexivity ]
+ tclTHEN (mk_then tac) reflexivity ]
| NOT_EXACT_DIVIDE (e1,k) :: l ->
let c = floor_div e1.constant k in
@@ -1166,10 +1200,10 @@ let replay_history tactic_normalisation =
let kk = mk_integer k
and dd = mk_integer d in
let tac = scalar_norm_add [P_APP 2] e2.body in
- Tacticals.New.tclTHENS
+ tclTHENS
(cut (mk_gt dd izero))
- [ Tacticals.New.tclTHENS (cut (mk_gt kk dd))
- [Tacticals.New.tclTHENLIST [
+ [ tclTHENS (cut (mk_gt kk dd))
+ [tclTHENLIST [
(intros_using [aux2;aux1]);
(generalize_tac
[mkApp (Lazy.force coq_OMEGA4,
@@ -1177,14 +1211,14 @@ let replay_history tactic_normalisation =
(clear [aux1;aux2]);
unfold sp_not;
(intros_using [aux]);
- Proofview.V82.tactic (resolve_id aux);
- Proofview.V82.tactic (mk_then tac);
+ resolve_id aux;
+ mk_then tac;
assumption ] ;
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
reflexivity ] ];
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
reflexivity ] ]
@@ -1197,9 +1231,9 @@ let replay_history tactic_normalisation =
let state_eq = mk_eq eq1 (mk_times eq2 kk) in
if e1.kind == DISE then
let tac = scalar_norm [P_APP 3] e2.body in
- Tacticals.New.tclTHENS
+ tclTHENS
(cut state_eq)
- [Tacticals.New.tclTHENLIST [
+ [tclTHENLIST [
(intros_using [aux1]);
(generalize_tac
[mkApp (Lazy.force coq_OMEGA18,
@@ -1207,14 +1241,14 @@ let replay_history tactic_normalisation =
(clear [aux1;id]);
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHEN (Proofview.V82.tactic (mk_then tac)) reflexivity ]
+ tclTHEN (mk_then tac) reflexivity ]
else
let tac = scalar_norm [P_APP 3] e2.body in
- Tacticals.New.tclTHENS (cut state_eq)
+ tclTHENS (cut state_eq)
[
- Tacticals.New.tclTHENS
+ tclTHENS
(cut (mk_gt kk izero))
- [Tacticals.New.tclTHENLIST [
+ [tclTHENLIST [
(intros_using [aux2;aux1]);
(generalize_tac
[mkApp (Lazy.force coq_OMEGA3,
@@ -1222,11 +1256,11 @@ let replay_history tactic_normalisation =
(clear [aux1;aux2;id]);
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
reflexivity ] ];
- Tacticals.New.tclTHEN (Proofview.V82.tactic (mk_then tac)) reflexivity ]
+ tclTHEN (mk_then tac) reflexivity ]
| (MERGE_EQ(e3,e1,e2)) :: l ->
let id = new_identifier () in
tag_hypothesis id e3;
@@ -1239,16 +1273,16 @@ let replay_history tactic_normalisation =
(Lazy.force coq_fast_Zopp_eq_mult_neg_1) ::
scalar_norm [P_APP 3] e1.body
in
- Tacticals.New.tclTHENS
+ tclTHENS
(cut (mk_eq eq1 (mk_inv eq2)))
- [Tacticals.New.tclTHENLIST [
+ [tclTHENLIST [
(intros_using [aux]);
(generalize_tac [mkApp (Lazy.force coq_OMEGA8,
[| eq1;eq2;mkVar id1;mkVar id2; mkVar aux|])]);
(clear [id1;id2;aux]);
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHEN (Proofview.V82.tactic (mk_then tac)) reflexivity]
+ tclTHEN (mk_then tac) reflexivity]
| STATE {st_new_eq=e;st_def=def;st_orig=orig;st_coef=m;st_var=v} :: l ->
let id = new_identifier ()
@@ -1272,9 +1306,9 @@ let replay_history tactic_normalisation =
[[P_APP 1]] (Lazy.force coq_fast_Zopp_eq_mult_neg_1) ::
shuffle_mult_right p_initial
orig.body m ({c= negone;v= v}::def.body) in
- Tacticals.New.tclTHENS
+ tclTHENS
(cut theorem)
- [Tacticals.New.tclTHENLIST [
+ [tclTHENLIST [
(intros_using [aux]);
(elim_id aux);
(clear [aux]);
@@ -1282,11 +1316,11 @@ let replay_history tactic_normalisation =
(generalize_tac
[mkApp (Lazy.force coq_OMEGA9,
[| mkVar vid;eq2;eq1;mm; mkVar id2;mkVar aux |])]);
- Proofview.V82.tactic (mk_then tac);
+ mk_then tac;
(clear [aux]);
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHEN (exists_tac eq1) reflexivity ]
+ tclTHEN (exists_tac eq1) reflexivity ]
| SPLIT_INEQ(e,(e1,act1),(e2,act2)) :: l ->
let id1 = new_identifier ()
and id2 = new_identifier () in
@@ -1295,10 +1329,10 @@ let replay_history tactic_normalisation =
let tac1 = norm_add [P_APP 2;P_TYPE] e.body in
let tac2 = scalar_norm_add [P_APP 2;P_TYPE] e.body in
let eq = val_of(decompile e) in
- Tacticals.New.tclTHENS
+ tclTHENS
(simplest_elim (applist (Lazy.force coq_OMEGA19, [eq; mkVar id])))
- [Tacticals.New.tclTHENLIST [ Proofview.V82.tactic (mk_then tac1); (intros_using [id1]); (loop act1) ];
- Tacticals.New.tclTHENLIST [ Proofview.V82.tactic (mk_then tac2); (intros_using [id2]); (loop act2) ]]
+ [tclTHENLIST [ mk_then tac1; (intros_using [id1]); (loop act1) ];
+ tclTHENLIST [ mk_then tac2; (intros_using [id2]); (loop act2) ]]
| SUM(e3,(k1,e1),(k2,e2)) :: l ->
let id = new_identifier () in
tag_hypothesis id e3;
@@ -1317,10 +1351,10 @@ let replay_history tactic_normalisation =
let p_initial =
if e1.kind == DISE then [P_APP 1; P_TYPE] else [P_APP 2; P_TYPE] in
let tac = shuffle_mult_right p_initial e1.body k2 e2.body in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (tac_thm, [| eq1; eq2; kk; mkVar id1; mkVar id2 |])]);
- Proofview.V82.tactic (mk_then tac);
+ mk_then tac;
(intros_using [id]);
(loop l)
]
@@ -1329,10 +1363,10 @@ let replay_history tactic_normalisation =
and kk2 = mk_integer k2 in
let p_initial = [P_APP 2;P_TYPE] in
let tac= shuffle_mult p_initial k1 e1.body k2 e2.body in
- Tacticals.New.tclTHENS (cut (mk_gt kk1 izero))
- [Tacticals.New.tclTHENS
+ tclTHENS (cut (mk_gt kk1 izero))
+ [tclTHENS
(cut (mk_gt kk2 izero))
- [Tacticals.New.tclTHENLIST [
+ [tclTHENLIST [
(intros_using [aux2;aux1]);
(generalize_tac
[mkApp (Lazy.force coq_OMEGA7, [|
@@ -1340,29 +1374,29 @@ let replay_history tactic_normalisation =
mkVar aux1;mkVar aux2;
mkVar id1;mkVar id2 |])]);
(clear [aux1;aux2]);
- Proofview.V82.tactic (mk_then tac);
+ mk_then tac;
(intros_using [id]);
(loop l) ];
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
reflexivity ] ];
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
unfold sp_Zgt;
simpl_in_concl;
reflexivity ] ]
| CONSTANT_NOT_NUL(e,k) :: l ->
- Tacticals.New.tclTHEN ((generalize_tac [mkVar (hyp_of_tag e)])) Equality.discrConcl
+ tclTHEN ((generalize_tac [mkVar (hyp_of_tag e)])) Equality.discrConcl
| CONSTANT_NUL(e) :: l ->
- Tacticals.New.tclTHEN (Proofview.V82.tactic (resolve_id (hyp_of_tag e))) reflexivity
+ tclTHEN (resolve_id (hyp_of_tag e)) reflexivity
| CONSTANT_NEG(e,k) :: l ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac [mkVar (hyp_of_tag e)]);
unfold sp_Zle;
simpl_in_concl;
unfold sp_not;
(intros_using [aux]);
- Proofview.V82.tactic (resolve_id aux);
+ resolve_id aux;
reflexivity
]
| _ -> Proofview.tclUNIT ()
@@ -1380,12 +1414,12 @@ let normalize_equation sigma id flag theorem pos t t1 t2 (tactic,defs) =
let (tac,t') = normalize sigma p_initial t in
let shift_left =
tclTHEN
- (Proofview.V82.of_tactic (generalize_tac [mkApp (theorem, [| t1; t2; mkVar id |]) ]))
- (tclTRY (Proofview.V82.of_tactic (clear [id])))
+ (generalize_tac [mkApp (theorem, [| t1; t2; mkVar id |]) ])
+ (tclTRY (clear [id]))
in
if not (List.is_empty tac) then
let id' = new_identifier () in
- ((id',(Tacticals.New.tclTHENLIST [ Proofview.V82.tactic (shift_left); Proofview.V82.tactic (mk_then tac); (intros_using [id']) ]))
+ ((id',(tclTHENLIST [ shift_left; mk_then tac; (intros_using [id']) ]))
:: tactic,
compile id' flag t' :: defs)
else
@@ -1430,7 +1464,7 @@ let destructure_omega gl tac_def (id,c) =
let reintroduce id =
(* [id] cannot be cleared if dependent: protect it by a try *)
- Tacticals.New.tclTHEN (Tacticals.New.tclTRY (clear [id])) (intro_using id)
+ tclTHEN (tclTRY (clear [id])) (intro_using id)
open Proofview.Notations
@@ -1449,7 +1483,7 @@ let coq_omega =
let id = new_identifier () in
let i = new_id () in
tag_hypothesis id i;
- (Tacticals.New.tclTHENLIST [
+ (tclTHENLIST [
(simplest_elim (applist (Lazy.force coq_intro_Z, [t])));
(intros_using [v; id]);
(elim_id id);
@@ -1460,7 +1494,7 @@ let coq_omega =
body = [{v=intern_id v; c=one}];
constant = zero; id = i} :: sys
else
- (Tacticals.New.tclTHENLIST [
+ (tclTHENLIST [
(simplest_elim (applist (Lazy.force coq_new_var, [t])));
(intros_using [v;th]);
tac ]),
@@ -1476,13 +1510,13 @@ let coq_omega =
with UNSOLVABLE ->
let _,path = depend [] [] (history ()) in
if !display_action_flag then display_action display_var path;
- (Tacticals.New.tclTHEN prelude (replay_history tactic_normalisation path))
+ (tclTHEN prelude (replay_history tactic_normalisation path))
end else begin
try
let path = simplify_strong (new_id,new_var_num,display_var) system in
if !display_action_flag then display_action display_var path;
- Tacticals.New.tclTHEN prelude (replay_history tactic_normalisation path)
- with NO_CONTRADICTION -> Tacticals.New.tclZEROMSG (Pp.str"Omega can't solve this system")
+ tclTHEN prelude (replay_history tactic_normalisation path)
+ with NO_CONTRADICTION -> tclZEROMSG (Pp.str"Omega can't solve this system")
end
end }
@@ -1495,36 +1529,36 @@ let nat_inject =
Proofview.tclEVARMAP >>= fun sigma ->
try match destructurate_term sigma t with
| Kapp(Plus,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
- Proofview.V82.tactic (clever_rewrite_gen p (mk_plus (mk_inj t1) (mk_inj t2))
+ tclTHENLIST [
+ (clever_rewrite_gen p (mk_plus (mk_inj t1) (mk_inj t2))
((Lazy.force coq_inj_plus),[t1;t2]));
(explore (P_APP 1 :: p) t1);
(explore (P_APP 2 :: p) t2)
]
| Kapp(Mult,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
- Proofview.V82.tactic (clever_rewrite_gen p (mk_times (mk_inj t1) (mk_inj t2))
+ tclTHENLIST [
+ (clever_rewrite_gen p (mk_times (mk_inj t1) (mk_inj t2))
((Lazy.force coq_inj_mult),[t1;t2]));
(explore (P_APP 1 :: p) t1);
(explore (P_APP 2 :: p) t2)
]
| Kapp(Minus,[t1;t2]) ->
let id = new_identifier () in
- Tacticals.New.tclTHENS
- (Tacticals.New.tclTHEN
+ tclTHENS
+ (tclTHEN
(simplest_elim (applist (Lazy.force coq_le_gt_dec, [t2;t1])))
(intros_using [id]))
[
- Tacticals.New.tclTHENLIST [
- Proofview.V82.tactic (clever_rewrite_gen p
+ tclTHENLIST [
+ (clever_rewrite_gen p
(mk_minus (mk_inj t1) (mk_inj t2))
((Lazy.force coq_inj_minus1),[t1;t2;mkVar id]));
(loop [id,mkApp (Lazy.force coq_le, [| t2;t1 |])]);
(explore (P_APP 1 :: p) t1);
(explore (P_APP 2 :: p) t2) ];
- (Tacticals.New.tclTHEN
- (Proofview.V82.tactic (clever_rewrite_gen p (mk_integer zero)
- ((Lazy.force coq_inj_minus2),[t1;t2;mkVar id])))
+ (tclTHEN
+ (clever_rewrite_gen p (mk_integer zero)
+ ((Lazy.force coq_inj_minus2),[t1;t2;mkVar id]))
(loop [id,mkApp (Lazy.force coq_gt, [| t2;t1 |])]))
]
| Kapp(S,[t']) ->
@@ -1538,24 +1572,24 @@ let nat_inject =
let rec loop p t : unit Proofview.tactic =
try match destructurate_term sigma t with
Kapp(S,[t]) ->
- (Tacticals.New.tclTHEN
- (Proofview.V82.tactic (clever_rewrite_gen p
+ (tclTHEN
+ (clever_rewrite_gen p
(mkApp (Lazy.force coq_Zsucc, [| mk_inj t |]))
- ((Lazy.force coq_inj_S),[t])))
+ ((Lazy.force coq_inj_S),[t]))
(loop (P_APP 1 :: p) t))
| _ -> explore p t
with e when catchable_exception e -> explore p t
in
- if is_number t' then Proofview.V82.tactic (focused_simpl p) else loop p t
+ if is_number t' then focused_simpl p else loop p t
| Kapp(Pred,[t]) ->
let t_minus_one =
mkApp (Lazy.force coq_minus, [| t;
mkApp (Lazy.force coq_S, [| Lazy.force coq_O |]) |]) in
- Tacticals.New.tclTHEN
- (Proofview.V82.tactic (clever_rewrite_gen_nat (P_APP 1 :: p) t_minus_one
- ((Lazy.force coq_pred_of_minus),[t])))
+ tclTHEN
+ (clever_rewrite_gen_nat (P_APP 1 :: p) t_minus_one
+ ((Lazy.force coq_pred_of_minus),[t]))
(explore p t_minus_one)
- | Kapp(O,[]) -> Proofview.V82.tactic (focused_simpl p)
+ | Kapp(O,[]) -> focused_simpl p
| _ -> Proofview.tclUNIT ()
with e when catchable_exception e -> Proofview.tclUNIT ()
@@ -1565,7 +1599,7 @@ let nat_inject =
Proofview.tclEVARMAP >>= fun sigma ->
begin try match destructurate_prop sigma t with
Kapp(Le,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_le, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 1; P_TYPE] t1);
@@ -1574,7 +1608,7 @@ let nat_inject =
(loop lit)
]
| Kapp(Lt,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_lt, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 1; P_TYPE] t1);
@@ -1583,7 +1617,7 @@ let nat_inject =
(loop lit)
]
| Kapp(Ge,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_ge, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 1; P_TYPE] t1);
@@ -1592,7 +1626,7 @@ let nat_inject =
(loop lit)
]
| Kapp(Gt,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_gt, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 1; P_TYPE] t1);
@@ -1601,7 +1635,7 @@ let nat_inject =
(loop lit)
]
| Kapp(Neq,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_neq, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 1; P_TYPE] t1);
@@ -1611,7 +1645,7 @@ let nat_inject =
]
| Kapp(Eq,[typ;t1;t2]) ->
if is_conv typ (Lazy.force coq_nat) then
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_inj_eq, [| t1;t2;mkVar i |]) ]);
(explore [P_APP 2; P_TYPE] t1);
@@ -1697,20 +1731,20 @@ let fresh_id avoid id gl =
let onClearedName id tac =
(* We cannot ensure that hyps can be cleared (because of dependencies), *)
(* so renaming may be necessary *)
- Tacticals.New.tclTHEN
- (Tacticals.New.tclTRY (clear [id]))
- (Proofview.Goal.enter { enter = begin fun gl ->
+ tclTHEN
+ (tclTRY (clear [id]))
+ (Proofview.Goal.nf_enter { enter = begin fun gl ->
let id = fresh_id [] id gl in
- Tacticals.New.tclTHEN (introduction id) (tac id)
+ tclTHEN (introduction id) (tac id)
end })
let onClearedName2 id tac =
- Tacticals.New.tclTHEN
- (Tacticals.New.tclTRY (clear [id]))
- (Proofview.Goal.enter { enter = begin fun gl ->
+ tclTHEN
+ (tclTRY (clear [id]))
+ (Proofview.Goal.nf_enter { enter = begin fun gl ->
let id1 = fresh_id [] (add_suffix id "_left") gl in
let id2 = fresh_id [] (add_suffix id "_right") gl in
- Tacticals.New.tclTHENLIST [ introduction id1; introduction id2; tac id1 id2 ]
+ tclTHENLIST [ introduction id1; introduction id2; tac id1 id2 ]
end })
let rec is_Prop sigma c = match EConstr.kind sigma c with
@@ -1724,7 +1758,7 @@ let destructure_hyps =
let decidability = decidability gl in
let pf_nf = pf_nf gl in
let rec loop = function
- | [] -> (Tacticals.New.tclTHEN nat_inject coq_omega)
+ | [] -> (tclTHEN nat_inject coq_omega)
| decl::lit ->
let i = NamedDecl.get_id decl in
Proofview.tclEVARMAP >>= fun sigma ->
@@ -1732,17 +1766,17 @@ let destructure_hyps =
| Kapp(False,[]) -> elim_id i
| Kapp((Zle|Zge|Zgt|Zlt|Zne),[t1;t2]) -> loop lit
| Kapp(Or,[t1;t2]) ->
- (Tacticals.New.tclTHENS
+ (tclTHENS
(elim_id i)
[ onClearedName i (fun i -> (loop (LocalAssum (i,t1)::lit)));
onClearedName i (fun i -> (loop (LocalAssum (i,t2)::lit))) ])
| Kapp(And,[t1;t2]) ->
- Tacticals.New.tclTHEN
+ tclTHEN
(elim_id i)
(onClearedName2 i (fun i1 i2 ->
loop (LocalAssum (i1,t1) :: LocalAssum (i2,t2) :: lit)))
| Kapp(Iff,[t1;t2]) ->
- Tacticals.New.tclTHEN
+ tclTHEN
(elim_id i)
(onClearedName2 i (fun i1 i2 ->
loop (LocalAssum (i1,mkArrow t1 t2) :: LocalAssum (i2,mkArrow t2 t1) :: lit)))
@@ -1752,7 +1786,7 @@ let destructure_hyps =
if is_Prop sigma (type_of t2)
then
let d1 = decidability t1 in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac [mkApp (Lazy.force coq_imp_simp,
[| t1; t2; d1; mkVar i|])]);
(onClearedName i (fun i ->
@@ -1763,7 +1797,7 @@ let destructure_hyps =
| Kapp(Not,[t]) ->
begin match destructurate_prop sigma t with
Kapp(Or,[t1;t2]) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_not_or,[| t1; t2; mkVar i |])]);
(onClearedName i (fun i ->
@@ -1771,7 +1805,7 @@ let destructure_hyps =
]
| Kapp(And,[t1;t2]) ->
let d1 = decidability t1 in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_not_and,
[| t1; t2; d1; mkVar i |])]);
@@ -1781,7 +1815,7 @@ let destructure_hyps =
| Kapp(Iff,[t1;t2]) ->
let d1 = decidability t1 in
let d2 = decidability t2 in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_not_iff,
[| t1; t2; d1; d2; mkVar i |])]);
@@ -1793,7 +1827,7 @@ let destructure_hyps =
(* t2 must be in Prop otherwise ~(t1->t2) wouldn't be ok.
For t1, being decidable implies being Prop. *)
let d1 = decidability t1 in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_not_imp,
[| t1; t2; d1; mkVar i |])]);
@@ -1802,7 +1836,7 @@ let destructure_hyps =
]
| Kapp(Not,[t]) ->
let d = decidability t in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force coq_not_not, [| t; d; mkVar i |])]);
(onClearedName i (fun i -> (loop (LocalAssum (i,t) :: lit))))
@@ -1810,7 +1844,7 @@ let destructure_hyps =
| Kapp(op,[t1;t2]) ->
(try
let thm = not_binop op in
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(generalize_tac
[mkApp (Lazy.force thm, [| t1;t2;mkVar i|])]);
(onClearedName i (fun _ -> loop lit))
@@ -1820,14 +1854,14 @@ let destructure_hyps =
if !old_style_flag then begin
match destructurate_type sigma (pf_nf typ) with
| Kapp(Nat,_) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(simplest_elim
(mkApp
(Lazy.force coq_not_eq, [|t1;t2;mkVar i|])));
(onClearedName i (fun _ -> loop lit))
]
| Kapp(Z,_) ->
- Tacticals.New.tclTHENLIST [
+ tclTHENLIST [
(simplest_elim
(mkApp
(Lazy.force coq_not_Zeq, [|t1;t2;mkVar i|])));
@@ -1837,12 +1871,12 @@ let destructure_hyps =
end else begin
match destructurate_type sigma (pf_nf typ) with
| Kapp(Nat,_) ->
- (Tacticals.New.tclTHEN
+ (tclTHEN
(convert_hyp_no_check (NamedDecl.set_type (mkApp (Lazy.force coq_neq, [| t1;t2|]))
decl))
(loop lit))
| Kapp(Z,_) ->
- (Tacticals.New.tclTHEN
+ (tclTHEN
(convert_hyp_no_check (NamedDecl.set_type (mkApp (Lazy.force coq_Zne, [| t1;t2|]))
decl))
(loop lit))
@@ -1870,23 +1904,24 @@ let destructure_goal =
Proofview.V82.wrap_exceptions prop >>= fun prop ->
match prop with
| Kapp(Not,[t]) ->
- (Tacticals.New.tclTHEN
- (Tacticals.New.tclTHEN (unfold sp_not) intro)
+ (tclTHEN
+ (tclTHEN (unfold sp_not) intro)
destructure_hyps)
- | Kimp(a,b) -> (Tacticals.New.tclTHEN intro (loop b))
+ | Kimp(a,b) -> (tclTHEN intro (loop b))
| Kapp(False,[]) -> destructure_hyps
| _ ->
let goal_tac =
try
let dec = decidability t in
- Tacticals.New.tclTHEN
- (Proofview.V82.tactic (Tacmach.refine
- (mkApp (Lazy.force coq_dec_not_not, [| t; dec; mkNewMeta () |]))))
+ tclTHEN
+ (Proofview.Goal.nf_enter { enter = begin fun gl ->
+ refine_app gl (mkApp (Lazy.force coq_dec_not_not, [| t; dec |]))
+ end })
intro
with Undecidable -> Tactics.elim_type (Lazy.force coq_False)
| e when Proofview.V82.catchable_exception e -> Proofview.tclZERO e
in
- Tacticals.New.tclTHEN goal_tac destructure_hyps
+ tclTHEN goal_tac destructure_hyps
in
(loop concl)
end }
diff --git a/plugins/omega/omega.ml b/plugins/omega/omega.ml
index bd991a955c..334b03de1d 100644
--- a/plugins/omega/omega.ml
+++ b/plugins/omega/omega.ml
@@ -330,11 +330,13 @@ let omega_mod a b = a - b * floor_div (two * a + b) (two * b)
let banerjee_step (new_eq_id,new_var_id,print_var) original l1 l2 =
let e = original.body in
let sigma = new_var_id () in
+ if e == [] then begin
+ display_system print_var [original] ; failwith "TL"
+ end;
let smallest,var =
- try
- List.fold_left (fun (v,p) c -> if v >? (abs c.c) then abs c.c,c.v else (v,p))
- (abs (List.hd e).c, (List.hd e).v) (List.tl e)
- with Failure "tl" -> display_system print_var [original] ; failwith "TL" in
+ List.fold_left (fun (v,p) c -> if v >? (abs c.c) then abs c.c,c.v else (v,p))
+ (abs (List.hd e).c, (List.hd e).v) (List.tl e)
+ in
let m = smallest + one in
let new_eq =
{ constant = omega_mod original.constant m;
diff --git a/plugins/romega/const_omega.ml b/plugins/romega/const_omega.ml
index 5c68078d7d..8d7ae51fc0 100644
--- a/plugins/romega/const_omega.ml
+++ b/plugins/romega/const_omega.ml
@@ -285,7 +285,7 @@ module type Int = sig
val mk : Bigint.bigint -> Term.constr
val parse_term : Term.constr -> parse_term
- val parse_rel : Proof_type.goal Tacmach.sigma -> Term.constr -> parse_rel
+ val parse_rel : ([ `NF ], 'r) Proofview.Goal.t -> Term.constr -> parse_rel
(* check whether t is built only with numbers and + * - *)
val is_scalar : Term.constr -> bool
end
@@ -350,10 +350,12 @@ let parse_term t =
| _ -> Tother
with e when Logic.catchable_exception e -> Tother
+let pf_nf gl c = Tacmach.New.pf_apply Tacred.simpl gl c
+
let parse_rel gl t =
try match destructurate t with
| Kapp("eq",[typ;t1;t2])
- when destructurate (EConstr.Unsafe.to_constr (Tacmach.pf_nf gl (EConstr.of_constr typ))) = Kapp("Z",[]) -> Req (t1,t2)
+ when destructurate (EConstr.Unsafe.to_constr (pf_nf gl (EConstr.of_constr typ))) = Kapp("Z",[]) -> Req (t1,t2)
| Kapp("Zne",[t1;t2]) -> Rne (t1,t2)
| Kapp("Z.le",[t1;t2]) -> Rle (t1,t2)
| Kapp("Z.lt",[t1;t2]) -> Rlt (t1,t2)
diff --git a/plugins/romega/const_omega.mli b/plugins/romega/const_omega.mli
index af50ea0fff..ee7ff451a9 100644
--- a/plugins/romega/const_omega.mli
+++ b/plugins/romega/const_omega.mli
@@ -168,7 +168,7 @@ module type Int =
(* parsing a term (one level, except if a number is found) *)
val parse_term : Term.constr -> parse_term
(* parsing a relation expression, including = < <= >= > *)
- val parse_rel : Proof_type.goal Tacmach.sigma -> Term.constr -> parse_rel
+ val parse_rel : ([ `NF ], 'r) Proofview.Goal.t -> Term.constr -> parse_rel
(* Is a particular term only made of numbers and + * - ? *)
val is_scalar : Term.constr -> bool
end
diff --git a/plugins/romega/g_romega.ml4 b/plugins/romega/g_romega.ml4
index 9a54ad7789..df7e5cb99e 100644
--- a/plugins/romega/g_romega.ml4
+++ b/plugins/romega/g_romega.ml4
@@ -38,7 +38,7 @@ let romega_tactic l =
we'd better leave as little as possible in the conclusion,
for an easier decidability argument. *)
(Tactics.intros)
- (Proofview.V82.tactic total_reflexive_omega_tactic))
+ (total_reflexive_omega_tactic))
TACTIC EXTEND romega
diff --git a/plugins/romega/refl_omega.ml b/plugins/romega/refl_omega.ml
index cfe14b230c..a20589fb46 100644
--- a/plugins/romega/refl_omega.ml
+++ b/plugins/romega/refl_omega.ml
@@ -8,6 +8,7 @@
open Pp
open Util
+open Proofview.Notations
open Const_omega
module OmegaSolver = Omega_plugin.Omega.MakeOmegaSolver (Bigint)
open OmegaSolver
@@ -16,13 +17,12 @@ open OmegaSolver
(* Especially useful debugging functions *)
let debug = ref false
-let show_goal gl =
- if !debug then (); Tacticals.tclIDTAC gl
+let show_goal = Tacticals.New.tclIDTAC
let pp i = print_int i; print_newline (); flush stdout
(* More readable than the prefix notation *)
-let (>>) = Tacticals.tclTHEN
+let (>>) = Tacticals.New.tclTHEN
let mkApp = Term.mkApp
@@ -739,7 +739,7 @@ and oproposition_of_constr env ((negated,depends,origin,path) as ctxt) gl c =
(* Destructuration des hypothèses et de la conclusion *)
let reify_gl env gl =
- let concl = Tacmach.pf_concl gl in
+ let concl = Tacmach.New.pf_concl gl in
let concl = EConstr.Unsafe.to_constr concl in
let t_concl =
Pnot (oproposition_of_constr env (true,[],id_concl,[O_mono]) gl concl) in
@@ -760,7 +760,7 @@ let reify_gl env gl =
| [] ->
if !debug then print_env_reification env;
[] in
- let t_lhyps = loop (Tacmach.pf_hyps_types gl) in
+ let t_lhyps = loop (Tacmach.New.pf_hyps_types gl) in
(id_concl,t_concl) :: t_lhyps
let rec destructurate_pos_hyp orig list_equations list_depends = function
@@ -1283,21 +1283,22 @@ let resolution env full_reified_goal systems_list =
CCHyp{o_hyp=id_concl;o_path=[]} :: hyp_stated_vars @ initial_context in
let decompose_tactic = decompose_tree env context solution_tree in
- Proofview.V82.of_tactic (Tactics.generalize
- (l_generalize_arg @ List.map EConstr.mkVar (List.tl l_hyps))) >>
- Proofview.V82.of_tactic (Tactics.change_concl reified) >>
- Proofview.V82.of_tactic (Tactics.apply (EConstr.of_constr (app coq_do_omega [|decompose_tactic; normalization_trace|]))) >>
+ Tactics.generalize
+ (l_generalize_arg @ List.map EConstr.mkVar (List.tl l_hyps)) >>
+ Tactics.change_concl reified >>
+ Tactics.apply (EConstr.of_constr (app coq_do_omega [|decompose_tactic; normalization_trace|])) >>
show_goal >>
- Proofview.V82.of_tactic (Tactics.normalise_vm_in_concl) >>
+ Tactics.normalise_vm_in_concl >>
(*i Alternatives to the previous line:
- Normalisation without VM:
Tactics.normalise_in_concl
- Skip the conversion check and rely directly on the QED:
Tacmach.convert_concl_no_check (Lazy.force coq_True) Term.VMcast >>
i*)
- Proofview.V82.of_tactic (Tactics.apply (EConstr.of_constr (Lazy.force coq_I)))
+ Tactics.apply (EConstr.of_constr (Lazy.force coq_I))
-let total_reflexive_omega_tactic gl =
+let total_reflexive_omega_tactic =
+ Proofview.Goal.nf_enter { enter = begin fun gl ->
Coqlib.check_required_library ["Coq";"romega";"ROmega"];
rst_omega_eq ();
rst_omega_var ();
@@ -1306,9 +1307,9 @@ let total_reflexive_omega_tactic gl =
let full_reified_goal = reify_gl env gl in
let systems_list = destructurate_hyps full_reified_goal in
if !debug then display_systems systems_list;
- resolution env full_reified_goal systems_list gl
+ resolution env full_reified_goal systems_list
with NO_CONTRADICTION -> CErrors.error "ROmega can't solve this system"
-
+ end }
(*i let tester = Tacmach.hide_atomic_tactic "TestOmega" test_tactic i*)
diff --git a/plugins/rtauto/refl_tauto.ml b/plugins/rtauto/refl_tauto.ml
index f30f8a9438..3655df8951 100644
--- a/plugins/rtauto/refl_tauto.ml
+++ b/plugins/rtauto/refl_tauto.ml
@@ -95,7 +95,6 @@ let rec make_form atom_env gls term =
let normalize=special_nf gls in
let cciterm=special_whd gls term in
let sigma = Tacmach.project gls in
- let inj = EConstr.Unsafe.to_constr in
match EConstr.kind sigma cciterm with
Prod(_,a,b) ->
if noccurn sigma 1 b &&
diff --git a/plugins/setoid_ring/newring.ml b/plugins/setoid_ring/newring.ml
index dd68eac24c..d59ffee546 100644
--- a/plugins/setoid_ring/newring.ml
+++ b/plugins/setoid_ring/newring.ml
@@ -19,7 +19,6 @@ open Environ
open Libnames
open Globnames
open Glob_term
-open Tacticals
open Tacexpr
open Coqlib
open Mod_subst
@@ -279,8 +278,6 @@ let my_constant c =
let my_reference c =
lazy (Coqlib.gen_reference_in_modules "Ring" plugin_modules c)
-let new_ring_path =
- DirPath.make (List.map Id.of_string ["Ring_tac";plugin_dir;"Coq"])
let znew_ring_path =
DirPath.make (List.map Id.of_string ["InitialRing";plugin_dir;"Coq"])
let zltac s =
diff --git a/plugins/setoid_ring/newring.mli b/plugins/setoid_ring/newring.mli
index 4367d021c0..d9d32c681d 100644
--- a/plugins/setoid_ring/newring.mli
+++ b/plugins/setoid_ring/newring.mli
@@ -7,13 +7,10 @@
(************************************************************************)
open Names
-open Constr
open EConstr
open Libnames
open Globnames
open Constrexpr
-open Tacexpr
-open Proof_type
open Newring_ast
val protect_tac_in : string -> Id.t -> unit Proofview.tactic
diff --git a/plugins/ssrmatching/ssrmatching.ml4 b/plugins/ssrmatching/ssrmatching.ml4
index f3555ebc4c..72c70750c9 100644
--- a/plugins/ssrmatching/ssrmatching.ml4
+++ b/plugins/ssrmatching/ssrmatching.ml4
@@ -21,30 +21,21 @@ open Pp
open Pcoq
open Genarg
open Stdarg
-open Tacarg
open Term
open Vars
-open Topconstr
open Libnames
open Tactics
open Tacticals
open Termops
-open Namegen
open Recordops
open Tacmach
-open Coqlib
open Glob_term
open Util
open Evd
-open Extend
-open Goptions
open Tacexpr
-open Proofview.Notations
open Tacinterp
open Pretyping
open Constr
-open Pltac
-open Extraargs
open Ppconstr
open Printer
@@ -54,14 +45,9 @@ open Decl_kinds
open Evar_kinds
open Constrexpr
open Constrexpr_ops
-open Notation_term
-open Notation_ops
-open Locus
-open Locusops
DECLARE PLUGIN "ssrmatching_plugin"
-type loc = Loc.t
let dummy_loc = Loc.ghost
let errorstrm = CErrors.user_err ~hdr:"ssrmatching"
let loc_error loc msg = CErrors.user_err ~loc ~hdr:msg (str msg)
@@ -90,8 +76,6 @@ let pp s = !pp_ref s
let env_size env = List.length (Environ.named_context env)
let safeDestApp c =
match kind_of_term c with App (f, a) -> f, a | _ -> c, [| |]
-let get_index = function ArgArg i -> i | _ ->
- CErrors.anomaly (str"Uninterpreted index")
(* Toplevel constr must be globalized twice ! *)
let glob_constr ist genv = function
| _, Some ce ->
@@ -304,8 +288,6 @@ let unif_EQ_args env sigma pa a =
let unif_HO env ise p c = Evarconv.the_conv_x env p c ise
-let unif_HOtype env ise p c = Evarconv.the_conv_x_leq env p c ise
-
let unif_HO_args env ise0 pa i ca =
let n = Array.length pa in
let rec loop ise j =
@@ -371,11 +353,6 @@ let unif_end env sigma0 ise0 pt ok =
let s, uc', t = nf_open_term sigma0 ise2 t in
s, Evd.union_evar_universe_context uc uc', t
-let pf_unif_HO gl sigma pt p c =
- let env = pf_env gl in
- let ise = unif_HO env (create_evar_defs sigma) p c in
- unif_end env (project gl) ise pt (fun _ -> true)
-
let unify_HO env sigma0 t1 t2 =
let sigma = unif_HO env sigma0 t1 t2 in
let sigma, uc, _ = unif_end env sigma0 sigma t2 (fun _ -> true) in
@@ -440,16 +417,10 @@ let all_ok _ _ = true
let proj_nparams c =
try 1 + Recordops.find_projection_nparams (ConstRef c) with _ -> 0
-let isFixed c = match kind_of_term c with
- | Var _ | Ind _ | Construct _ | Const _ | Proj _ -> true
- | _ -> false
-
let isRigid c = match kind_of_term c with
| Prod _ | Sort _ | Lambda _ | Case _ | Fix _ | CoFix _ -> true
| _ -> false
-exception UndefPat
-
let hole_var = mkVar (id_of_string "_")
let pr_constr_pat c0 =
let rec wipe_evar c =
@@ -917,13 +888,6 @@ let pp_pattern (sigma, p) =
let pr_cpattern = pr_term
let pr_rpattern _ _ _ = pr_pattern
-let pr_option f = function None -> mt() | Some x -> f x
-let pr_ssrpattern _ _ _ = pr_option pr_pattern
-let pr_pattern_squarep = pr_option (fun r -> str "[" ++ pr_pattern r ++ str "]")
-let pr_ssrpattern_squarep _ _ _ = pr_pattern_squarep
-let pr_pattern_roundp = pr_option (fun r -> str "(" ++ pr_pattern r ++ str ")")
-let pr_ssrpattern_roundp _ _ _ = pr_pattern_roundp
-
let wit_rpatternty = add_genarg "rpatternty" pr_pattern
let glob_ssrterm gs = function
@@ -1045,7 +1009,6 @@ let interp_wit wit ist gl x =
let arg = interp_genarg ist globarg in
let (sigma, arg) = of_ftactic arg gl in
sigma, Value.cast (topwit wit) arg
-let interp_constr = interp_wit wit_constr
let interp_open_constr ist gl gc =
interp_wit wit_open_constr ist gl gc
let pf_intern_term ist gl (_, c) = glob_constr ist (pf_env gl) c
@@ -1261,7 +1224,7 @@ let eval_pattern ?raise_NoMatch env0 sigma0 concl0 pattern occ do_subst =
let occ = match pattern with Some (_, T _) -> occ | _ -> noindex in
let rp = mk_upat_for env0 sigma0 (ise, rp) all_ok in
let find_T, end_T = mk_tpattern_matcher ?raise_NoMatch sigma0 occ rp in
- let concl = find_T env0 concl0 1 do_subst in
+ let concl = find_T env0 concl0 1 ~k:do_subst in
let _ = end_T () in
concl
| Some (sigma, (X_In_T (hole, p) | In_X_In_T (hole, p))) ->
@@ -1273,11 +1236,11 @@ let eval_pattern ?raise_NoMatch env0 sigma0 concl0 pattern occ do_subst =
(* we start from sigma, so hole is considered a rigid head *)
let holep = mk_upat_for env0 sigma (sigma, hole) all_ok in
let find_X, end_X = mk_tpattern_matcher ?raise_NoMatch sigma occ holep in
- let concl = find_T env0 concl0 1 (fun env c _ h ->
+ let concl = find_T env0 concl0 1 ~k:(fun env c _ h ->
let p_sigma = unify_HO env (create_evar_defs sigma) (EConstr.of_constr c) (EConstr.of_constr p) in
let sigma, e_body = pop_evar p_sigma ex p in
fs p_sigma (find_X env (fs sigma p) h
- (fun env _ -> do_subst env e_body))) in
+ ~k:(fun env _ -> do_subst env e_body))) in
let _ = end_X () in let _ = end_T () in
concl
| Some (sigma, E_In_X_In_T (e, hole, p)) ->
@@ -1289,11 +1252,11 @@ let eval_pattern ?raise_NoMatch env0 sigma0 concl0 pattern occ do_subst =
let find_X, end_X = mk_tpattern_matcher sigma noindex holep in
let re = mk_upat_for env0 sigma0 (sigma, e) all_ok in
let find_E, end_E = mk_tpattern_matcher ?raise_NoMatch sigma0 occ re in
- let concl = find_T env0 concl0 1 (fun env c _ h ->
+ let concl = find_T env0 concl0 1 ~k:(fun env c _ h ->
let p_sigma = unify_HO env (create_evar_defs sigma) (EConstr.of_constr c) (EConstr.of_constr p) in
let sigma, e_body = pop_evar p_sigma ex p in
- fs p_sigma (find_X env (fs sigma p) h (fun env c _ h ->
- find_E env e_body h do_subst))) in
+ fs p_sigma (find_X env (fs sigma p) h ~k:(fun env c _ h ->
+ find_E env e_body h ~k:do_subst))) in
let _ = end_E () in let _ = end_X () in let _ = end_T () in
concl
| Some (sigma, E_As_X_In_T (e, hole, p)) ->
@@ -1306,10 +1269,10 @@ let eval_pattern ?raise_NoMatch env0 sigma0 concl0 pattern occ do_subst =
let find_TE, end_TE = mk_tpattern_matcher sigma0 noindex rp in
let holep = mk_upat_for env0 sigma (sigma, hole) all_ok in
let find_X, end_X = mk_tpattern_matcher sigma occ holep in
- let concl = find_TE env0 concl0 1 (fun env c _ h ->
+ let concl = find_TE env0 concl0 1 ~k:(fun env c _ h ->
let p_sigma = unify_HO env (create_evar_defs sigma) (EConstr.of_constr c) (EConstr.of_constr p) in
let sigma, e_body = pop_evar p_sigma ex p in
- fs p_sigma (find_X env (fs sigma p) h (fun env c _ h ->
+ fs p_sigma (find_X env (fs sigma p) h ~k:(fun env c _ h ->
let e_sigma = unify_HO env sigma (EConstr.of_constr e_body) (EConstr.of_constr e) in
let e_body = fs e_sigma e in
do_subst env e_body e_body h))) in
@@ -1352,7 +1315,7 @@ let pf_fill_occ env concl occ sigma0 p (sigma, t) ok h =
let ise, u = mk_tpattern env sigma0 (ise,EConstr.Unsafe.to_constr t) ok L2R p in
let find_U, end_U =
mk_tpattern_matcher ~raise_NoMatch:true sigma0 occ (ise,[u]) in
- let concl = find_U env concl h (fun _ _ _ -> mkRel) in
+ let concl = find_U env concl h ~k:(fun _ _ _ -> mkRel) in
let rdx, _, (sigma, uc, p) = end_U () in
sigma, uc, EConstr.of_constr p, EConstr.of_constr concl, EConstr.of_constr rdx
diff --git a/plugins/ssrmatching/ssrmatching.mli b/plugins/ssrmatching/ssrmatching.mli
index 894cdb9438..638b4e254e 100644
--- a/plugins/ssrmatching/ssrmatching.mli
+++ b/plugins/ssrmatching/ssrmatching.mli
@@ -4,7 +4,6 @@
open Genarg
open Tacexpr
open Environ
-open Tacmach
open Evd
open Proof_type
open Term
@@ -226,7 +225,6 @@ val loc_of_cpattern : cpattern -> Loc.t
val id_of_pattern : pattern -> Names.variable option
val is_wildcard : cpattern -> bool
val cpattern_of_id : Names.variable -> cpattern
-val cpattern_of_id : Names.variable -> cpattern
val pr_constr_pat : constr -> Pp.std_ppcmds
val pf_merge_uc : Evd.evar_universe_context -> goal Evd.sigma -> goal Evd.sigma
val pf_unsafe_merge_uc : Evd.evar_universe_context -> goal Evd.sigma -> goal Evd.sigma
diff --git a/pretyping/cases.ml b/pretyping/cases.ml
index c5cf74ccfb..6bc2a4f94b 100644
--- a/pretyping/cases.ml
+++ b/pretyping/cases.ml
@@ -563,31 +563,30 @@ let dependencies_in_rhs sigma nargs current tms eqns =
declarations [d(i+1);...;dn] the term [tmi] is dependent in.
[find_dependencies_signature (used1,...,usedn) ((tm1,d1),...,(tmn,dn))]
- returns [(deps1,...,depsn)] where [depsi] is a subset of n,..,i+1
+ returns [(deps1,...,depsn)] where [depsi] is a subset of tm(i+1),..,tmn
denoting in which of the d(i+1)...dn, the term tmi is dependent.
- Dependencies are expressed by index, e.g. in dependency list
- [n-2;1], [1] points to [dn] and [n-2] to [d3]
*)
let rec find_dependency_list sigma tmblock = function
| [] -> []
- | (used,tdeps,d)::rest ->
+ | (used,tdeps,tm,d)::rest ->
let deps = find_dependency_list sigma tmblock rest in
if used && List.exists (fun x -> dependent_decl sigma x d) tmblock
then
- List.add_set Int.equal
- (List.length rest + 1) (List.union Int.equal deps tdeps)
+ match EConstr.kind sigma tm with
+ | Rel n -> List.add_set Int.equal n (List.union Int.equal deps tdeps)
+ | _ -> List.union Int.equal deps tdeps
else deps
let find_dependencies sigma is_dep_or_cstr_in_rhs (tm,(_,tmtypleaves),d) nextlist =
let deps = find_dependency_list sigma (tm::tmtypleaves) nextlist in
if is_dep_or_cstr_in_rhs || not (List.is_empty deps)
- then ((true ,deps,d)::nextlist)
- else ((false,[] ,d)::nextlist)
+ then ((true ,deps,tm,d)::nextlist)
+ else ((false,[] ,tm,d)::nextlist)
let find_dependencies_signature sigma deps_in_rhs typs =
let l = List.fold_right2 (find_dependencies sigma) deps_in_rhs typs [] in
- List.map (fun (_,deps,_) -> deps) l
+ List.map (fun (_,deps,_,_) -> deps) l
(* Assume we had terms t1..tq to match in a context xp:Tp,...,x1:T1 |-
and xn:Tn has just been regeneralized into x:Tn so that the terms
diff --git a/pretyping/cbv.mli b/pretyping/cbv.mli
index b014af2c7f..eb25994bef 100644
--- a/pretyping/cbv.mli
+++ b/pretyping/cbv.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open EConstr
open Environ
open CClosure
diff --git a/pretyping/classops.ml b/pretyping/classops.ml
index 632ba0d9cd..32da81f96c 100644
--- a/pretyping/classops.ml
+++ b/pretyping/classops.ml
@@ -17,7 +17,6 @@ open Nametab
open Environ
open Libobject
open Term
-open Termops
open Mod_subst
(* usage qque peu general: utilise aussi dans record *)
@@ -388,7 +387,7 @@ let add_coercion_in_graph (ic,source,target) =
old_inheritance_graph
end;
let is_ambig = match !ambig_paths with [] -> false | _ -> true in
- if is_ambig && is_verbose () then
+ if is_ambig && not !quiet then
Feedback.msg_info (message_ambig !ambig_paths)
type coercion = {
diff --git a/pretyping/classops.mli b/pretyping/classops.mli
index 0d741a5a5d..c4238e8b0d 100644
--- a/pretyping/classops.mli
+++ b/pretyping/classops.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open Environ
open EConstr
open Evd
diff --git a/pretyping/coercion.ml b/pretyping/coercion.ml
index 542db7fdfa..e6c0075c5b 100644
--- a/pretyping/coercion.ml
+++ b/pretyping/coercion.ml
@@ -22,7 +22,6 @@ open Environ
open EConstr
open Vars
open Reductionops
-open Typeops
open Pretype_errors
open Classops
open Evarutil
@@ -479,8 +478,8 @@ let rec inh_conv_coerce_to_fail loc env evd rigidonly v t c1 =
(* We eta-expand (hence possibly modifying the original term!) *)
(* and look for a coercion c:u1->t1 s.t. fun x:u1 => v' (c x)) *)
(* has type forall (x:u1), u2 (with v' recursively obtained) *)
- (* Note: we retype the term because sort-polymorphism may have *)
- (* weaken its type *)
+ (* Note: we retype the term because template polymorphism may have *)
+ (* weakened its type *)
let name = match name with
| Anonymous -> Name Namegen.default_dependent_ident
| _ -> name in
diff --git a/pretyping/coercion.mli b/pretyping/coercion.mli
index bc63d092d9..ea3d3f0fa1 100644
--- a/pretyping/coercion.mli
+++ b/pretyping/coercion.mli
@@ -8,7 +8,6 @@
open Evd
open Names
-open Term
open Environ
open EConstr
open Glob_term
diff --git a/pretyping/constr_matching.ml b/pretyping/constr_matching.ml
index efe03bc2e9..2334be9664 100644
--- a/pretyping/constr_matching.ml
+++ b/pretyping/constr_matching.ml
@@ -83,32 +83,70 @@ let add_binders na1 na2 binding_vars (names, terms as subst) =
let rec build_lambda sigma vars ctx m = match vars with
| [] ->
- let len = List.length ctx in
- EConstr.Vars.lift (-1 * len) m
+ if Vars.closed0 sigma m then m else raise PatternMatchingFailure
| n :: vars ->
- let open EConstr in
(* change [ x1 ... xn y z1 ... zm |- t ] into
[ x1 ... xn z1 ... zm |- lam y. t ] *)
- let len = List.length ctx in
- let init i =
- if i < pred n then mkRel (i + 2)
- else if Int.equal i (pred n) then mkRel 1
- else mkRel (i + 1)
- in
- let m = Vars.substl (List.init len init) m in
let pre, suf = List.chop (pred n) ctx in
- match suf with
+ let (na, t, suf) = match suf with
| [] -> assert false
- | (_, na, t) :: suf ->
- let map i = if i > n then pred i else i in
- let vars = List.map map vars in
- (** Check that the abstraction is legal *)
- let frels = free_rels sigma t in
- let brels = List.fold_right Int.Set.add vars Int.Set.empty in
- let () = if not (Int.Set.subset frels brels) then raise PatternMatchingFailure in
- (** Create the abstraction *)
- let m = mkLambda (na, t, m) in
- build_lambda sigma vars (pre @ suf) m
+ | (_, na, t) :: suf -> (na, t, suf)
+ in
+ (** Check that the abstraction is legal by generating a transitive closure of
+ its dependencies. *)
+ let is_nondep t clear = match clear with
+ | [] -> true
+ | _ ->
+ let rels = free_rels sigma t in
+ let check i b = b || not (Int.Set.mem i rels) in
+ List.for_all_i check 1 clear
+ in
+ let fold (_, _, t) clear = is_nondep t clear :: clear in
+ (** Produce a list of booleans: true iff we keep the hypothesis *)
+ let clear = List.fold_right fold pre [false] in
+ let clear = List.drop_last clear in
+ (** If the conclusion depends on a variable we cleared, failure *)
+ let () = if not (is_nondep m clear) then raise PatternMatchingFailure in
+ (** Create the abstracted term *)
+ let fold (k, accu) keep =
+ if keep then
+ let k = succ k in
+ (k, Some k :: accu)
+ else (k, None :: accu)
+ in
+ let keep, shift = List.fold_left fold (0, []) clear in
+ let shift = List.rev shift in
+ let map = function
+ | None -> mkProp (** dummy term *)
+ | Some i -> mkRel (i + 1)
+ in
+ (** [x1 ... xn y z1 ... zm] -> [x1 ... xn f(z1) ... f(zm) y] *)
+ let subst =
+ List.map map shift @
+ mkRel 1 ::
+ List.mapi (fun i _ -> mkRel (i + keep + 2)) suf
+ in
+ let map i (id, na, c) =
+ let i = succ i in
+ let subst = List.skipn i subst in
+ let subst = List.map (fun c -> Vars.lift (- i) c) subst in
+ (id, na, substl subst c)
+ in
+ let pre = List.mapi map pre in
+ let pre = List.filter_with clear pre in
+ let m = substl subst m in
+ let map i =
+ if i > n then i - n + keep
+ else match List.nth shift (i - 1) with
+ | None ->
+ (** We cleared a variable that we wanted to abstract! *)
+ raise PatternMatchingFailure
+ | Some k -> k
+ in
+ let vars = List.map map vars in
+ (** Create the abstraction *)
+ let m = mkLambda (na, Vars.lift keep t, m) in
+ build_lambda sigma vars (pre @ suf) m
let rec extract_bound_aux k accu frels ctx = match ctx with
| [] -> accu
diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml
index 8ba4086795..0d798b4d94 100644
--- a/pretyping/detyping.ml
+++ b/pretyping/detyping.ml
@@ -13,7 +13,6 @@ open CErrors
open Util
open Names
open Term
-open Environ
open EConstr
open Vars
open Inductiveops
@@ -423,7 +422,9 @@ let detype_sort sigma = function
| Type u ->
GType
(if !print_universes
- then [dl, Pp.string_of_ppcmds (Univ.Universe.pr_with (Termops.pr_evd_level sigma) u)]
+ then
+ let u = Pp.string_of_ppcmds (Univ.Universe.pr_with (Termops.pr_evd_level sigma) u) in
+ [dl, Name.mk_name (Id.of_string_soft u)]
else [])
type binder_kind = BProd | BLambda | BLetIn
@@ -435,7 +436,8 @@ let detype_anonymous = ref (fun loc n -> anomaly ~label:"detype" (Pp.str "index
let set_detype_anonymous f = detype_anonymous := f
let detype_level sigma l =
- GType (Some (dl, Pp.string_of_ppcmds (Termops.pr_evd_level sigma l)))
+ let l = Pp.string_of_ppcmds (Termops.pr_evd_level sigma l) in
+ GType (Some (dl, Name.mk_name (Id.of_string_soft l)))
let detype_instance sigma l =
let l = EInstance.kind sigma l in
@@ -696,7 +698,7 @@ and detype_binder (lax,isgoal as flags) bk avoid env sigma na body ty c =
let c = detype (lax,false) avoid env sigma (Option.get body) in
(* Heuristic: we display the type if in Prop *)
let s = try Retyping.get_sort_family_of (snd env) sigma ty with _ when !Flags.in_debugger || !Flags.in_toplevel -> InType (* Can fail because of sigma missing in debugger *) in
- let t = if s != InProp then None else Some (detype (lax,false) avoid env sigma ty) in
+ let t = if s != InProp && not !Flags.raw_print then None else Some (detype (lax,false) avoid env sigma ty) in
GLetIn (dl, na', c, t, r)
let detype_rel_context ?(lax=false) where avoid env sigma sign =
diff --git a/pretyping/evarconv.ml b/pretyping/evarconv.ml
index 4bb66b8e91..305eae15a3 100644
--- a/pretyping/evarconv.ml
+++ b/pretyping/evarconv.ml
@@ -21,7 +21,6 @@ open Recordops
open Evarutil
open Evardefine
open Evarsolve
-open Globnames
open Evd
open Pretype_errors
open Sigma.Notations
diff --git a/pretyping/evarconv.mli b/pretyping/evarconv.mli
index fc07f0fbea..7cee1e8a7e 100644
--- a/pretyping/evarconv.mli
+++ b/pretyping/evarconv.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open EConstr
open Environ
open Reductionops
diff --git a/pretyping/evardefine.ml b/pretyping/evardefine.ml
index c5ae684e3b..5fd104c781 100644
--- a/pretyping/evardefine.ml
+++ b/pretyping/evardefine.ml
@@ -11,7 +11,6 @@ open Pp
open Names
open Term
open Termops
-open Environ
open EConstr
open Vars
open Namegen
diff --git a/pretyping/evarsolve.ml b/pretyping/evarsolve.ml
index 77086d046c..f0d0114775 100644
--- a/pretyping/evarsolve.ml
+++ b/pretyping/evarsolve.ml
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-module CVars = Vars
open Util
open CErrors
open Names
diff --git a/pretyping/find_subterm.mli b/pretyping/find_subterm.mli
index e3d3b74f10..d22f94e4e5 100644
--- a/pretyping/find_subterm.mli
+++ b/pretyping/find_subterm.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Locus
-open Term
open Evd
open Pretype_errors
open Environ
diff --git a/pretyping/inductiveops.ml b/pretyping/inductiveops.ml
index 5b42add285..429e5005ec 100644
--- a/pretyping/inductiveops.ml
+++ b/pretyping/inductiveops.ml
@@ -459,7 +459,6 @@ let extract_mrectype sigma t =
| _ -> raise Not_found
let find_mrectype_vect env sigma c =
- let open EConstr in
let (t, l) = Termops.decompose_app_vect sigma (whd_all env sigma c) in
match EConstr.kind sigma t with
| Ind ind -> (ind, l)
diff --git a/pretyping/miscops.ml b/pretyping/miscops.ml
index 7fe81c9a43..1669f8334b 100644
--- a/pretyping/miscops.ml
+++ b/pretyping/miscops.ml
@@ -30,7 +30,7 @@ let smartmap_cast_type f c =
let glob_sort_eq g1 g2 = match g1, g2 with
| GProp, GProp -> true
| GSet, GSet -> true
-| GType l1, GType l2 -> List.equal (fun x y -> CString.equal (snd x) (snd y)) l1 l2
+| GType l1, GType l2 -> List.equal (fun x y -> Names.Name.equal (snd x) (snd y)) l1 l2
| _ -> false
let intro_pattern_naming_eq nam1 nam2 = match nam1, nam2 with
diff --git a/pretyping/patternops.ml b/pretyping/patternops.ml
index 318f94be24..33a68589c1 100644
--- a/pretyping/patternops.ml
+++ b/pretyping/patternops.ml
@@ -20,7 +20,6 @@ open Mod_subst
open Misctypes
open Decl_kinds
open Pattern
-open Evd
open Environ
let case_info_pattern_eq i1 i2 =
@@ -156,7 +155,7 @@ let pattern_of_constr env sigma t =
| Construct (sp,u) -> PRef (canonical_gr (ConstructRef sp))
| Proj (p, c) ->
pattern_of_constr env (EConstr.Unsafe.to_constr (Retyping.expand_projection env sigma p (EConstr.of_constr c) []))
- | Evar (evk,ctxt as ev) ->
+ | Evar (evk,ctxt) ->
(match snd (Evd.evar_source evk sigma) with
| Evar_kinds.MatchingVar (b,id) ->
assert (not b); PMeta (Some id)
@@ -220,6 +219,8 @@ let instantiate_pattern env sigma lvar c =
ctx
in
let c = substl inst c in
+ (** FIXME: Stupid workaround to pattern_of_constr being evar sensitive *)
+ let c = Evarutil.nf_evar sigma c in
pattern_of_constr env sigma (EConstr.Unsafe.to_constr c)
with Not_found (* List.index failed *) ->
let vars =
diff --git a/pretyping/patternops.mli b/pretyping/patternops.mli
index 5694d345c1..791fd74ed3 100644
--- a/pretyping/patternops.mli
+++ b/pretyping/patternops.mli
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Term
open EConstr
open Globnames
open Glob_term
diff --git a/pretyping/pretype_errors.ml b/pretyping/pretype_errors.ml
index 24f6d16899..f9cf6b83bc 100644
--- a/pretyping/pretype_errors.ml
+++ b/pretyping/pretype_errors.ml
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Util
open Names
open Term
open Environ
diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml
index a042b73c28..4886423bd0 100644
--- a/pretyping/pretyping.ml
+++ b/pretyping/pretyping.ml
@@ -33,7 +33,6 @@ open EConstr
open Vars
open Reductionops
open Type_errors
-open Typeops
open Typing
open Globnames
open Nameops
@@ -193,45 +192,51 @@ let _ =
optwrite = (:=) Universes.set_minimization })
(** Miscellaneous interpretation functions *)
-let interp_universe_level_name evd (loc,s) =
- let names, _ = Global.global_universe_names () in
- if CString.string_contains s "." then
- match List.rev (CString.split '.' s) with
- | [] -> anomaly (str"Invalid universe name " ++ str s)
- | n :: dp ->
- let num = int_of_string n in
- let dp = DirPath.make (List.map Id.of_string dp) in
- let level = Univ.Level.make dp num in
- let evd =
- try Evd.add_global_univ evd level
- with UGraph.AlreadyDeclared -> evd
- in evd, level
- else
- try
- let level = Evd.universe_of_name evd s in
- evd, level
- with Not_found ->
- try
- let id = try Id.of_string s with _ -> raise Not_found in
- evd, snd (Idmap.find id names)
- with Not_found ->
- if not (is_strict_universe_declarations ()) then
- new_univ_level_variable ~loc ~name:s univ_rigid evd
- else user_err ~loc ~hdr:"interp_universe_level_name"
- (Pp.(str "Undeclared universe: " ++ str s))
+let interp_universe_level_name ~anon_rigidity evd (loc,s) =
+ match s with
+ | Anonymous ->
+ new_univ_level_variable ~loc anon_rigidity evd
+ | Name s ->
+ let s = Id.to_string s in
+ let names, _ = Global.global_universe_names () in
+ if CString.string_contains ~where:s ~what:"." then
+ match List.rev (CString.split '.' s) with
+ | [] -> anomaly (str"Invalid universe name " ++ str s)
+ | n :: dp ->
+ let num = int_of_string n in
+ let dp = DirPath.make (List.map Id.of_string dp) in
+ let level = Univ.Level.make dp num in
+ let evd =
+ try Evd.add_global_univ evd level
+ with UGraph.AlreadyDeclared -> evd
+ in evd, level
+ else
+ try
+ let level = Evd.universe_of_name evd s in
+ evd, level
+ with Not_found ->
+ try
+ let id = try Id.of_string s with _ -> raise Not_found in
+ evd, snd (Idmap.find id names)
+ with Not_found ->
+ if not (is_strict_universe_declarations ()) then
+ new_univ_level_variable ~loc ~name:s univ_rigid evd
+ else user_err ~loc ~hdr:"interp_universe_level_name"
+ (Pp.(str "Undeclared universe: " ++ str s))
let interp_universe ?loc evd = function
| [] -> let evd, l = new_univ_level_variable ?loc univ_rigid evd in
evd, Univ.Universe.make l
| l ->
List.fold_left (fun (evd, u) l ->
- let evd', l = interp_universe_level_name evd l in
+ (* [univ_flexible_alg] can produce algebraic universes in terms *)
+ let evd', l = interp_universe_level_name ~anon_rigidity:univ_flexible evd l in
(evd', Univ.sup u (Univ.Universe.make l)))
(evd, Univ.Universe.type0m) l
-let interp_universe_level loc evd = function
+let interp_level_info loc evd : Misctypes.level_info -> _ = function
| None -> new_univ_level_variable ~loc univ_rigid evd
- | Some (loc,s) -> interp_universe_level_name evd (loc,s)
+ | Some (loc,s) -> interp_universe_level_name ~anon_rigidity:univ_flexible evd (loc,s)
let interp_sort ?loc evd = function
| GProp -> evd, Prop Null
@@ -489,11 +494,28 @@ let pretype_id pretype k0 loc env evdref lvar id =
(*************************************************************************)
(* Main pretyping function *)
-let interp_universe_level_name loc evd l =
- match l with
+let interp_glob_level loc evd : Misctypes.glob_level -> _ = function
| GProp -> evd, Univ.Level.prop
| GSet -> evd, Univ.Level.set
- | GType s -> interp_universe_level loc evd s
+ | GType s -> interp_level_info loc evd s
+
+let interp_instance loc evd ~len l =
+ if len != List.length l then
+ user_err ~loc ~hdr:"pretype"
+ (str "Universe instance should have length " ++ int len)
+ else
+ let evd, l' =
+ List.fold_left
+ (fun (evd, univs) l ->
+ let evd, l = interp_glob_level loc evd l in
+ (evd, l :: univs)) (evd, [])
+ l
+ in
+ if List.exists (fun l -> Univ.Level.is_prop l) l' then
+ user_err ~loc ~hdr:"pretype"
+ (str "Universe instances cannot contain Prop, polymorphic" ++
+ str " universe instances must be greater or equal to Set.");
+ evd, Some (Univ.Instance.of_array (Array.of_list (List.rev l')))
let pretype_global loc rigid env evd gr us =
let evd, instance =
@@ -501,21 +523,8 @@ let pretype_global loc rigid env evd gr us =
| None -> evd, None
| Some l ->
let _, ctx = Universes.unsafe_constr_of_global gr in
- let arr = Univ.Instance.to_array (Univ.UContext.instance ctx) in
- let len = Array.length arr in
- if len != List.length l then
- user_err ~loc ~hdr:"pretype"
- (str "Universe instance should have length " ++ int len)
- else
- let evd, l' = List.fold_left (fun (evd, univs) l ->
- let evd, l = interp_universe_level_name loc evd l in
- (evd, l :: univs)) (evd, []) l
- in
- if List.exists (fun l -> Univ.Level.is_prop l) l' then
- user_err ~loc ~hdr:"pretype"
- (str "Universe instances cannot contain Prop, polymorphic" ++
- str " universe instances must be greater or equal to Set.");
- evd, Some (Univ.Instance.of_array (Array.of_list (List.rev l')))
+ let len = Univ.UContext.size ctx in
+ interp_instance loc evd ~len l
in
let (sigma, c) = Evd.fresh_global ~loc ~rigid ?names:instance env.ExtraEnv.env evd gr in
(sigma, EConstr.of_constr c)
diff --git a/pretyping/program.ml b/pretyping/program.ml
index caa5a5c8a6..42acc5705b 100644
--- a/pretyping/program.ml
+++ b/pretyping/program.ml
@@ -10,7 +10,6 @@ open Pp
open CErrors
open Util
open Names
-open Term
let make_dir l = DirPath.make (List.rev_map Id.of_string l)
diff --git a/pretyping/reductionops.ml b/pretyping/reductionops.ml
index 2703205386..52f424f751 100644
--- a/pretyping/reductionops.ml
+++ b/pretyping/reductionops.ml
@@ -239,6 +239,9 @@ sig
| Shift of int
| Update of 'a
and 'a t = 'a member list
+
+ exception IncompatibleFold2
+
val pr : ('a -> Pp.std_ppcmds) -> 'a t -> Pp.std_ppcmds
val empty : 'a t
val is_empty : 'a t -> bool
@@ -413,6 +416,7 @@ struct
| (_,_) -> false in
compare_rec 0 stk1 stk2
+ exception IncompatibleFold2
let fold2 f o sk1 sk2 =
let rec aux o lft1 sk1 lft2 sk2 =
let fold_array =
@@ -442,7 +446,7 @@ struct
aux o lft1 (List.rev params1) lft2 (List.rev params2)
in aux o' lft1' q1 lft2' q2
| (((Update _|App _|Case _|Proj _|Fix _| Cst _) :: _|[]), _) ->
- raise (Invalid_argument "Reductionops.Stack.fold2")
+ raise IncompatibleFold2
in aux o 0 (List.rev sk1) 0 (List.rev sk2)
let rec map f x = List.map (function
@@ -1117,7 +1121,9 @@ let local_whd_state_gen flags sigma =
whrec
let raw_whd_state_gen flags env =
- let f sigma s = fst (whd_state_gen (get_refolding_in_reduction ()) false flags env sigma s) in
+ let f sigma s = fst (whd_state_gen ~refold:(get_refolding_in_reduction ())
+ ~tactic_mode:false
+ flags env sigma s) in
f
let stack_red_of_state_red f =
@@ -1127,7 +1133,7 @@ let stack_red_of_state_red f =
(* Drops the Cst_stack *)
let iterate_whd_gen refold flags env sigma s =
let rec aux t =
- let (hd,sk),_ = whd_state_gen refold false flags env sigma (t,Stack.empty) in
+ let (hd,sk),_ = whd_state_gen ~refold ~tactic_mode:false flags env sigma (t,Stack.empty) in
let whd_sk = Stack.map aux sk in
Stack.zip sigma ~refold (hd,whd_sk)
in aux s
diff --git a/pretyping/reductionops.mli b/pretyping/reductionops.mli
index 752c30a8ac..af80481569 100644
--- a/pretyping/reductionops.mli
+++ b/pretyping/reductionops.mli
@@ -81,8 +81,11 @@ module Stack : sig
val decomp_node_last : 'a app_node -> 'a t -> ('a * 'a t)
val compare_shape : 'a t -> 'a t -> bool
+
+ exception IncompatibleFold2
(** [fold2 f x sk1 sk2] folds [f] on any pair of term in [(sk1,sk2)].
- @return the result and the lifts to apply on the terms *)
+ @return the result and the lifts to apply on the terms
+ @raise IncompatibleFold2 when [sk1] and [sk2] have incompatible shapes *)
val fold2 : ('a -> constr -> constr -> 'a) -> 'a ->
constr t -> constr t -> 'a * int * int
val map : ('a -> 'a) -> 'a t -> 'a t
diff --git a/pretyping/tacred.mli b/pretyping/tacred.mli
index 76d0bc241f..c31212e26a 100644
--- a/pretyping/tacred.mli
+++ b/pretyping/tacred.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open Environ
open Evd
open EConstr
diff --git a/pretyping/typeclasses_errors.ml b/pretyping/typeclasses_errors.ml
index 2db0e9e881..754dacd193 100644
--- a/pretyping/typeclasses_errors.ml
+++ b/pretyping/typeclasses_errors.ml
@@ -8,7 +8,6 @@
(*i*)
open Names
-open Term
open EConstr
open Environ
open Constrexpr
diff --git a/pretyping/typeclasses_errors.mli b/pretyping/typeclasses_errors.mli
index 9bd430e4d6..558575ccce 100644
--- a/pretyping/typeclasses_errors.mli
+++ b/pretyping/typeclasses_errors.mli
@@ -8,7 +8,6 @@
open Loc
open Names
-open Term
open EConstr
open Environ
open Constrexpr
diff --git a/pretyping/typing.ml b/pretyping/typing.ml
index c2a030bcd2..00535adb7d 100644
--- a/pretyping/typing.ml
+++ b/pretyping/typing.ml
@@ -313,14 +313,13 @@ let rec execute env evdref cstr =
let j =
match EConstr.kind !evdref f with
| Ind (ind, u) when EInstance.is_empty u && Environ.template_polymorphic_ind ind env ->
- (* Sort-polymorphism of inductive types *)
make_judge f
(inductive_type_knowing_parameters env !evdref (ind, u) jl)
| Const (cst, u) when EInstance.is_empty u && Environ.template_polymorphic_constant cst env ->
- (* Sort-polymorphism of inductive types *)
make_judge f
(constant_type_knowing_parameters env !evdref (cst, u) jl)
| _ ->
+ (* No template polymorphism *)
execute env evdref f
in
e_judge_of_apply env evdref j jl
diff --git a/pretyping/unification.ml b/pretyping/unification.ml
index 532cc8baa5..661c1d8657 100644
--- a/pretyping/unification.ml
+++ b/pretyping/unification.ml
@@ -1095,7 +1095,7 @@ let rec unify_0_with_initial_metas (sigma,ms,es as subst : subst0) conv_at_top e
let app = mkApp (c, Array.rev_of_list ks) in
(* let substn = unirec_rec curenvnb pb b false substn t cN in *)
unirec_rec curenvnb pb opt' substn c1 app
- with Invalid_argument "Reductionops.Stack.fold2" ->
+ with Reductionops.Stack.IncompatibleFold2 ->
error_cannot_unify (fst curenvnb) sigma (cM,cN)
else error_cannot_unify (fst curenvnb) sigma (cM,cN)
in
@@ -1535,9 +1535,6 @@ let indirectly_dependent sigma c d decls =
way to see that the second hypothesis depends indirectly over 2 *)
List.exists (fun d' -> dependent_in_decl sigma (EConstr.mkVar (NamedDecl.get_id d')) d) decls
-let indirect_dependency sigma d decls =
- decls |> List.filter (fun d' -> dependent_in_decl sigma (EConstr.mkVar (NamedDecl.get_id d')) d) |> List.hd |> NamedDecl.get_id
-
let finish_evar_resolution ?(flags=Pretyping.all_and_fail_flags) env current_sigma (pending,c) =
let current_sigma = Sigma.to_evar_map current_sigma in
let sigma = Pretyping.solve_remaining_evars flags env current_sigma pending in
diff --git a/printing/ppconstr.ml b/printing/ppconstr.ml
index 38eeda9b96..b546c39aec 100644
--- a/printing/ppconstr.ml
+++ b/printing/ppconstr.ml
@@ -151,8 +151,8 @@ let tag_var = tag Tag.variable
let pr_univ l =
match l with
- | [_,x] -> str x
- | l -> str"max(" ++ prlist_with_sep (fun () -> str",") (fun x -> str (snd x)) l ++ str")"
+ | [_,x] -> pr_name x
+ | l -> str"max(" ++ prlist_with_sep (fun () -> str",") (fun x -> pr_name (snd x)) l ++ str")"
let pr_univ_annot pr x = str "@{" ++ pr x ++ str "}"
@@ -166,7 +166,7 @@ let tag_var = tag Tag.variable
| GProp -> tag_type (str "Prop")
| GSet -> tag_type (str "Set")
| GType None -> tag_type (str "Type")
- | GType (Some (_, u)) -> tag_type (str u)
+ | GType (Some (_, u)) -> tag_type (pr_name u)
let pr_qualid sp =
let (sl, id) = repr_qualid sp in
@@ -191,7 +191,7 @@ let tag_var = tag Tag.variable
tag_type (str "Set")
| GType u ->
(match u with
- | Some (_,u) -> str u
+ | Some (_,u) -> pr_name u
| None -> tag_type (str "Type"))
let pr_universe_instance l =
@@ -212,10 +212,6 @@ let tag_var = tag Tag.variable
| Some (_,ExplByName id) ->
str "(" ++ pr_id id ++ str ":=" ++ pr ltop a ++ str ")"
- let pr_opt_type pr = function
- | CHole (_,_,Misctypes.IntroAnonymous,_) -> mt ()
- | t -> cut () ++ str ":" ++ pr t
-
let pr_opt_type_spc pr = function
| CHole (_,_,Misctypes.IntroAnonymous,_) -> mt ()
| t -> str " :" ++ pr_sep_com (fun()->brk(1,2)) (pr ltop) t
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index cfc2e48d11..3e41439c8c 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -107,7 +107,7 @@ open Decl_kinds
| SearchString (s,sc) -> qs s ++ pr_opt (fun sc -> str "%" ++ str sc) sc
let pr_search a gopt b pr_p =
- pr_opt (fun g -> int g ++ str ":"++ spc()) gopt
+ pr_opt (fun g -> Proof_global.pr_goal_selector g ++ str ":"++ spc()) gopt
++
match a with
| SearchHead c -> keyword "SearchHead" ++ spc() ++ pr_p c ++ pr_in_out_modules b
@@ -386,19 +386,14 @@ open Decl_kinds
++ pr_opt (fun def -> str":=" ++ brk(1,2) ++ pr_pure_lconstr def) def
++ prlist (pr_decl_notation pr_constr) ntn
- let pr_statement head (idpl,(bl,c,guard)) =
+ let pr_statement head (idpl,(bl,c)) =
assert (not (Option.is_empty idpl));
let id, pl = Option.get idpl in
hov 2
(head ++ spc() ++ pr_lident id ++ pr_univs pl ++ spc() ++
(match bl with [] -> mt() | _ -> pr_binders bl ++ spc()) ++
- pr_opt (pr_guard_annot pr_lconstr_expr bl) guard ++
str":" ++ pr_spc_lconstr c)
- let pr_priority = function
- | None -> mt ()
- | Some i -> spc () ++ str "|" ++ spc () ++ int i
-
(**************************************)
(* Pretty printer for vernac commands *)
(**************************************)
@@ -497,7 +492,7 @@ open Decl_kinds
| PrintVisibility s ->
keyword "Print Visibility" ++ pr_opt str s
| PrintAbout (qid,gopt) ->
- pr_opt (fun g -> int g ++ str ":"++ spc()) gopt
+ pr_opt (fun g -> Proof_global.pr_goal_selector g ++ str ":"++ spc()) gopt
++ keyword "About" ++ spc() ++ pr_smart_global qid
| PrintImplicit qid ->
keyword "Print Implicit" ++ spc() ++ pr_smart_global qid
@@ -619,8 +614,6 @@ open Decl_kinds
return (keyword "Timeout " ++ int n ++ spc() ++ pr_vernac_body v)
| VernacFail v ->
return (keyword "Fail" ++ spc() ++ pr_vernac_body v)
- | VernacError _ ->
- return (keyword "No-parsing-rule for VernacError")
(* Syntax *)
| VernacOpenCloseScope (_,(opening,sc)) ->
@@ -1140,7 +1133,8 @@ open Decl_kinds
spc() ++ keyword "in" ++ spc () ++ pr_lconstr c)
| None -> hov 2 (keyword "Check" ++ spc() ++ pr_lconstr c)
in
- let pr_i = match io with None -> mt () | Some i -> int i ++ str ": " in
+ let pr_i = match io with None -> mt ()
+ | Some i -> Proof_global.pr_goal_selector i ++ str ": " in
return (pr_i ++ pr_mayeval r c)
| VernacGlobalCheck c ->
return (hov 2 (keyword "Type" ++ pr_constrarg c))
@@ -1222,7 +1216,7 @@ open Decl_kinds
| Egramml.GramTerminal s :: rl, cl -> str s :: aux rl cl
| [], [] -> []
| _ -> assert false in
- hov 1 (pr_sequence (fun x -> x) (aux rl cl))
+ hov 1 (pr_sequence identity (aux rl cl))
with Not_found ->
hov 1 (str "TODO(" ++ str (fst s) ++ spc () ++ prlist_with_sep sep pr_arg cl ++ str ")")
diff --git a/printing/prettyp.ml b/printing/prettyp.ml
index aa422e36af..381af83c73 100644
--- a/printing/prettyp.ml
+++ b/printing/prettyp.ml
@@ -29,7 +29,7 @@ open Printer
open Printmod
open Context.Rel.Declaration
-module RelDecl = Context.Rel.Declaration
+(* module RelDecl = Context.Rel.Declaration *)
module NamedDecl = Context.Named.Declaration
type object_pr = {
diff --git a/printing/prettyp.mli b/printing/prettyp.mli
index 38e1110344..6841781ccd 100644
--- a/printing/prettyp.mli
+++ b/printing/prettyp.mli
@@ -8,7 +8,6 @@
open Pp
open Names
-open Term
open Environ
open Reductionops
open Libnames
diff --git a/printing/printer.ml b/printing/printer.ml
index 239e1d7ebe..91a7d22899 100644
--- a/printing/printer.ml
+++ b/printing/printer.ml
@@ -28,12 +28,53 @@ module CompactedDecl = Context.Compacted.Declaration
let emacs_str s =
if !Flags.print_emacs then s else ""
-let delayed_emacs_cmd s =
- if !Flags.print_emacs then s () else str ""
let get_current_context () =
Pfedit.get_current_context ()
+let enable_unfocused_goal_printing = ref false
+let enable_goal_tags_printing = ref false
+let enable_goal_names_printing = ref false
+
+let should_tag() = !enable_goal_tags_printing
+let should_unfoc() = !enable_unfocused_goal_printing
+let should_gname() = !enable_goal_names_printing
+
+
+let _ =
+ let open Goptions in
+ declare_bool_option
+ { optsync = true;
+ optdepr = false;
+ optname = "printing of unfocused goal";
+ optkey = ["Printing";"Unfocused"];
+ optread = (fun () -> !enable_unfocused_goal_printing);
+ optwrite = (fun b -> enable_unfocused_goal_printing:=b) }
+
+(* This is set on by proofgeneral proof-tree mode. But may be used for
+ other purposes *)
+let _ =
+ let open Goptions in
+ declare_bool_option
+ { optsync = true;
+ optdepr = false;
+ optname = "printing of goal tags";
+ optkey = ["Printing";"Goal";"Tags"];
+ optread = (fun () -> !enable_goal_tags_printing);
+ optwrite = (fun b -> enable_goal_tags_printing:=b) }
+
+
+let _ =
+ let open Goptions in
+ declare_bool_option
+ { optsync = true;
+ optdepr = false;
+ optname = "printing of goal names";
+ optkey = ["Printing";"Goal";"Names"];
+ optread = (fun () -> !enable_goal_names_printing);
+ optwrite = (fun b -> enable_goal_names_printing:=b) }
+
+
(**********************************************************************)
(** Terms *)
@@ -370,13 +411,21 @@ let pr_context_limit_compact ?n env sigma =
env ~init:(mt ()) in
(sign_env ++ db_env)
-(* compact printing an env (variables and de Bruijn). Separator: three
- spaces between simple hyps, and newline otherwise *)
-let pr_context_unlimited_compact env sigma =
- pr_context_limit_compact env sigma
+(* The number of printed hypothesis in a goal *)
+(* If [None], no limit *)
+let print_hyps_limit = ref (None : int option)
-let pr_context_of env sigma =
- match Flags.print_hyps_limit () with
+let _ =
+ let open Goptions in
+ declare_int_option
+ { optsync = false;
+ optdepr = false;
+ optname = "the hypotheses limit";
+ optkey = ["Hyps";"Limit"];
+ optread = (fun () -> !print_hyps_limit);
+ optwrite = (fun x -> print_hyps_limit := x) }
+
+let pr_context_of env sigma = match !print_hyps_limit with
| None -> hv 0 (pr_context_limit_compact env sigma)
| Some n -> hv 0 (pr_context_limit_compact ~n env sigma)
@@ -411,23 +460,25 @@ let default_pr_goal gs =
(* display a goal tag *)
let pr_goal_tag g =
let s = " (ID " ^ Goal.uid g ^ ")" in
- str (emacs_str s)
-
-let display_name = false
+ str s
(* display a goal name *)
let pr_goal_name sigma g =
- if display_name then str " " ++ Pp.surround (pr_existential_key sigma g)
+ if should_gname() then str " " ++ Pp.surround (pr_existential_key sigma g)
else mt ()
+let pr_goal_header nme sigma g =
+ let (g,sigma) = Goal.V82.nf_evar sigma g in
+ str "subgoal " ++ nme ++ (if should_tag() then pr_goal_tag g else str"")
+ ++ (if should_gname() then str " " ++ Pp.surround (pr_existential_key sigma g) else mt ())
+
(* display the conclusion of a goal *)
let pr_concl n sigma g =
let (g,sigma) = Goal.V82.nf_evar sigma g in
let env = Goal.V82.env sigma g in
let pc = pr_goal_concl_style_env env sigma (Goal.V82.concl sigma g) in
- str (emacs_str "") ++
- str "subgoal " ++ int n ++ pr_goal_tag g ++ pr_goal_name sigma g ++
- str " is:" ++ cut () ++ str" " ++ pc
+ let header = pr_goal_header (int n) sigma g in
+ header ++ str " is:" ++ cut () ++ str" " ++ pc
(* display evar type: a context and a type *)
let pr_evgl_sign sigma evi =
@@ -483,8 +534,8 @@ let pr_ne_evar_set hd tl sigma l =
let pr_selected_subgoal name sigma g =
let pg = default_pr_goal { sigma=sigma ; it=g; } in
- v 0 (str "subgoal " ++ name ++ pr_goal_tag g ++ pr_goal_name sigma g
- ++ str " is:" ++ cut () ++ pg)
+ let header = pr_goal_header name sigma g in
+ v 0 (header ++ str " is:" ++ cut () ++ pg)
let default_pr_subgoal n sigma =
let rec prrec p = function
@@ -577,27 +628,27 @@ let print_dependent_evars gl sigma seeds =
end i (str ",")
end evars (str "")
in
- fnl () ++
- str "(dependent evars:" ++ evars ++ str ")" ++ fnl ()
- else
- fnl () ++
- str "(dependent evars: (printing disabled) )" ++ fnl ()
+ cut () ++ cut () ++
+ str "(dependent evars:" ++ evars ++ str ")"
+ else if !Flags.print_emacs then
+ (* IDEs prefer something dummy instead of nothing *)
+ cut () ++ cut () ++ str "(dependent evars: (printing disabled) )"
+ else mt ()
in
- constraints ++ delayed_emacs_cmd evars
+ constraints ++ evars ()
(* Print open subgoals. Checks for uninstantiated existential variables *)
(* spiwack: [seeds] is for printing dependent evars in emacs mode. *)
(* spiwack: [pr_first] is true when the first goal must be singled out
and printed in its entirety. *)
-(* courtieu: in emacs mode, even less cases where the first goal is printed
- in its entirety *)
-let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals =
+let default_pr_subgoals ?(pr_first=true)
+ close_cmd sigma seeds shelf stack unfocused goals =
(** Printing functions for the extra informations. *)
let rec print_stack a = function
| [] -> Pp.int a
| b::l -> Pp.int a ++ str"-" ++ print_stack b l
in
- let print_unfocused l =
+ let print_unfocused_nums l =
match l with
| [] -> None
| a::l -> Some (str"unfocused: " ++ print_stack a l)
@@ -617,7 +668,7 @@ let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals
| [] -> Pp.mt ()
| a::l -> Pp.spc () ++ str"(" ++ print_comma_separated_list a l ++ str")"
in
- let extra = Option.List.flatten [ print_unfocused stack ; print_shelf shelf ] in
+ let extra = Option.List.flatten [ print_unfocused_nums stack ; print_shelf shelf ] in
let print_extra = print_extra_list extra in
let focused_if_needed =
let needed = not (CList.is_empty extra) && pr_first in
@@ -634,8 +685,9 @@ let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals
in
let print_multiple_goals g l =
if pr_first then
- default_pr_goal { it = g ; sigma = sigma; } ++ fnl () ++
- pr_rec 2 l
+ default_pr_goal { it = g ; sigma = sigma; }
+ ++ (if l=[] then mt () else cut ())
+ ++ pr_rec 2 l
else
pr_rec 1 (g::l)
in
@@ -650,32 +702,27 @@ let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals
begin
let exl = Evarutil.non_instantiated sigma in
if Evar.Map.is_empty exl then
- (str"No more subgoals."
- ++ print_dependent_evars None sigma seeds)
+ (str"No more subgoals." ++ print_dependent_evars None sigma seeds)
else
let pei = pr_evars_int sigma 1 exl in
- (str "No more subgoals, but there are non-instantiated existential variables:"
- ++ fnl () ++ (hov 0 pei)
- ++ print_dependent_evars None sigma seeds ++ fnl () ++
- str "You can use Grab Existential Variables.")
+ v 0 ((str "No more subgoals,"
+ ++ str " but there are non-instantiated existential variables:"
+ ++ cut () ++ (hov 0 pei)
+ ++ print_dependent_evars None sigma seeds
+ ++ cut () ++ str "You can use Grab Existential Variables."))
end
- | [g] when not !Flags.print_emacs && pr_first ->
- let pg = default_pr_goal { it = g ; sigma = sigma; } in
- v 0 (
- str "1" ++ focused_if_needed ++ str"subgoal" ++ print_extra
- ++ pr_goal_tag g ++ pr_goal_name sigma g ++ cut () ++ pg
- ++ print_dependent_evars (Some g) sigma seeds
- )
| g1::rest ->
let goals = print_multiple_goals g1 rest in
let ngoals = List.length rest+1 in
v 0 (
- int ngoals ++ focused_if_needed ++ str(String.plural ngoals "subgoal") ++
- print_extra ++
- str ((if display_name then (fun x -> x) else emacs_str) ", subgoal 1")
- ++ pr_goal_tag g1
- ++ pr_goal_name sigma g1 ++ cut ()
- ++ goals
+ int ngoals ++ focused_if_needed ++ str(String.plural ngoals "subgoal")
+ ++ print_extra
+ ++ str (if (should_gname()) then ", subgoal 1" else "")
+ ++ (if should_tag() then pr_goal_tag g1 else str"")
+ ++ pr_goal_name sigma g1 ++ cut () ++ goals
+ ++ (if unfocused=[] then str ""
+ else (cut() ++ cut() ++ str "*** Unfocused goals:" ++ cut()
+ ++ pr_rec (List.length rest + 2) unfocused))
++ print_dependent_evars (Some g1) sigma seeds
)
@@ -684,7 +731,7 @@ let default_pr_subgoals ?(pr_first=true) close_cmd sigma seeds shelf stack goals
type printer_pr = {
- pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list -> goal list -> std_ppcmds;
+ pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list -> goal list -> goal list -> std_ppcmds;
pr_subgoal : int -> evar_map -> goal list -> std_ppcmds;
pr_goal : goal sigma -> std_ppcmds;
}
@@ -718,16 +765,16 @@ let pr_open_subgoals ?(proof=Proof_global.give_me_the_proof ()) () =
begin match goals with
| [] -> let { Evd.it = bgoals ; sigma = bsigma } = Proof.V82.background_subgoals p in
begin match bgoals,shelf,given_up with
- | [] , [] , [] -> pr_subgoals None sigma seeds shelf stack goals
+ | [] , [] , [] -> pr_subgoals None sigma seeds shelf stack [] goals
| [] , [] , _ ->
Feedback.msg_info (str "No more subgoals, but there are some goals you gave up:");
fnl ()
- ++ pr_subgoals ~pr_first:false None bsigma seeds [] [] given_up
+ ++ pr_subgoals ~pr_first:false None bsigma seeds [] [] [] given_up
++ fnl () ++ str "You need to go back and solve them."
| [] , _ , _ ->
Feedback.msg_info (str "All the remaining goals are on the shelf.");
fnl ()
- ++ pr_subgoals ~pr_first:false None bsigma seeds [] [] shelf
+ ++ pr_subgoals ~pr_first:false None bsigma seeds [] [] [] shelf
| _ , _, _ ->
let end_cmd =
str "This subproof is complete, but there are some unfocused goals." ++
@@ -735,9 +782,13 @@ let pr_open_subgoals ?(proof=Proof_global.give_me_the_proof ()) () =
if Pp.ismt s then s else fnl () ++ s) ++
fnl ()
in
- pr_subgoals ~pr_first:false (Some end_cmd) bsigma seeds shelf [] bgoals
+ pr_subgoals ~pr_first:false (Some end_cmd) bsigma seeds shelf [] [] bgoals
end
- | _ -> pr_subgoals None sigma seeds shelf stack goals
+ | _ ->
+ let { Evd.it = bgoals ; sigma = bsigma } = Proof.V82.background_subgoals p in
+ let bgoals_focused, bgoals_unfocused = List.partition (fun x -> List.mem x goals) bgoals in
+ let unfocused_if_needed = if should_unfoc() then bgoals_unfocused else [] in
+ pr_subgoals ~pr_first:true None bsigma seeds shelf [] unfocused_if_needed bgoals_focused
end
let pr_nth_open_subgoal n =
diff --git a/printing/printer.mli b/printing/printer.mli
index 504392e35f..c282950545 100644
--- a/printing/printer.mli
+++ b/printing/printer.mli
@@ -18,6 +18,11 @@ open Glob_term
(** These are the entry points for printing terms, context, tac, ... *)
+
+val enable_unfocused_goal_printing: bool ref
+val enable_goal_tags_printing : bool ref
+val enable_goal_names_printing : bool ref
+
(** Terms *)
val pr_lconstr_env : env -> evar_map -> constr -> std_ppcmds
@@ -135,7 +140,19 @@ val pr_transparent_state : transparent_state -> std_ppcmds
(** Proofs *)
val pr_goal : goal sigma -> std_ppcmds
-val pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list -> goal list -> std_ppcmds
+
+(** [pr_subgoals ~pr_first pp sigma seeds shelf focus_stack unfocused goals]
+ prints the goals of the list [goals] followed by the goals in
+ [unfocused], in a short way (typically only the conclusion) except
+ for the first goal if [pr_first] is true. This function can be
+ replaced by another one by calling [set_printer_pr] (see below),
+ typically by plugin writers. The default printer prints only the
+ focused goals unless the conrresponding option
+ [enable_unfocused_goal_printing] is set. [seeds] is for printing
+ dependent evars (mainly for emacs proof tree mode). *)
+val pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list
+ -> goal list -> goal list -> std_ppcmds
+
val pr_subgoal : int -> evar_map -> goal list -> std_ppcmds
val pr_concl : int -> evar_map -> goal -> std_ppcmds
@@ -190,7 +207,7 @@ val pr_goal_by_id : Id.t -> std_ppcmds
val pr_goal_by_uid : string -> std_ppcmds
type printer_pr = {
- pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list -> goal list -> std_ppcmds;
+ pr_subgoals : ?pr_first:bool -> std_ppcmds option -> evar_map -> evar list -> Goal.goal list -> int list -> goal list -> goal list -> std_ppcmds;
pr_subgoal : int -> evar_map -> goal list -> std_ppcmds;
pr_goal : goal sigma -> std_ppcmds;
};;
diff --git a/proofs/clenv.ml b/proofs/clenv.ml
index f9ebc42330..605914a015 100644
--- a/proofs/clenv.ml
+++ b/proofs/clenv.ml
@@ -27,11 +27,6 @@ open Unification
open Misctypes
open Sigma.Notations
-(* Abbreviations *)
-
-let pf_env = Refiner.pf_env
-let pf_type_of gls c = Typing.unsafe_type_of (pf_env gls) gls.sigma c
-
(******************************************************************)
(* Clausal environments *)
diff --git a/proofs/clenvtac.mli b/proofs/clenvtac.mli
index 5b7164705a..26069207eb 100644
--- a/proofs/clenvtac.mli
+++ b/proofs/clenvtac.mli
@@ -8,7 +8,6 @@
(** Legacy components of the previous proof engine. *)
-open Term
open Clenv
open EConstr
open Unification
diff --git a/proofs/goal.ml b/proofs/goal.ml
index 9046f45341..fc8e635a07 100644
--- a/proofs/goal.ml
+++ b/proofs/goal.ml
@@ -8,7 +8,6 @@
open Util
open Pp
-open Term
open Sigma.Notations
module NamedDecl = Context.Named.Declaration
diff --git a/proofs/goal.mli b/proofs/goal.mli
index a2fa34c05e..ee2e736120 100644
--- a/proofs/goal.mli
+++ b/proofs/goal.mli
@@ -59,9 +59,6 @@ module V82 : sig
second goal *)
val partial_solution_to : Evd.evar_map -> goal -> goal -> EConstr.constr -> Evd.evar_map
- (* Principal part of the weak-progress tactical *)
- val weak_progress : goal list Evd.sigma -> goal Evd.sigma -> bool
-
(* Principal part of the progress tactical *)
val progress : goal list Evd.sigma -> goal Evd.sigma -> bool
diff --git a/proofs/logic.ml b/proofs/logic.ml
index e6024785db..54345abd97 100644
--- a/proofs/logic.ml
+++ b/proofs/logic.ml
@@ -97,11 +97,6 @@ let check_typability env sigma c =
(instead of iterating on the list of identifier to be removed, which
forces the user to give them in order). *)
-let clear_hyps env sigma ids sign cl =
- let evdref = ref (Evd.clear_metas sigma) in
- let (hyps,cl) = Evarutil.clear_hyps_in_evi env evdref sign cl ids in
- (hyps, cl, !evdref)
-
let clear_hyps2 env sigma ids sign t cl =
let evdref = ref (Evd.clear_metas sigma) in
let (hyps,t,cl) = Evarutil.clear_hyps2_in_evi env evdref sign t cl ids in
@@ -379,7 +374,7 @@ let rec mk_refgoals sigma goal goalacc conclty trm =
let (acc',hdty,sigma,applicand) =
if is_template_polymorphic env sigma (EConstr.of_constr f) then
let ty =
- (* Template sort-polymorphism of definition and inductive types *)
+ (* Template polymorphism of definitions and inductive types *)
let firstmeta = Array.findi (fun i x -> occur_meta sigma (EConstr.of_constr x)) l in
let args, _ = Option.cata (fun i -> CArray.chop i l) (l, [||]) firstmeta in
type_of_global_reference_knowing_parameters env sigma (EConstr.of_constr f) (Array.map EConstr.of_constr args)
diff --git a/proofs/pfedit.mli b/proofs/pfedit.mli
index f9fb0b76de..7622a87768 100644
--- a/proofs/pfedit.mli
+++ b/proofs/pfedit.mli
@@ -190,4 +190,4 @@ val declare_implicit_tactic : unit Proofview.tactic -> unit
val clear_implicit_tactic : unit -> unit
(* Raise Exit if cannot solve *)
-val solve_by_implicit_tactic : unit -> (env -> Evd.evar_map -> Evd.evar -> Evd.evar_map * EConstr.constr) option
+val solve_by_implicit_tactic : unit -> Pretyping.inference_hook option
diff --git a/proofs/proof_global.ml b/proofs/proof_global.ml
index e4cba6f07d..5f4a7766f3 100644
--- a/proofs/proof_global.ml
+++ b/proofs/proof_global.ml
@@ -88,7 +88,7 @@ type proof_terminator = proof_ending -> unit
type closed_proof = proof_object * proof_terminator
type pstate = {
- pid : Id.t;
+ pid : Id.t; (* the name of the theorem whose proof is being constructed *)
terminator : proof_terminator CEphemeron.key;
endline_tactic : Genarg.glob_generic_argument option;
section_vars : Context.Named.t option;
@@ -671,16 +671,18 @@ let _ =
let default_goal_selector = ref (Vernacexpr.SelectNth 1)
let get_default_goal_selector () = !default_goal_selector
-let print_range_selector (i, j) =
- if i = j then string_of_int i
- else string_of_int i ^ "-" ^ string_of_int j
+let pr_range_selector (i, j) =
+ if i = j then int i
+ else int i ++ str "-" ++ int j
-let print_goal_selector = function
- | Vernacexpr.SelectAll -> "all"
- | Vernacexpr.SelectNth i -> string_of_int i
- | Vernacexpr.SelectList l -> "[" ^
- String.concat ", " (List.map print_range_selector l) ^ "]"
- | Vernacexpr.SelectId id -> Id.to_string id
+let pr_goal_selector = function
+ | Vernacexpr.SelectAll -> str "all"
+ | Vernacexpr.SelectNth i -> int i
+ | Vernacexpr.SelectList l ->
+ str "["
+ ++ prlist_with_sep pr_comma pr_range_selector l
+ ++ str "]"
+ | Vernacexpr.SelectId id -> Id.print id
let parse_goal_selector = function
| "all" -> Vernacexpr.SelectAll
@@ -699,7 +701,10 @@ let _ =
optdepr = false;
optname = "default goal selector" ;
optkey = ["Default";"Goal";"Selector"] ;
- optread = begin fun () -> print_goal_selector !default_goal_selector end;
+ optread = begin fun () ->
+ string_of_ppcmds
+ (pr_goal_selector !default_goal_selector)
+ end;
optwrite = begin fun n ->
default_goal_selector := parse_goal_selector n
end
diff --git a/proofs/proof_global.mli b/proofs/proof_global.mli
index 3b2cc6b23b..6bb6f5e2cb 100644
--- a/proofs/proof_global.mli
+++ b/proofs/proof_global.mli
@@ -198,6 +198,7 @@ end
(* *)
(**********************************************************)
+val pr_goal_selector : Vernacexpr.goal_selector -> Pp.std_ppcmds
val get_default_goal_selector : unit -> Vernacexpr.goal_selector
module V82 : sig
diff --git a/proofs/proof_type.mli b/proofs/proof_type.mli
index 03bc5e4710..e59db9e427 100644
--- a/proofs/proof_type.mli
+++ b/proofs/proof_type.mli
@@ -11,9 +11,6 @@
open Evd
open Names
open Term
-open Glob_term
-open Nametab
-open Misctypes
(** This module defines the structure of proof tree and the tactic type. So, it
is used by [Proof_tree] and [Refiner] *)
diff --git a/proofs/redexpr.ml b/proofs/redexpr.ml
index 0fe5c73f15..cb35384227 100644
--- a/proofs/redexpr.ml
+++ b/proofs/redexpr.ml
@@ -43,7 +43,7 @@ let cbv_native env sigma c =
let whd_cbn flags env sigma t =
let (state,_) =
- (whd_state_gen true true flags env sigma (t,Reductionops.Stack.empty))
+ (whd_state_gen ~refold:true ~tactic_mode:true flags env sigma (t,Reductionops.Stack.empty))
in
Reductionops.Stack.zip ~refold:true sigma state
diff --git a/proofs/refiner.ml b/proofs/refiner.ml
index 5c7659ac0e..259e96a276 100644
--- a/proofs/refiner.ml
+++ b/proofs/refiner.ml
@@ -10,7 +10,6 @@ open Pp
open CErrors
open Util
open Evd
-open Environ
open Proof_type
open Logic
@@ -162,31 +161,11 @@ let tclMAP tacfun l =
(* PROGRESS tac ptree applies tac to the goal ptree and fails if tac leaves
the goal unchanged *)
-let tclWEAK_PROGRESS tac ptree =
- let rslt = tac ptree in
- if Goal.V82.weak_progress rslt ptree then rslt
- else user_err ~hdr:"Refiner.WEAK_PROGRESS" (str"Failed to progress.")
-
-(* PROGRESS tac ptree applies tac to the goal ptree and fails if tac leaves
-the goal unchanged *)
let tclPROGRESS tac ptree =
let rslt = tac ptree in
if Goal.V82.progress rslt ptree then rslt
else user_err ~hdr:"Refiner.PROGRESS" (str"Failed to progress.")
-(* Same as tclWEAK_PROGRESS but fails also if tactics generates several goals,
- one of them being identical to the original goal *)
-let tclNOTSAMEGOAL (tac : tactic) goal =
- let same_goal gls1 evd2 gl2 =
- Goal.V82.same_goal gls1.sigma gls1.it evd2 gl2
- in
- let rslt = tac goal in
- let {it=gls;sigma=sigma} = rslt in
- if List.exists (same_goal goal sigma) gls
- then user_err ~hdr:"Refiner.tclNOTSAMEGOAL"
- (str"Tactic generated a subgoal identical to the original goal.")
- else rslt
-
(* Execute tac, show the names of new hypothesis names created by tac
in the "as" format and then forget everything. From the logical
point of view [tclSHOWHYPS tac] is therefore equivalent to idtac,
diff --git a/proofs/refiner.mli b/proofs/refiner.mli
index 56f5facf89..e179589df2 100644
--- a/proofs/refiner.mli
+++ b/proofs/refiner.mli
@@ -119,10 +119,8 @@ val tclAT_LEAST_ONCE : tactic -> tactic
val tclFAIL : int -> Pp.std_ppcmds -> tactic
val tclFAIL_lazy : int -> Pp.std_ppcmds Lazy.t -> tactic
val tclDO : int -> tactic -> tactic
-val tclWEAK_PROGRESS : tactic -> tactic
val tclPROGRESS : tactic -> tactic
val tclSHOWHYPS : tactic -> tactic
-val tclNOTSAMEGOAL : tactic -> tactic
(** [tclIFTHENELSE tac1 tac2 tac3 gls] first applies [tac1] to [gls] then,
if it succeeds, applies [tac2] to the resulting subgoals,
diff --git a/proofs/tacmach.ml b/proofs/tacmach.ml
index b55f8ef113..97c5cda770 100644
--- a/proofs/tacmach.ml
+++ b/proofs/tacmach.ml
@@ -179,9 +179,6 @@ module New = struct
let pf_unsafe_type_of gl t =
pf_apply unsafe_type_of gl t
- let pf_get_type_of gl t =
- pf_apply (Retyping.get_type_of ~lax:true) gl t
-
let pf_type_of gl t =
pf_apply type_of gl t
diff --git a/proofs/tacmach.mli b/proofs/tacmach.mli
index 627a8e0e7e..e6e60e27f7 100644
--- a/proofs/tacmach.mli
+++ b/proofs/tacmach.mli
@@ -15,7 +15,6 @@ open Proof_type
open Redexpr
open Pattern
open Locus
-open Misctypes
(** Operations for handling terms under a local typing context. *)
diff --git a/stm/asyncTaskQueue.ml b/stm/asyncTaskQueue.ml
index 1254919880..3fa1732a4d 100644
--- a/stm/asyncTaskQueue.ml
+++ b/stm/asyncTaskQueue.ml
@@ -105,7 +105,7 @@ module Make(T : Task) = struct
let report_status ?(id = !Flags.async_proofs_worker_id) s =
let open Feedback in
- feedback ~id:(State Stateid.initial) (WorkerStatus(id, s))
+ feedback ~id:Stateid.initial (WorkerStatus(id, s))
module Worker = Spawn.Sync(struct end)
@@ -308,7 +308,7 @@ module Make(T : Task) = struct
(* We pass feedback to master *)
let slave_feeder oc fb =
Marshal.to_channel oc (RespFeedback (debug_with_pid fb)) []; flush oc in
- Feedback.add_feeder (fun x -> slave_feeder (Option.get !slave_oc) x);
+ ignore (Feedback.add_feeder (fun x -> slave_feeder (Option.get !slave_oc) x));
(* We ask master to allocate universe identifiers *)
Universes.set_remote_new_univ_level (bufferize (fun () ->
marshal_response (Option.get !slave_oc) RespGetCounterNewUnivLevel;
diff --git a/stm/stm.ml b/stm/stm.ml
index 2b6ee55111..84c8aa9a99 100644
--- a/stm/stm.ml
+++ b/stm/stm.ml
@@ -6,34 +6,32 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
+(* enable in case of stm problems *)
+let stm_debug = false
+
let stm_pr_err s = Printf.eprintf "%s] %s\n" (System.process_id ()) s; flush stderr
let stm_pp_err pp = Format.eprintf "%s] @[%a@]\n" (System.process_id ()) Pp.pp_with pp; flush stderr
-let stm_prerr_endline s = if false then begin stm_pr_err (s ()) end else ()
-let stm_prerr_debug s = if !Flags.debug then begin stm_pr_err (s ()) end else ()
+let stm_prerr_endline s = if stm_debug then begin stm_pr_err (s ()) end else ()
+let stm_pperr_endline s = if stm_debug then begin stm_pp_err (s ()) end else ()
-let stm_pperr_endline s = if false then begin stm_pp_err (s ()) end else ()
+let stm_prerr_debug s = if !Flags.debug then begin stm_pr_err (s ()) end else ()
-open Vernacexpr
-open CErrors
open Pp
-open Names
-open Util
-open Ppvernac
-open Vernac_classifier
+open CErrors
open Feedback
+open Vernacexpr
+open Vernac_classifier
let execution_error state_id loc msg =
- feedback ~id:(State state_id)
+ feedback ~id:state_id
(Message (Error, Some loc, msg))
module Hooks = struct
-let process_error, process_error_hook = Hook.make ()
-
let state_computed, state_computed_hook = Hook.make
~default:(fun state_id ~in_cache ->
- feedback ~id:(State state_id) Processed) ()
+ feedback ~id:state_id Processed) ()
let state_ready, state_ready_hook = Hook.make
~default:(fun state_id -> ()) ()
@@ -45,16 +43,9 @@ let forward_feedback, forward_feedback_hook =
try Mutex.lock m; feedback ~id:id ~route contents; Mutex.unlock m
with e -> Mutex.unlock m; raise e) ()
-let parse_error, parse_error_hook = Hook.make
- ~default:(fun id loc msg ->
- feedback ~id (Message(Error, Some loc, msg))) ()
-
let unreachable_state, unreachable_state_hook = Hook.make
~default:(fun _ _ -> ()) ()
-let tactic_being_run, tactic_being_run_hook = Hook.make
- ~default:(fun _ -> ()) ()
-
include Hook
(* enables: Hooks.(call foo args) *)
@@ -66,7 +57,7 @@ let call_process_error_once =
match Exninfo.get info processed with
| Some _ -> ei
| None ->
- let e, info = call process_error ei in
+ let e, info = ExplainErr.process_vernac_interp_error ei in
let info = Exninfo.add info processed () in
e, info
@@ -86,7 +77,7 @@ type aast = {
strlen : int;
mutable expr : vernac_expr; (* mutable: Proof using hinted by aux file *)
}
-let pr_ast { expr; indentation } = int indentation ++ str " " ++ pr_vernac expr
+let pr_ast { expr; indentation } = Pp.(int indentation ++ str " " ++ Ppvernac.pr_vernac expr)
let default_proof_mode () = Proof_global.get_default_proof_mode_name ()
@@ -102,43 +93,6 @@ let may_pierce_opaque = function
| { expr = VernacExtend (("ExtractionInductive",_), _) } -> true
| _ -> false
-(* Wrapper for Vernac.parse_sentence to set the feedback id *)
-let indentation_of_string s =
- let len = String.length s in
- let rec aux n i precise =
- if i >= len then 0, precise, len
- else
- match s.[i] with
- | ' ' | '\t' -> aux (succ n) (succ i) precise
- | '\n' | '\r' -> aux 0 (succ i) true
- | _ -> n, precise, len in
- aux 0 0 false
-
-let vernac_parse ?(indlen_prev=fun() -> 0) ?newtip ?route eid s =
- let feedback_id =
- if Option.is_empty newtip then Edit eid
- else State (Option.get newtip) in
- let indentation, precise, strlen = indentation_of_string s in
- let indentation =
- if precise then indentation else indlen_prev () + indentation in
- set_id_for_feedback ?route feedback_id;
- let pa = Pcoq.Gram.parsable (Stream.of_string s) in
- Flags.with_option Flags.we_are_parsing (fun () ->
- try
- match Pcoq.Gram.entry_parse Pcoq.main_entry pa with
- | None -> raise (Invalid_argument "vernac_parse")
- | Some (loc, ast) -> indentation, strlen, loc, ast
- with e when CErrors.noncritical e ->
- let (e, info) = CErrors.push e in
- let loc = Option.default Loc.ghost (Loc.get_loc info) in
- Hooks.(call parse_error feedback_id loc (iprint (e, info)));
- iraise (e, info))
- ()
-
-let pr_open_cur_subgoals () =
- try Printer.pr_open_subgoals ()
- with Proof_global.NoCurrentProof -> Pp.str ""
-
let update_global_env () =
if Proof_global.there_are_pending_proofs () then
Proof_global.update_global_env ()
@@ -158,13 +112,13 @@ type cmd_t = {
ctac : bool; (* is a tactic *)
ceff : bool; (* is a side-effecting command in the middle of a proof *)
cast : aast;
- cids : Id.t list;
+ cids : Names.Id.t list;
cblock : proof_block_name option;
cqueue : [ `MainQueue
| `TacQueue of solving_tac * anon_abstracting_tac * cancel_switch
| `QueryQueue of cancel_switch
| `SkipQueue ] }
-type fork_t = aast * Vcs_.Branch.t * Vernacexpr.opacity_guarantee * Id.t list
+type fork_t = aast * Vcs_.Branch.t * Vernacexpr.opacity_guarantee * Names.Id.t list
type qed_t = {
qast : aast;
keep : vernac_qed_type;
@@ -253,7 +207,7 @@ end = struct (* {{{ *)
let proof_nesting vcs =
List.fold_left max 0
- (List.map_filter
+ (CList.map_filter
(function
| { Vcs_.kind = `Proof (_,n) } -> Some n
| { Vcs_.kind = `Edit _ } -> Some 1
@@ -369,6 +323,15 @@ end = struct (* {{{ *)
open Printf
let print_dag vcs () =
+
+ (* Due to threading, be wary that this will be called from the
+ toplevel with we_are_parsing set to true, as indeed, the
+ toplevel is waiting for input . What a race! XD
+
+ In case you are hitting the race enable stm_debug.
+ *)
+ if stm_debug then Flags.we_are_parsing := false;
+
let fname =
"stm_" ^ Str.global_replace (Str.regexp " ") "_" (System.process_id ()) in
let string_of_transaction = function
@@ -380,7 +343,7 @@ end = struct (* {{{ *)
| Sideff None -> "EnvChange"
| Noop -> " "
| Alias (id,_) -> sprintf "Alias(%s)" (Stateid.to_string id)
- | Qed { qast } -> string_of_ppcmds (pr_ast qast) in
+ | Qed { qast } -> Pp.string_of_ppcmds (pr_ast qast) in
let is_green id =
match get_info vcs id with
| Some { state = Valid _ } -> true
@@ -510,8 +473,8 @@ end = struct (* {{{ *)
let reachable id = reachable !vcs id
let mk_branch_name { expr = x } = Branch.make
(match x with
- | VernacDefinition (_,((_,i),_),_) -> string_of_id i
- | VernacStartTheoremProof (_,[Some ((_,i),_),_],_) -> string_of_id i
+ | VernacDefinition (_,((_,i),_),_) -> Names.string_of_id i
+ | VernacStartTheoremProof (_,[Some ((_,i),_),_],_) -> Names.string_of_id i
| _ -> "branch")
let edit_branch = Branch.make "edit"
let branch ?root ?pos name kind = vcs := branch !vcs ?root ?pos name kind
@@ -567,7 +530,7 @@ end = struct (* {{{ *)
| { next = n; step = `Alias x } -> (id,Alias x) :: aux n
| { next = n; step = `Sideff (`Ast (x,_)) } ->
(id,Sideff (Some x)) :: aux n
- | _ -> anomaly(str("Cannot slice from "^ Stateid.to_string block_start ^
+ | _ -> anomaly Pp.(str("Cannot slice from "^ Stateid.to_string block_start ^
" to "^Stateid.to_string block_stop))
in aux block_stop
@@ -620,11 +583,11 @@ end = struct (* {{{ *)
l
let create_proof_task_box l ~qed ~block_start:lemma =
- if not (topo_invariant l) then anomaly (str "overlapping boxes");
+ if not (topo_invariant l) then anomaly Pp.(str "overlapping boxes");
vcs := create_property !vcs l (ProofTask { qed; lemma })
let create_proof_block ({ block_start; block_stop} as decl) name =
let l = nodes_in_slice ~block_start ~block_stop in
- if not (topo_invariant l) then anomaly (str "overlapping boxes");
+ if not (topo_invariant l) then anomaly Pp.(str "overlapping boxes");
vcs := create_property !vcs l (ProofBlock (decl, name))
let box_of id = List.map Dag.Property.data (property_of !vcs id)
let delete_boxes_of id =
@@ -635,7 +598,7 @@ end = struct (* {{{ *)
with
| [] -> None
| [x] -> Some x
- | _ -> anomaly (str "node with more than 1 proof task box")
+ | _ -> anomaly Pp.(str "node with more than 1 proof task box")
let gc () =
let old_vcs = !vcs in
@@ -716,14 +679,14 @@ module State : sig
?safe_id:Stateid.t ->
?redefine:bool -> ?cache:Summary.marshallable ->
?feedback_processed:bool -> (unit -> unit) -> Stateid.t -> unit
- val fix_exn_ref : (iexn -> iexn) ref
+ val fix_exn_ref : (Exninfo.iexn -> Exninfo.iexn) ref
val install_cached : Stateid.t -> unit
val is_cached : ?cache:Summary.marshallable -> Stateid.t -> bool
val is_cached_and_valid : ?cache:Summary.marshallable -> Stateid.t -> bool
- val exn_on : Stateid.t -> valid:Stateid.t -> iexn -> iexn
+ val exn_on : Stateid.t -> valid:Stateid.t -> Exninfo.iexn -> Exninfo.iexn
(* to send states across worker/master *)
type frozen_state
val get_cached : Stateid.t -> frozen_state
@@ -736,6 +699,9 @@ module State : sig
val proof_part_of_frozen : frozen_state -> proof_part
val assign : Stateid.t -> partial_state -> unit
+ (* Only for internal use to catch problems in parse_sentence, should
+ be removed in the state handling refactoring. *)
+ val cur_id : Stateid.t ref
end = struct (* {{{ *)
(* cur_id holds Stateid.dummy in case the last attempt to define a state
@@ -796,13 +762,13 @@ end = struct (* {{{ *)
| _ ->
(* coqc has a 1 slot cache and only for valid states *)
if interactive () = `No && Stateid.equal id !cur_id then ()
- else anomaly (str "installing a non cached state")
+ else anomaly Pp.(str "installing a non cached state")
let get_cached id =
try match VCS.get_info id with
| { state = Valid s } -> s
- | _ -> anomaly (str "not a cached state")
- with VCS.Expired -> anomaly (str "not a cached state (expired)")
+ | _ -> anomaly Pp.(str "not a cached state")
+ with VCS.Expired -> anomaly Pp.(str "not a cached state (expired)")
let assign id what =
if VCS.get_state id <> Empty then () else
@@ -850,10 +816,10 @@ end = struct (* {{{ *)
let define ?safe_id ?(redefine=false) ?(cache=`No) ?(feedback_processed=true)
f id
=
- feedback ~id:(State id) (ProcessingIn !Flags.async_proofs_worker_id);
+ feedback ~id:id (ProcessingIn !Flags.async_proofs_worker_id);
let str_id = Stateid.to_string id in
if is_cached id && not redefine then
- anomaly (str"defining state "++str str_id++str" twice");
+ anomaly Pp.(str"defining state "++str str_id++str" twice");
try
stm_prerr_endline (fun () -> "defining "^str_id^" (cache="^
if cache = `Yes then "Y)" else if cache = `Shallow then "S)" else "N)");
@@ -928,9 +894,9 @@ let indent_script_item ((ng1,ngl1),nl,beginend,ppl) (cmd,ng) =
| VernacBullet _ -> pred ind, nl, beginend
| _ -> ind, nl, beginend
in
- let pp =
+ let pp = Pp.(
(if nl then fnl () else mt ()) ++
- (hov (ind+1) (str (String.make ind ' ') ++ Ppvernac.pr_vernac cmd))
+ (hov (ind+1) (str (String.make ind ' ') ++ Ppvernac.pr_vernac cmd)))
in
(new_ngl, new_nl, new_beginend, pp :: ppl)
@@ -970,7 +936,7 @@ let show_script ?proof () =
List.fold_left indent_script_item ((1,[]),false,[],[]) cmds
in
let indented_cmds = List.rev (indented_cmds) in
- msg_notice (v 0 (prlist_with_sep fnl (fun x -> x) indented_cmds))
+ msg_notice Pp.(v 0 (prlist_with_sep fnl (fun x -> x) indented_cmds))
with Vcs_aux.Expired -> ()
end
@@ -982,7 +948,7 @@ let stm_vernac_interp ?proof id ?route { verbose; loc; expr } =
(* The Stm will gain the capability to interpret commmads affecting
the whole document state, such as backtrack, etc... so we start
to design the stm command interpreter now *)
- set_id_for_feedback ?route (State id);
+ set_id_for_feedback ?route id;
Aux_file.record_in_aux_set_at loc;
(* We need to check if a command should be filtered from
* vernac_entries, as it cannot handle it. This should go away in
@@ -997,15 +963,15 @@ let stm_vernac_interp ?proof id ?route { verbose; loc; expr } =
in
let aux_interp cmd =
if is_filtered_command cmd then
- stm_pperr_endline Pp.(fun () -> str "ignoring " ++ pr_vernac expr)
+ stm_pperr_endline Pp.(fun () -> str "ignoring " ++ Ppvernac.pr_vernac expr)
else match cmd with
| VernacShow ShowScript -> ShowScript.show_script ()
| expr ->
- stm_pperr_endline Pp.(fun () -> str "interpreting " ++ pr_vernac expr);
+ stm_pperr_endline Pp.(fun () -> str "interpreting " ++ Ppvernac.pr_vernac expr);
try Vernacentries.interp ?verbosely:(Some verbose) ?proof (loc, expr)
with e ->
let e = CErrors.push e in
- iraise Hooks.(call_process_error_once e)
+ Exninfo.iraise Hooks.(call_process_error_once e)
in aux_interp expr
(****************************** CRUFT *****************************************)
@@ -1016,7 +982,6 @@ module Backtrack : sig
val record : unit -> unit
val backto : Stateid.t -> unit
- val back_safe : unit -> unit
(* we could navigate the dag, but this ways easy *)
val branches_of : Stateid.t -> backup
@@ -1045,7 +1010,7 @@ end = struct (* {{{ *)
let info = VCS.get_info oid in
match info.vcs_backup with
| None, _ ->
- anomaly(str"Backtrack.backto "++str(Stateid.to_string oid)++
+ anomaly Pp.(str"Backtrack.backto "++str(Stateid.to_string oid)++
str": a state with no vcs_backup")
| Some vcs, _ -> VCS.restore vcs
@@ -1053,8 +1018,8 @@ end = struct (* {{{ *)
let info = VCS.get_info id in
match info.vcs_backup with
| _, None ->
- anomaly(str"Backtrack.branches_of "++str(Stateid.to_string id)++
- str": a state with no vcs_backup")
+ anomaly Pp.(str"Backtrack.branches_of "++str(Stateid.to_string id)++
+ str": a state with no vcs_backup")
| _, Some x -> x
let rec fold_until f acc id =
@@ -1076,13 +1041,6 @@ end = struct (* {{{ *)
| `Stop x -> x
| `Cont acc -> next acc
- let back_safe () =
- let id =
- fold_until (fun n (id,_,_,_,_) ->
- if n >= 0 && State.is_cached_and_valid id then `Stop id else `Cont (succ n))
- 0 (VCS.get_branch_pos (VCS.current_branch ())) in
- backto id
-
let undo_vernac_classifier v =
try
match v with
@@ -1115,7 +1073,7 @@ end = struct (* {{{ *)
let id = VCS.get_branch_pos (VCS.current_branch ()) in
let vcs =
match (VCS.get_info id).vcs_backup with
- | None, _ -> anomaly(str"Backtrack: tip with no vcs_backup")
+ | None, _ -> anomaly Pp.(str"Backtrack: tip with no vcs_backup")
| Some vcs, _ -> vcs in
let cb, _ =
try Vcs_aux.find_proof_at_depth vcs (Vcs_aux.proof_nesting vcs)
@@ -1139,7 +1097,7 @@ end = struct (* {{{ *)
with
| Not_found ->
CErrors.user_err ~hdr:"undo_vernac_classifier"
- (str "Cannot undo")
+ Pp.(str "Cannot undo")
end (* }}} *)
@@ -1171,7 +1129,7 @@ let record_pb_time proof_name loc time =
hints := Aux_file.set !hints Loc.ghost proof_name proof_build_time
end
-exception RemoteException of std_ppcmds
+exception RemoteException of Pp.std_ppcmds
let _ = CErrors.register_handler (function
| RemoteException ppcmd -> ppcmd
| _ -> raise Unhandled)
@@ -1206,7 +1164,7 @@ let proof_block_delimiters = ref []
let register_proof_block_delimiter name static dynamic =
if List.mem_assoc name !proof_block_delimiters then
- CErrors.user_err ~hdr:"STM" (str "Duplicate block delimiter " ++ str name);
+ CErrors.user_err ~hdr:"STM" Pp.(str "Duplicate block delimiter " ++ str name);
proof_block_delimiters := (name, (static,dynamic)) :: !proof_block_delimiters
let mk_doc_node id = function
@@ -1242,11 +1200,13 @@ let detect_proof_block id name =
end
with Not_found ->
CErrors.user_err ~hdr:"STM"
- (str "Unknown proof block delimiter " ++ str name)
+ Pp.(str "Unknown proof block delimiter " ++ str name)
)
(****************************** THE SCHEDULER *********************************)
(******************************************************************************)
+(* Unused module warning doesn't understand [module rec] *)
+[@@@ocaml.warning "-60"]
module rec ProofTask : sig
type competence = Stateid.t list
@@ -1309,14 +1269,13 @@ end = struct (* {{{ *)
type error = {
e_error_at : Stateid.t;
e_safe_id : Stateid.t;
- e_msg : std_ppcmds;
+ e_msg : Pp.std_ppcmds;
e_safe_states : Stateid.t list }
type response =
| RespBuiltProof of Proof_global.closed_proof_output * float
| RespError of error
| RespStates of (Stateid.t * State.partial_state) list
- | RespDone
let name = ref "proofworker"
let extra_env () = !async_proofs_workers_extra_env
@@ -1382,9 +1341,9 @@ end = struct (* {{{ *)
| Some (BuildProof { t_start = start; t_assign }) ->
let s = "Worker dies or task expired" in
let info = Stateid.add ~valid:start Exninfo.null start in
- let e = (RemoteException (strbrk s), info) in
+ let e = (RemoteException (Pp.strbrk s), info) in
t_assign (`Exn e);
- execution_error start Loc.ghost (strbrk s);
+ execution_error start Loc.ghost (Pp.strbrk s);
feedback (InProgress ~-1)
let build_proof_here ~drop_pt (id,valid) loc eop =
@@ -1396,7 +1355,7 @@ end = struct (* {{{ *)
Aux_file.record_in_aux_at loc "proof_build_time"
(Printf.sprintf "%.3f" (wall_clock2 -. wall_clock1));
let p = Proof_global.return_proof ~allow_partial:drop_pt () in
- if drop_pt then feedback ~id:(State id) Complete;
+ if drop_pt then feedback ~id Complete;
p)
let perform_buildp { Stateid.exn_info; stop; document; loc } drop my_states =
@@ -1415,7 +1374,7 @@ end = struct (* {{{ *)
if not drop then begin
let checked_proof = Future.chain ~pure:false future_proof (fun p ->
let pobject, _ =
- Proof_global.close_future_proof stop (Future.from_val ~fix_exn p) in
+ Proof_global.close_future_proof ~feedback_id:stop (Future.from_val ~fix_exn p) in
let terminator = (* The one sent by master is an InvalidKey *)
Lemmas.(standard_proof_terminator [] (mk_hook (fun _ _ -> ()))) in
stm_vernac_interp stop
@@ -1465,7 +1424,7 @@ end = struct (* {{{ *)
when is_tac expr && State.same_env o n -> (* A pure tactic *)
Some (id, `Proof (prev, State.proof_part_of_frozen n))
| Some _, Some s ->
- msg_debug (str "STM: sending back a fat state");
+ msg_debug (Pp.str "STM: sending back a fat state");
Some (id, `Full s)
| _, Some s -> Some (id, `Full s) in
let rec aux seen = function
@@ -1481,10 +1440,10 @@ end = struct (* {{{ *)
| ReqStates sl -> RespStates (perform_states sl)
let on_marshal_error s = function
- | States _ -> msg_error(strbrk("Marshalling error: "^s^". "^
+ | States _ -> msg_error(Pp.strbrk("Marshalling error: "^s^". "^
"The system state could not be sent to the master process."))
| BuildProof { t_exn_info; t_stop; t_assign; t_loc; t_drop = drop_pt } ->
- msg_error(strbrk("Marshalling error: "^s^". "^
+ msg_error(Pp.strbrk("Marshalling error: "^s^". "^
"The system state could not be sent to the worker process. "^
"Falling back to local, lazy, evaluation."));
t_assign(`Comp(build_proof_here ~drop_pt t_exn_info t_loc t_stop));
@@ -1537,7 +1496,7 @@ end = struct (* {{{ *)
let check_task_aux extra name l i =
let { Stateid.stop; document; loc; name = r_name }, drop = List.nth l i in
Flags.if_verbose msg_info
- (str(Printf.sprintf "Checking task %d (%s%s) of %s" i r_name extra name));
+ Pp.(str(Printf.sprintf "Checking task %d (%s%s) of %s" i r_name extra name));
VCS.restore document;
let start =
let rec aux cur =
@@ -1568,7 +1527,7 @@ end = struct (* {{{ *)
let (e, info) = CErrors.push e in
(try match Stateid.get info with
| None ->
- msg_error (
+ msg_error Pp.(
str"File " ++ str name ++ str ": proof of " ++ str r_name ++
spc () ++ iprint (e, info))
| Some (_, cur) ->
@@ -1578,16 +1537,16 @@ end = struct (* {{{ *)
| { step = `Qed ( { qast = { loc } }, _) }
| { step = `Sideff (`Ast ( { loc }, _)) } ->
let start, stop = Loc.unloc loc in
- msg_error (
+ msg_error Pp.(
str"File " ++ str name ++ str ": proof of " ++ str r_name ++
str ": chars " ++ int start ++ str "-" ++ int stop ++
spc () ++ iprint (e, info))
| _ ->
- msg_error (
+ msg_error Pp.(
str"File " ++ str name ++ str ": proof of " ++ str r_name ++
spc () ++ iprint (e, info))
with e ->
- msg_error (str"unable to print error message: " ++
+ msg_error Pp.(str"unable to print error message: " ++
str (Printexc.to_string e)));
if drop then `ERROR_ADMITTED else `ERROR
@@ -1746,7 +1705,7 @@ end = struct (* {{{ *)
type response =
| RespBuiltSubProof of output
- | RespError of std_ppcmds
+ | RespError of Pp.std_ppcmds
| RespNoProgress
exception NoProgress
@@ -1806,7 +1765,7 @@ end = struct (* {{{ *)
List.for_all (Context.Named.Declaration.for_all is_ground)
Evd.(evar_context g))
then
- CErrors.user_err ~hdr:"STM" (strbrk("the par: goal selector supports ground "^
+ CErrors.user_err ~hdr:"STM" Pp.(strbrk("the par: goal selector supports ground "^
"goals only"))
else begin
let (i, ast) = r_ast in
@@ -1821,7 +1780,7 @@ end = struct (* {{{ *)
if Evarutil.is_ground_term sigma t then
let t = EConstr.Unsafe.to_constr t in
RespBuiltSubProof (t, Evd.evar_universe_context sigma)
- else CErrors.user_err ~hdr:"STM" (str"The solution is not ground")
+ else CErrors.user_err ~hdr:"STM" Pp.(str"The solution is not ground")
end) ()
with e when CErrors.noncritical e -> RespError (CErrors.print e)
@@ -1845,12 +1804,13 @@ end = struct (* {{{ *)
{ indentation; verbose; loc; expr = e; strlen }
=
let e, time, fail =
- let rec find time fail = function
- | VernacTime (_,e) | VernacRedirect (_,(_,e)) -> find true fail e
- | VernacFail e -> find time true e
- | _ -> e, time, fail in find false false e in
+ let rec find ~time ~fail = function
+ | VernacTime (_,e) -> find ~time:true ~fail e
+ | VernacRedirect (_,(_,e)) -> find ~time ~fail e
+ | VernacFail e -> find ~time ~fail:true e
+ | e -> e, time, fail in find ~time:false ~fail:false e in
Vernacentries.with_fail fail (fun () ->
- (if time then System.with_time false else (fun x -> x)) (fun () ->
+ (if time then System.with_time !Flags.time else (fun x -> x)) (fun () ->
ignore(TaskQueue.with_n_workers nworkers (fun queue ->
Proof_global.with_current_proof (fun _ p ->
let goals, _, _, _, _ = Proof.proof p in
@@ -1943,11 +1903,11 @@ end = struct (* {{{ *)
Reach.known_state ~cache:`No r_where;
try
stm_vernac_interp r_for { r_what with verbose = true };
- feedback ~id:(State r_for) Processed
+ feedback ~id:r_for Processed
with e when CErrors.noncritical e ->
let e = CErrors.push e in
let msg = iprint e in
- feedback ~id:(State r_for) (Message (Error, None, msg))
+ feedback ~id:r_for (Message (Error, None, msg))
let name_of_task { t_what } = string_of_ppcmds (pr_ast t_what)
let name_of_request { r_what } = string_of_ppcmds (pr_ast r_what)
@@ -2009,12 +1969,16 @@ let collect_proof keep cur hd brkind id =
let no_name = "" in
let name = function
| [] -> no_name
- | id :: _ -> Id.to_string id in
+ | id :: _ -> Names.Id.to_string id in
let loc = (snd cur).loc in
- let is_defined = function
- | _, { expr = VernacEndProof (Proved ((Transparent|Opaque (Some _)),_)) } ->
- true
+ let rec is_defined_expr = function
+ | VernacEndProof (Proved ((Transparent|Opaque (Some _)),_)) -> true
+ | VernacTime (_, e) -> is_defined_expr e
+ | VernacRedirect (_, (_, e)) -> is_defined_expr e
+ | VernacTimeout (_, e) -> is_defined_expr e
| _ -> false in
+ let is_defined = function
+ | _, { expr = e } -> is_defined_expr e in
let proof_using_ast = function
| Some (_, ({ expr = VernacProof(_,Some _) } as v)) -> Some v
| _ -> None in
@@ -2130,13 +2094,13 @@ let known_state ?(redefine_qed=false) ~cache id =
Some (decl, name)
| _ -> None) boxes in
assert(List.length valid_boxes < 2);
- if valid_boxes = [] then iraise exn
+ if valid_boxes = [] then Exninfo.iraise exn
else
let decl, name = List.hd valid_boxes in
try
let _, dynamic_check = List.assoc name !proof_block_delimiters in
match dynamic_check decl with
- | `Leaks -> iraise exn
+ | `Leaks -> Exninfo.iraise exn
| `ValidBlock { base_state; goals_to_admit; recovery_command } -> begin
let tac =
let open Proofview.Notations in
@@ -2149,7 +2113,7 @@ let known_state ?(redefine_qed=false) ~cache id =
| Valid { proof } ->
Proof_global.unfreeze proof;
Proof_global.with_current_proof (fun _ p ->
- feedback ~id:(State id) Feedback.AddedAxiom;
+ feedback ~id:id Feedback.AddedAxiom;
fst (Pfedit.solve Vernacexpr.SelectAll None tac p), ());
Option.iter (fun expr -> stm_vernac_interp id {
verbose = true; loc = Loc.ghost; expr; indentation = 0;
@@ -2216,10 +2180,8 @@ let known_state ?(redefine_qed=false) ~cache id =
(fun () ->
resilient_tactic id cblock (fun () ->
reach ~cache:`Shallow view.next;
- Hooks.(call tactic_being_run true);
Partac.vernac_interp ~solve ~abstract
- cancel !Flags.async_proofs_n_tacworkers view.next id x;
- Hooks.(call tactic_being_run false))
+ cancel !Flags.async_proofs_n_tacworkers view.next id x)
), cache, true
| `Cmd { cast = x; cqueue = `QueryQueue cancel }
when Flags.async_proofs_is_master () -> (fun () ->
@@ -2229,9 +2191,7 @@ let known_state ?(redefine_qed=false) ~cache id =
| `Cmd { cast = x; ceff = eff; ctac = true; cblock } -> (fun () ->
resilient_tactic id cblock (fun () ->
reach view.next;
- Hooks.(call tactic_being_run true);
- stm_vernac_interp id x;
- Hooks.(call tactic_being_run false));
+ stm_vernac_interp id x);
if eff then update_global_env ()
), (if eff then `Yes else cache), true
| `Cmd { cast = x; ceff = eff } -> (fun () ->
@@ -2254,7 +2214,7 @@ let known_state ?(redefine_qed=false) ~cache id =
with e when CErrors.noncritical e ->
let (e, info) = CErrors.push e in
let info = Stateid.add info ~valid:prev id in
- iraise (e, info));
+ Exninfo.iraise (e, info));
wall_clock_last_fork := Unix.gettimeofday ()
), `Yes, true
| `Qed ({ qast = x; keep; brinfo; brname } as qed, eop) ->
@@ -2301,7 +2261,7 @@ let known_state ?(redefine_qed=false) ~cache id =
if not delegate then ignore(Future.compute fp);
reach view.next;
stm_vernac_interp id ~proof x;
- feedback ~id:(State id) Incomplete
+ feedback ~id:id Incomplete
| { VCS.kind = `Master }, _ -> assert false
end;
Proof_global.discard_all ()
@@ -2337,9 +2297,9 @@ let known_state ?(redefine_qed=false) ~cache id =
| `MaybeASync (start, pua, nodes, name, delegate) -> (fun () ->
reach ~cache:`Shallow start;
(* no sections *)
- if List.is_empty (Environ.named_context (Global.env ()))
- then pi1 (aux (`ASync (start, pua, nodes, name, delegate))) ()
- else pi1 (aux (`Sync (name, pua, `NoPU_NoHint_NoES))) ()
+ if CList.is_empty (Environ.named_context (Global.env ()))
+ then Util.pi1 (aux (`ASync (start, pua, nodes, name, delegate))) ()
+ else Util.pi1 (aux (`Sync (name, pua, `NoPU_NoHint_NoES))) ()
), (if redefine_qed then `No else `Yes), true
in
aux (collect_proof keep (view.next, x) brname brinfo eop)
@@ -2360,6 +2320,7 @@ let known_state ?(redefine_qed=false) ~cache id =
reach ~redefine_qed id
end (* }}} *)
+[@@@ocaml.warning "+60"]
(********************************* STM API ************************************)
(******************************************************************************)
@@ -2393,20 +2354,20 @@ let observe id =
let e = CErrors.push e in
VCS.print ();
VCS.restore vcs;
- iraise e
+ Exninfo.iraise e
-let finish ?(print_goals=false) () =
+let finish () =
let head = VCS.current_branch () in
observe (VCS.get_branch_pos head);
- if print_goals then msg_notice (pr_open_cur_subgoals ());
VCS.print ();
+ (* EJGA: Setting here the proof state looks really wrong, and it
+ hides true bugs cf bug #5363. Also, what happens with observe? *)
(* Some commands may by side effect change the proof mode *)
match VCS.get_branch head with
| { VCS.kind = `Edit (mode,_,_,_,_) } -> Proof_global.activate_proof_mode mode
| { VCS.kind = `Proof (mode, _) } -> Proof_global.activate_proof_mode mode
| _ -> ()
-
let wait () =
Slaves.wait_all_done ();
VCS.print ()
@@ -2466,7 +2427,7 @@ let merge_proof_branch ~valid ?id qast keep brname =
let id = VCS.new_node ?id () in
VCS.merge id ~ours:(Qed (qed None)) brname;
VCS.delete_branch brname;
- VCS.propagate_sideff None;
+ VCS.propagate_sideff ~replay:None;
`Ok
| { VCS.kind = `Edit (mode, qed_id, master_id, _,_) } ->
let ofp =
@@ -2480,35 +2441,23 @@ let merge_proof_branch ~valid ?id qast keep brname =
VCS.checkout VCS.Branch.master;
`Unfocus qed_id
| { VCS.kind = `Master } ->
- iraise (State.exn_on ~valid Stateid.dummy (Proof_global.NoCurrentProof, Exninfo.null))
+ Exninfo.iraise (State.exn_on ~valid Stateid.dummy (Proof_global.NoCurrentProof, Exninfo.null))
(* When tty is true, this code also does some of the job of the user interface:
jump back to a state that is valid *)
-let handle_failure (e, info) vcs tty =
- if e = CErrors.Drop then iraise (e, info) else
+let handle_failure (e, info) vcs =
+ if e = CErrors.Drop then Exninfo.iraise (e, info) else
match Stateid.get info with
| None ->
VCS.restore vcs;
VCS.print ();
- if tty && interactive () = `Yes then begin
- (* Hopefully the 1 to last state is valid *)
- Backtrack.back_safe ();
- VCS.checkout_shallowest_proof_branch ();
- end;
- VCS.print ();
anomaly(str"error with no safe_id attached:" ++ spc() ++
CErrors.iprint_no_report (e, info))
| Some (safe_id, id) ->
stm_prerr_endline (fun () -> "Failed at state " ^ Stateid.to_string id);
VCS.restore vcs;
- if tty && interactive () = `Yes then begin
- (* We stay on a valid state *)
- Backtrack.backto safe_id;
- VCS.checkout_shallowest_proof_branch ();
- Reach.known_state ~cache:(interactive ()) safe_id;
- end;
VCS.print ();
- iraise (e, info)
+ Exninfo.iraise (e, info)
let snapshot_vio ldir long_f_dot_vo =
finish ();
@@ -2520,7 +2469,7 @@ let snapshot_vio ldir long_f_dot_vo =
let reset_task_queue = Slaves.reset_task_queue
(* Document building *)
-let process_transaction ?(newtip=Stateid.fresh ()) ~tty
+let process_transaction ?(newtip=Stateid.fresh ())
({ verbose; loc; expr } as x) c =
stm_pperr_endline (fun () -> str "{{{ processing: " ++ pr_ast x);
let vcs = VCS.backup () in
@@ -2566,18 +2515,11 @@ let process_transaction ?(newtip=Stateid.fresh ()) ~tty
anomaly(str"classifier: VtBack + VtLater must imply part_of_script")
(* Query *)
- | VtQuery (false,(report_id,route)), VtNow when tty = true ->
- finish ();
- (try Future.purify (stm_vernac_interp report_id ~route)
- {x with verbose = true }
- with e when CErrors.noncritical e ->
- let e = CErrors.push e in
- iraise (State.exn_on ~valid:Stateid.dummy report_id e)); `Ok
| VtQuery (false,(report_id,route)), VtNow ->
(try stm_vernac_interp report_id ~route x
with e ->
let e = CErrors.push e in
- iraise (State.exn_on ~valid:Stateid.dummy report_id e)); `Ok
+ Exninfo.iraise (State.exn_on ~valid:Stateid.dummy report_id e)); `Ok
| VtQuery (true,(report_id,_)), w ->
assert(Stateid.equal report_id Stateid.dummy);
let id = VCS.new_node ~id:newtip () in
@@ -2704,7 +2646,7 @@ let process_transaction ?(newtip=Stateid.fresh ()) ~tty
rc
with e ->
let e = CErrors.push e in
- handle_failure e vcs tty
+ handle_failure e vcs
let get_ast id =
match VCS.visit id with
@@ -2716,29 +2658,94 @@ let get_ast id =
let stop_worker n = Slaves.cancel_worker n
+(* We must parse on top of a state id, it should be something like:
+
+ - get parsing information for that state.
+ - feed the parsable / parser with the right parsing information.
+ - call the parser
+
+ Now, the invariant in ensured by the callers, but this is a bit
+ problematic.
+*)
+exception End_of_input
+
+let parse_sentence sid pa =
+ (* XXX: Should this restore the previous state?
+ Using reach here to try to really get to the
+ proper state makes the error resilience code fail *)
+ (* Reach.known_state ~cache:`Yes sid; *)
+ let cur_tip = VCS.cur_tip () in
+ let real_tip = !State.cur_id in
+ if not (Stateid.equal sid cur_tip) then
+ user_err ~hdr:"Stm.parse_sentence"
+ (str "Currently, the parsing api only supports parsing at the tip of the document." ++ fnl () ++
+ str "You wanted to parse at: " ++ str (Stateid.to_string sid) ++
+ str " but the current tip is: " ++ str (Stateid.to_string cur_tip)) ;
+ if not (Stateid.equal sid real_tip) && !Flags.debug && stm_debug then
+ Feedback.msg_debug
+ (str "Warning, the real tip doesn't match the current tip." ++
+ str "You wanted to parse at: " ++ str (Stateid.to_string sid) ++
+ str " but the real tip is: " ++ str (Stateid.to_string real_tip) ++ fnl () ++
+ str "This is usually due to use of Stm.observe to evaluate a state different than the tip. " ++
+ str "All is good if not parsing changes occur between the two states, however if they do, a problem might occur.");
+ Flags.with_option Flags.we_are_parsing (fun () ->
+ try
+ match Pcoq.Gram.entry_parse Pcoq.main_entry pa with
+ | None -> raise End_of_input
+ | Some com -> com
+ with e when CErrors.noncritical e ->
+ let (e, info) = CErrors.push e in
+ Exninfo.iraise (e, info))
+ ()
+
(* You may need to know the len + indentation of previous command to compute
* the indentation of the current one.
* Eg. foo. bar.
* Here bar is indented of the indentation of foo + its strlen (4) *)
-let ind_len_of id =
- if Stateid.equal id Stateid.initial then 0
- else match (VCS.visit id).step with
- | `Cmd { ctac = true; cast = { indentation; strlen } } ->
- indentation + strlen
- | _ -> 0
-
-let add ~ontop ?newtip ?(check=ignore) verb eid s =
+let ind_len_loc_of_id sid =
+ if Stateid.equal sid Stateid.initial then None
+ else match (VCS.visit sid).step with
+ | `Cmd { ctac = true; cast = { indentation; strlen; loc } } ->
+ Some (indentation, strlen, loc)
+ | _ -> None
+
+(* the indentation logic works like this: if the beginning of the
+ command is different than the start we are in a new line, thus
+ indentation follows from the starting position. Otherwise, we use
+ the previous one plus the offset.
+
+ Note, this could maybe improved by handling more cases in
+ compute_indentation. *)
+
+let compute_indentation sid loc =
+ let open Loc in
+ (* The effective lenght is the lenght on the last line *)
+ let len = loc.ep - loc.bp in
+ let prev_indent = match ind_len_loc_of_id sid with
+ | None -> 0
+ | Some (i,l,p) -> i + l
+ in
+ (* Now if the line has not changed, the need to add the previous indent *)
+ let eff_indent = loc.bp - loc.bol_pos in
+ if loc.bol_pos = 0 then
+ eff_indent + prev_indent, len
+ else
+ eff_indent, len
+
+
+let add ~ontop ?newtip verb (loc, ast) =
let cur_tip = VCS.cur_tip () in
if not (Stateid.equal ontop cur_tip) then
- (* For now, arbitrary edits should be announced with edit_at *)
- anomaly(str"Not yet implemented, the GUI should not try this");
- let indentation, strlen, loc, ast =
- vernac_parse ~indlen_prev:(fun () -> ind_len_of ontop) ?newtip eid s in
+ user_err ~hdr:"Stm.add"
+ (str "Stm.add called for a different state (" ++ str (Stateid.to_string ontop) ++
+ str ") than the tip: " ++ str (Stateid.to_string cur_tip) ++ str "." ++ fnl () ++
+ str "This is not supported yet, sorry.");
+ let indentation, strlen = compute_indentation ontop loc in
CWarnings.set_current_loc loc;
- check(loc,ast);
+ (* XXX: Classifiy vernac should be moved inside process transaction *)
let clas = classify_vernac ast in
let aast = { verbose = verb; indentation; strlen; loc; expr = ast } in
- match process_transaction ?newtip ~tty:false aast clas with
+ match process_transaction ?newtip aast clas with
| `Ok -> VCS.cur_tip (), `NewTip
| `Unfocus qed_id -> qed_id, `Unfocus (VCS.cur_tip ())
@@ -2754,17 +2761,16 @@ let query ~at ?(report_with=(Stateid.dummy,default_route)) s =
Future.purify (fun s ->
if Stateid.equal at Stateid.dummy then finish ()
else Reach.known_state ~cache:`Yes at;
- let newtip, route = report_with in
- let indentation, strlen, loc, ast = vernac_parse ~newtip ~route 0 s in
+ let loc, ast = parse_sentence at s in
+ let indentation, strlen = compute_indentation at loc in
CWarnings.set_current_loc loc;
let clas = classify_vernac ast in
let aast = { verbose = true; indentation; strlen; loc; expr = ast } in
match clas with
| VtStm (w,_), _ ->
- ignore(process_transaction ~tty:false aast (VtStm (w,false), VtNow))
+ ignore(process_transaction aast (VtStm (w,false), VtNow))
| _ ->
- ignore(process_transaction
- ~tty:false aast (VtQuery (false,report_with), VtNow)))
+ ignore(process_transaction aast (VtQuery (false,report_with), VtNow)))
s
let edit_at id =
@@ -2888,37 +2894,16 @@ let edit_at id =
stm_prerr_endline (fun () -> "Failed at state " ^ Stateid.to_string id);
VCS.restore vcs;
VCS.print ();
- iraise (e, info)
+ Exninfo.iraise (e, info)
let backup () = VCS.backup ()
let restore d = VCS.restore d
+let get_current_state () = VCS.cur_tip ()
+
(*********************** TTY API (PG, coqtop, coqc) ***************************)
(******************************************************************************)
-let interp verb (loc,e) =
- let clas = classify_vernac e in
- let aast = { verbose = verb; indentation = 0; strlen = 0; loc; expr = e } in
- let rc = process_transaction ~tty:true aast clas in
- if rc <> `Ok then anomaly(str"tty loop can't be mixed with the STM protocol");
- if interactive () = `Yes ||
- (!Flags.async_proofs_mode = Flags.APoff &&
- !Flags.compilation_mode = Flags.BuildVo) then
- let vcs = VCS.backup () in
- let print_goals =
- verb && match clas with
- | VtQuery _, _ -> false
- | (VtProofStep _ | VtStm (VtBack _, _) | VtStartProof _), _ -> true
- | _ -> not !Flags.coqtop_ui in
- try finish ~print_goals ()
- with e ->
- let e = CErrors.push e in
- handle_failure e vcs true
-
-let finish () = finish ()
-
-let get_current_state () = VCS.cur_tip ()
-
let current_proof_depth () =
let head = VCS.current_branch () in
match VCS.get_branch head with
@@ -2939,15 +2924,13 @@ let proofname b = match VCS.get_branch b with
| _ -> None
let get_all_proof_names () =
- List.map unmangle (List.map_filter proofname (VCS.branches ()))
+ List.map unmangle (CList.map_filter proofname (VCS.branches ()))
(* Export hooks *)
let state_computed_hook = Hooks.state_computed_hook
let state_ready_hook = Hooks.state_ready_hook
-let parse_error_hook = Hooks.parse_error_hook
let forward_feedback_hook = Hooks.forward_feedback_hook
-let process_error_hook = Hooks.process_error_hook
let unreachable_state_hook = Hooks.unreachable_state_hook
let () = Hook.set Obligations.stm_get_fix_exn (fun () -> !State.fix_exn_ref)
-let tactic_being_run_hook = Hooks.tactic_being_run_hook
+
(* vim:set foldmethod=marker: *)
diff --git a/stm/stm.mli b/stm/stm.mli
index 0f0a3c4e13..d2bee44964 100644
--- a/stm/stm.mli
+++ b/stm/stm.mli
@@ -6,31 +6,35 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Vernacexpr
open Names
-open Feedback
-open Loc
(** state-transaction-machine interface *)
-(* [add ontop check vebose eid s] adds a new command [s] on the state [ontop]
- having edit id [eid]. [check] is called on the AST.
- The [ontop] parameter is just for asserting the GUI is on sync, but
- will eventually call edit_at on the fly if needed.
- The sentence [s] is parsed in the state [ontop].
- If [newtip] is provided, then the returned state id is guaranteed to be
- [newtip] *)
-val add :
- ontop:Stateid.t -> ?newtip:Stateid.t ->
- ?check:(vernac_expr located -> unit) ->
- bool -> edit_id -> string ->
- Stateid.t * [ `NewTip | `Unfocus of Stateid.t ]
-
-(* parses and executes a command at a given state, throws away its side effects
- but for the printings. Feedback is sent with report_with (defaults to dummy
- state id) *)
+(* [parse_sentence sid pa] Reads a sentence from [pa] with parsing
+ state [sid] Returns [End_of_input] if the stream ends *)
+val parse_sentence : Stateid.t -> Pcoq.Gram.coq_parsable ->
+ Vernacexpr.vernac_expr Loc.located
+
+(* Reminder: A parsable [pa] is constructed using
+ [Pcoq.Gram.coq_parsable stream], where [stream : char Stream.t]. *)
+
+exception End_of_input
+
+(* [add ~ontop ?newtip verbose cmd] adds a new command [cmd] ontop of
+ the state [ontop].
+ The [ontop] parameter just asserts that the GUI is on
+ sync, but it will eventually call edit_at on the fly if needed.
+ If [newtip] is provided, then the returned state id is guaranteed
+ to be [newtip] *)
+val add : ontop:Stateid.t -> ?newtip:Stateid.t ->
+ bool -> Vernacexpr.vernac_expr Loc.located ->
+ Stateid.t * [ `NewTip | `Unfocus of Stateid.t ]
+
+(* [query at ?report_with cmd] Executes [cmd] at a given state [at],
+ throwing away side effects except messages. Feedback will
+ be sent with [report_with], which defaults to the dummy state id *)
val query :
- at:Stateid.t -> ?report_with:(Stateid.t * Feedback.route_id) -> string -> unit
+ at:Stateid.t -> ?report_with:(Stateid.t * Feedback.route_id) -> Pcoq.Gram.coq_parsable -> unit
(* [edit_at id] is issued to change the editing zone. [`NewTip] is returned if
the requested id is the new document tip hence the document portion following
@@ -182,14 +186,10 @@ val register_proof_block_delimiter :
* the name of the Task(s) above) *)
val state_computed_hook : (Stateid.t -> in_cache:bool -> unit) Hook.t
-val parse_error_hook :
- (Feedback.edit_or_state_id -> Loc.t -> Pp.std_ppcmds -> unit) Hook.t
val unreachable_state_hook : (Stateid.t -> Exninfo.iexn -> unit) Hook.t
+
(* ready means that master has it at hand *)
val state_ready_hook : (Stateid.t -> unit) Hook.t
-(* called with true before and with false after a tactic explicitly
- * in the document is run *)
-val tactic_being_run_hook : (bool -> unit) Hook.t
(* Messages from the workers to the master *)
val forward_feedback_hook : (Feedback.feedback -> unit) Hook.t
@@ -202,16 +202,6 @@ type state = {
val state_of_id :
Stateid.t -> [ `Valid of state option | `Expired | `Error of exn ]
-(** read-eval-print loop compatible interface ****************************** **)
-
-(* Adds a new line to the document. It replaces the core of Vernac.interp.
- [finish] is called as the last bit of this function if the system
- is running interactively (-emacs or coqtop). *)
-val interp : bool -> vernac_expr located -> unit
-
(* Queries for backward compatibility *)
val current_proof_depth : unit -> int
val get_all_proof_names : unit -> Id.t list
-
-(* Hooks to be set by other Coq components in order to break file cycles *)
-val process_error_hook : Future.fix_exn Hook.t
diff --git a/stm/vcs.ml b/stm/vcs.ml
index d3886464d9..88f860eb69 100644
--- a/stm/vcs.ml
+++ b/stm/vcs.ml
@@ -74,8 +74,6 @@ module Dag = Dag.Make(OT)
type id = OT.t
-module NodeSet = Dag.NodeSet
-
module Branch =
struct
type t = string
diff --git a/stm/vernac_classifier.ml b/stm/vernac_classifier.ml
index 5908c09d08..c4f392f201 100644
--- a/stm/vernac_classifier.ml
+++ b/stm/vernac_classifier.ml
@@ -203,7 +203,6 @@ let rec classify_vernac e =
| VernacToplevelControl _
| VernacRestoreState _
| VernacWriteState _ -> VtUnknown, VtNow
- | VernacError _ -> assert false
(* Plugins should classify their commands *)
| VernacExtend (s,l) ->
try List.assoc s !classifiers l ()
diff --git a/stm/workerLoop.ml b/stm/workerLoop.ml
index 50b42512cb..86ef59dc30 100644
--- a/stm/workerLoop.ml
+++ b/stm/workerLoop.ml
@@ -13,7 +13,7 @@ let rec parse = function
let loop init args =
let args = parse args in
- Flags.make_silent true;
+ Flags.quiet := true;
init ();
CoqworkmgrApi.init !Flags.async_proofs_worker_priority;
args
diff --git a/tactics/auto.ml b/tactics/auto.ml
index 74cb7a364f..c2d12ebd08 100644
--- a/tactics/auto.ml
+++ b/tactics/auto.ml
@@ -10,16 +10,12 @@ module CVars = Vars
open Pp
open Util
-open CErrors
open Names
-open Vars
open Termops
open EConstr
open Environ
-open Tacmach
open Genredexpr
open Tactics
-open Tacticals
open Clenv
open Locus
open Proofview.Notations
@@ -380,7 +376,7 @@ and my_find_search_delta sigma db_list local_db secvars hdc concl =
and tac_of_hint dbg db_list local_db concl (flags, ({pat=p; code=t;poly=poly;db=dbname})) =
let tactic = function
| Res_pf (c,cl) -> unify_resolve_gen poly flags (c,cl)
- | ERes_pf _ -> Proofview.V82.tactic (fun gl -> error "eres_pf")
+ | ERes_pf _ -> Proofview.Goal.enter { enter = fun gl -> Tacticals.New.tclZEROMSG (str "eres_pf") }
| Give_exact (c, cl) -> exact poly (c, cl)
| Res_pf_THEN_trivial_fail (c,cl) ->
Tacticals.New.tclTHEN
@@ -389,10 +385,11 @@ and tac_of_hint dbg db_list local_db concl (flags, ({pat=p; code=t;poly=poly;db=
with "debug auto" we don't display the details of inner trivial *)
(trivial_fail_db (no_dbg ()) (not (Option.is_empty flags)) db_list local_db)
| Unfold_nth c ->
- Proofview.V82.tactic (fun gl ->
- if exists_evaluable_reference (pf_env gl) c then
- tclPROGRESS (Proofview.V82.of_tactic (reduce (Unfold [AllOccurrences,c]) Locusops.onConcl)) gl
- else tclFAIL 0 (str"Unbound reference") gl)
+ Proofview.Goal.enter { enter = begin fun gl ->
+ if exists_evaluable_reference (Tacmach.New.pf_env gl) c then
+ Tacticals.New.tclPROGRESS (reduce (Unfold [AllOccurrences,c]) Locusops.onConcl)
+ else Tacticals.New.tclFAIL 0 (str"Unbound reference")
+ end }
| Extern tacast ->
conclPattern concl p tacast
in
diff --git a/tactics/auto.mli b/tactics/auto.mli
index 32710e3470..9ed9f0ae26 100644
--- a/tactics/auto.mli
+++ b/tactics/auto.mli
@@ -9,7 +9,6 @@
(** This files implements auto and related automation tactics *)
open Names
-open Term
open EConstr
open Clenv
open Pattern
diff --git a/tactics/autorewrite.ml b/tactics/autorewrite.ml
index e58ec5a31f..2d54b61c72 100644
--- a/tactics/autorewrite.ml
+++ b/tactics/autorewrite.ml
@@ -9,8 +9,6 @@
open Equality
open Names
open Pp
-open Tacticals
-open Tactics
open Term
open Termops
open CErrors
@@ -127,45 +125,13 @@ let autorewrite ?(conds=Naive) tac_main lbas =
(Proofview.tclUNIT()) lbas))
let autorewrite_multi_in ?(conds=Naive) idl tac_main lbas =
- Proofview.Goal.nf_enter { enter = begin fun gl ->
+ Proofview.Goal.enter { enter = begin fun gl ->
(* let's check at once if id exists (to raise the appropriate error) *)
- let _ = List.map (fun id -> Tacmach.New.pf_get_hyp id gl) idl in
- let general_rewrite_in id =
- let id = ref id in
- let to_be_cleared = ref false in
- fun dir cstr tac gl ->
- let last_hyp_id =
- match Tacmach.pf_hyps gl with
- d :: _ -> Context.Named.Declaration.get_id d
- | _ -> (* even the hypothesis id is missing *)
- raise (Logic.RefinerError (Logic.NoSuchHyp !id))
- in
- let gl' = Proofview.V82.of_tactic (general_rewrite_in dir AllOccurrences true ~tac:(tac, conds) false !id cstr false) gl in
- let gls = gl'.Evd.it in
- match gls with
- g::_ ->
- (match Environ.named_context_of_val (Goal.V82.hyps gl'.Evd.sigma g) with
- d ::_ ->
- let lastid = Context.Named.Declaration.get_id d in
- if not (Id.equal last_hyp_id lastid) then
- begin
- let gl'' =
- if !to_be_cleared then
- tclTHEN (fun _ -> gl') (tclTRY (Proofview.V82.of_tactic (clear [!id]))) gl
- else gl' in
- id := lastid ;
- to_be_cleared := true ;
- gl''
- end
- else
- begin
- to_be_cleared := false ;
- gl'
- end
- | _ -> assert false) (* there must be at least an hypothesis *)
- | _ -> assert false (* rewriting cannot complete a proof *)
- in
- let general_rewrite_in x y z w = Proofview.V82.tactic (general_rewrite_in x y (EConstr.of_constr z) w) in
+ let _ = List.map (fun id -> Tacmach.New.pf_get_hyp id gl) idl in
+ let general_rewrite_in id dir cstr tac =
+ let cstr = EConstr.of_constr cstr in
+ general_rewrite_in dir AllOccurrences true ~tac:(tac, conds) false id cstr false
+ in
Tacticals.New.tclMAP (fun id ->
Tacticals.New.tclREPEAT_MAIN (Proofview.tclPROGRESS
(List.fold_left (fun tac bas ->
diff --git a/tactics/btermdn.mli b/tactics/btermdn.mli
index 2a5e7c3458..27f624f716 100644
--- a/tactics/btermdn.mli
+++ b/tactics/btermdn.mli
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Term
open Pattern
open Names
diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml
index ea19660931..2d6dffdd23 100644
--- a/tactics/class_tactics.ml
+++ b/tactics/class_tactics.ml
@@ -18,9 +18,7 @@ open Names
open Term
open Termops
open EConstr
-open Reduction
open Proof_type
-open Tacticals
open Tacmach
open Tactics
open Clenv
@@ -221,18 +219,22 @@ let auto_unif_flags freeze st =
resolve_evars = false
}
-let e_give_exact flags poly (c,clenv) gl =
+let e_give_exact flags poly (c,clenv) =
+ let open Tacmach.New in
+ Proofview.Goal.s_enter { s_enter = begin fun gl ->
+ let sigma = project gl in
let (c, _, _) = c in
- let c, gl =
+ let c, sigma =
if poly then
let clenv', subst = Clenv.refresh_undefined_univs clenv in
- let evd = evars_reset_evd ~with_conv_pbs:true gl.sigma clenv'.evd in
+ let evd = evars_reset_evd ~with_conv_pbs:true sigma clenv'.evd in
let c = Vars.subst_univs_level_constr subst c in
- c, {gl with sigma = evd}
- else c, gl
+ c, evd
+ else c, sigma
in
- let t1 = pf_unsafe_type_of gl c in
- Proofview.V82.of_tactic (Clenvtac.unify ~flags t1 <*> exact_no_check c) gl
+ let (sigma, t1) = Typing.type_of (pf_env gl) sigma c in
+ Sigma.Unsafe.of_pair (Clenvtac.unify ~flags t1 <*> exact_no_check c, sigma)
+ end }
let unify_e_resolve poly flags = { enter = begin fun gls (c,_,clenv) ->
let clenv', c = connect_hint_clenv poly c clenv gls in
@@ -353,12 +355,12 @@ let shelve_dependencies gls =
let hintmap_of sigma hdc secvars concl =
match hdc with
- | None -> fun db -> Hint_db.map_none secvars db
+ | None -> fun db -> Hint_db.map_none ~secvars db
| Some hdc ->
fun db ->
if Hint_db.use_dn db then (* Using dnet *)
- Hint_db.map_eauto sigma secvars hdc concl db
- else Hint_db.map_existential sigma secvars hdc concl db
+ Hint_db.map_eauto sigma ~secvars hdc concl db
+ else Hint_db.map_existential sigma ~secvars hdc concl db
(** Hack to properly solve dependent evars that are typeclasses *)
let rec e_trivial_fail_db only_classes db_list local_db secvars =
@@ -455,15 +457,14 @@ and e_my_find_search db_list local_db secvars hdc complete only_classes sigma co
{ enter = fun gl -> unify_resolve_refine poly flags gl (c,None,clenv) } in
Tacticals.New.tclTHEN tac Proofview.shelve_unifiable
else
- Proofview.V82.tactic (e_give_exact flags poly (c,clenv))
+ e_give_exact flags poly (c,clenv)
| Res_pf_THEN_trivial_fail (term,cl) ->
let fst = with_prods nprods poly (term,cl) (unify_e_resolve poly flags) in
let snd = if complete then Tacticals.New.tclIDTAC
else e_trivial_fail_db only_classes db_list local_db secvars in
Tacticals.New.tclTHEN fst snd
| Unfold_nth c ->
- let tac = Proofview.V82.of_tactic (unfold_in_concl [AllOccurrences,c]) in
- Proofview.V82.tactic (tclWEAK_PROGRESS tac)
+ Proofview.tclPROGRESS (unfold_in_concl [AllOccurrences,c])
| Extern tacast -> conclPattern concl p tacast
in
let tac = run_hint t tac in
@@ -590,7 +591,7 @@ let make_resolve_hyp env sigma st flags only_classes pri decl =
info.Vernacexpr.hint_pattern }
in
make_resolves env sigma ~name:(PathHints path)
- (true,false,Flags.is_verbose()) info false
+ (true,false,not !Flags.quiet) info false
(IsConstr (EConstr.of_constr c,Univ.ContextSet.empty)))
hints)
else []
@@ -1216,7 +1217,6 @@ module Search = struct
let intro_tac info kont gl =
let open Proofview in
- let open Proofview.Notations in
let env = Goal.env gl in
let sigma = Goal.sigma gl in
let s = Sigma.to_evar_map sigma in
@@ -1254,7 +1254,6 @@ module Search = struct
let search_tac_gl ?st only_classes dep hints depth i sigma gls gl :
unit Proofview.tactic =
let open Proofview in
- let open Proofview.Notations in
if false (* In 8.6, still allow non-class goals only_classes && not (is_class_type sigma (Goal.concl gl)) *) then
Tacticals.New.tclZEROMSG (str"Not a subgoal for a class")
else
@@ -1614,9 +1613,11 @@ let not_evar c =
| Evar _ -> Tacticals.New.tclFAIL 0 (str"Evar")
| _ -> Proofview.tclUNIT ()
-let is_ground c gl =
- if Evarutil.is_ground_term (project gl) c then tclIDTAC gl
- else tclFAIL 0 (str"Not ground") gl
+let is_ground c =
+ let open Tacticals.New in
+ Proofview.tclEVARMAP >>= fun sigma ->
+ if Evarutil.is_ground_term sigma c then tclIDTAC
+ else tclFAIL 0 (str"Not ground")
let autoapply c i =
let open Proofview.Notations in
diff --git a/tactics/class_tactics.mli b/tactics/class_tactics.mli
index a38be5972f..c5731e3779 100644
--- a/tactics/class_tactics.mli
+++ b/tactics/class_tactics.mli
@@ -9,9 +9,7 @@
(** This files implements typeclasses eauto *)
open Names
-open Constr
open EConstr
-open Tacmach
val catchable : exn -> bool
@@ -33,7 +31,7 @@ val head_of_constr : Id.t -> constr -> unit Proofview.tactic
val not_evar : constr -> unit Proofview.tactic
-val is_ground : constr -> tactic
+val is_ground : constr -> unit Proofview.tactic
val autoapply : constr -> Hints.hint_db_name -> unit Proofview.tactic
diff --git a/tactics/contradiction.mli b/tactics/contradiction.mli
index 510b135b0a..2cf5a68298 100644
--- a/tactics/contradiction.mli
+++ b/tactics/contradiction.mli
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Term
open EConstr
open Misctypes
diff --git a/tactics/dnet.mli b/tactics/dnet.mli
index 9f29c60b60..565a916f8e 100644
--- a/tactics/dnet.mli
+++ b/tactics/dnet.mli
@@ -26,7 +26,7 @@
distincts, or you'll get unexpected behaviours.
Warning 2: This structure is perfect, i.e. the set of candidates
- returned is equal to the set of solutions. Beware of DeBruijn
+ returned is equal to the set of solutions. Beware of de Bruijn
shifts and sorts subtyping though (which makes the comparison not
symmetric, see term_dnet.ml).
diff --git a/tactics/eauto.mli b/tactics/eauto.mli
index e2006ac1e3..c952f4e721 100644
--- a/tactics/eauto.mli
+++ b/tactics/eauto.mli
@@ -6,9 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Term
open EConstr
-open Proof_type
open Hints
open Tactypes
diff --git a/tactics/elim.ml b/tactics/elim.ml
index e37ec6bce2..855cb206fe 100644
--- a/tactics/elim.ml
+++ b/tactics/elim.ml
@@ -8,7 +8,6 @@
open Util
open Names
-open Term
open Termops
open EConstr
open Inductiveops
diff --git a/tactics/elim.mli b/tactics/elim.mli
index dc1af79ba0..fb7cc7b838 100644
--- a/tactics/elim.mli
+++ b/tactics/elim.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open EConstr
open Tacticals
open Misctypes
diff --git a/tactics/eqdecide.ml b/tactics/eqdecide.ml
index bac3980d2b..641929a77b 100644
--- a/tactics/eqdecide.ml
+++ b/tactics/eqdecide.ml
@@ -25,7 +25,6 @@ open Constr_matching
open Misctypes
open Tactypes
open Hipattern
-open Pretyping
open Proofview.Notations
open Tacmach.New
open Coqlib
@@ -67,9 +66,26 @@ let choose_noteq eqonleft =
else
left_with_bindings false Misctypes.NoBindings
-let mkBranches c1 c2 =
+open Sigma.Notations
+
+(* A surgical generalize which selects the right occurrences by hand *)
+(* This prevents issues where c2 is also a subterm of c1 (see e.g. #5449) *)
+
+let generalize_right mk typ c1 c2 =
+ Proofview.Goal.enter { Proofview.Goal.enter = begin fun gl ->
+ let env = Proofview.Goal.env gl in
+ let store = Proofview.Goal.extra gl in
+ Refine.refine ~unsafe:true { Sigma.run = begin fun sigma ->
+ let na = Name (next_name_away_with_default "x" Anonymous (Termops.ids_of_context env)) in
+ let newconcl = mkProd (na, typ, mk typ c1 (mkRel 1)) in
+ let Sigma (x, sigma, p) = Evarutil.new_evar env sigma ~principal:true ~store newconcl in
+ Sigma (mkApp (x, [|c2|]), sigma, p)
+ end }
+ end }
+
+let mkBranches (eqonleft,mk,c1,c2,typ) =
tclTHENLIST
- [generalize [c2];
+ [generalize_right mk typ c1 c2;
Simple.elim c1;
intros;
onLastHyp Simple.case;
@@ -145,15 +161,32 @@ let diseqCase hyps eqonleft =
open Proofview.Notations
-(* spiwack: a small wrapper around [Hipattern]. *)
+(* spiwack: a PatternMatchingFailure wrapper around [Hipattern]. *)
let match_eqdec sigma c =
- try Proofview.tclUNIT (match_eqdec sigma c)
+ try
+ let (eqonleft,_,c1,c2,ty) = match_eqdec sigma c in
+ let (op,eq1,noteq,eq2) =
+ match EConstr.kind sigma c with
+ | App (op,[|ty1;ty2|]) ->
+ let ty1, ty2 = if eqonleft then ty1, ty2 else ty2, ty1 in
+ (match EConstr.kind sigma ty1, EConstr.kind sigma ty2 with
+ | App (eq1,_), App (noteq,[|neq|]) ->
+ (match EConstr.kind sigma neq with
+ | App (eq2,_) -> op,eq1,noteq,eq2
+ | _ -> assert false)
+ | _ -> assert false)
+ | _ -> assert false in
+ let mk t x y =
+ let eq = mkApp (eq1,[|t;x;y|]) in
+ let neq = mkApp (noteq,[|mkApp (eq2,[|t;x;y|])|]) in
+ if eqonleft then mkApp (op,[|eq;neq|]) else mkApp (op,[|neq;eq|]) in
+ Proofview.tclUNIT (eqonleft,mk,c1,c2,ty)
with PatternMatchingFailure -> Proofview.tclZERO PatternMatchingFailure
(* /spiwack *)
-let rec solveArg hyps eqonleft op largs rargs = match largs, rargs with
+let rec solveArg hyps eqonleft mk largs rargs = match largs, rargs with
| [], [] ->
tclTHENLIST [
choose_eq eqonleft;
@@ -163,8 +196,8 @@ let rec solveArg hyps eqonleft op largs rargs = match largs, rargs with
| a1 :: largs, a2 :: rargs ->
Proofview.Goal.enter { enter = begin fun gl ->
let rectype = pf_unsafe_type_of gl a1 in
- let decide = mkDecideEqGoal eqonleft op rectype a1 a2 in
- let tac hyp = solveArg (hyp :: hyps) eqonleft op largs rargs in
+ let decide = mk rectype a1 a2 in
+ let tac hyp = solveArg (hyp :: hyps) eqonleft mk largs rargs in
let subtacs =
if eqonleft then [eqCase tac;diseqCase hyps eqonleft;default_auto]
else [diseqCase hyps eqonleft;eqCase tac;default_auto] in
@@ -178,13 +211,13 @@ let solveEqBranch rectype =
Proofview.Goal.enter { enter = begin fun gl ->
let concl = pf_concl gl in
let sigma = project gl in
- match_eqdec sigma concl >>= fun (eqonleft,op,lhs,rhs,_) ->
+ match_eqdec sigma concl >>= fun (eqonleft,mk,lhs,rhs,_) ->
let (mib,mip) = Global.lookup_inductive rectype in
let nparams = mib.mind_nparams in
let getargs l = List.skipn nparams (snd (decompose_app sigma l)) in
let rargs = getargs rhs
and largs = getargs lhs in
- solveArg [] eqonleft op largs rargs
+ solveArg [] eqonleft mk largs rargs
end }
end
begin function (e, info) -> match e with
@@ -204,14 +237,14 @@ let decideGralEquality =
Proofview.Goal.enter { enter = begin fun gl ->
let concl = pf_concl gl in
let sigma = project gl in
- match_eqdec sigma concl >>= fun (eqonleft,_,c1,c2,typ) ->
+ match_eqdec sigma concl >>= fun (eqonleft,mk,c1,c2,typ as data) ->
let headtyp = hd_app sigma (pf_compute gl typ) in
begin match EConstr.kind sigma headtyp with
| Ind (mi,_) -> Proofview.tclUNIT mi
| _ -> tclZEROMSG (Pp.str"This decision procedure only works for inductive objects.")
end >>= fun rectype ->
(tclTHEN
- (mkBranches c1 c2)
+ (mkBranches data)
(tclORELSE (solveNoteqBranch eqonleft) (solveEqBranch rectype)))
end }
end
diff --git a/tactics/equality.ml b/tactics/equality.ml
index 7ae7446c82..cc7701ad5f 100644
--- a/tactics/equality.ml
+++ b/tactics/equality.ml
@@ -14,7 +14,6 @@ open Names
open Nameops
open Term
open Termops
-open Environ
open EConstr
open Vars
open Namegen
@@ -97,9 +96,6 @@ let _ =
(* Rewriting tactics *)
-let tclNOTSAMEGOAL tac =
- Proofview.V82.tactic (Tacticals.tclNOTSAMEGOAL (Proofview.V82.of_tactic tac))
-
type dep_proof_flag = bool (* true = support rewriting dependent proofs *)
type freeze_evars_flag = bool (* true = don't instantiate existing evars *)
@@ -268,6 +264,25 @@ let rewrite_elim with_evars frzevars cls c e =
general_elim_clause with_evars flags cls c e
end }
+let tclNOTSAMEGOAL tac =
+ let goal gl = Proofview.Goal.goal (Proofview.Goal.assume gl) in
+ Proofview.Goal.nf_enter { enter = begin fun gl ->
+ let sigma = project gl in
+ let ev = goal gl in
+ tac >>= fun () ->
+ Proofview.Goal.goals >>= fun gls ->
+ let check accu gl' =
+ gl' >>= fun gl' ->
+ let accu = accu || Goal.V82.same_goal sigma ev (project gl') (goal gl') in
+ Proofview.tclUNIT accu
+ in
+ Proofview.Monad.List.fold_left check false gls >>= fun has_same ->
+ if has_same then
+ tclZEROMSG (str"Tactic generated a subgoal identical to the original goal.")
+ else
+ Proofview.tclUNIT ()
+ end }
+
(* Ad hoc asymmetric general_elim_clause *)
let general_elim_clause with_evars frzevars cls rew elim =
let open Pretype_errors in
@@ -642,8 +657,8 @@ let replace_using_leibniz clause c1 c2 l2r unsafe try_prove_eq_opt =
| Some evd ->
let e = build_coq_eq () in
let sym = build_coq_eq_sym () in
- Tacticals.New.pf_constr_of_global sym (fun sym ->
- Tacticals.New.pf_constr_of_global e (fun e ->
+ Tacticals.New.pf_constr_of_global sym >>= fun sym ->
+ Tacticals.New.pf_constr_of_global e >>= fun e ->
let eq = applist (e, [t1;c1;c2]) in
tclTHENLAST
(replace_core clause l2r eq)
@@ -651,7 +666,7 @@ let replace_using_leibniz clause c1 c2 l2r unsafe try_prove_eq_opt =
[assumption;
tclTHEN (apply sym) assumption;
try_prove_eq
- ])))
+ ])
end }
let replace c1 c2 =
diff --git a/tactics/equality.mli b/tactics/equality.mli
index 5467b4af25..d979c580aa 100644
--- a/tactics/equality.mli
+++ b/tactics/equality.mli
@@ -8,7 +8,6 @@
(*i*)
open Names
-open Term
open Evd
open EConstr
open Environ
diff --git a/tactics/hints.ml b/tactics/hints.ml
index 77ed4330c1..c5bacc5a20 100644
--- a/tactics/hints.ml
+++ b/tactics/hints.ml
@@ -6,8 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-module CVars = Vars
-
open Pp
open Util
open CErrors
@@ -1160,7 +1158,7 @@ let add_resolves env sigma clist local dbnames =
(fun dbname ->
let r =
List.flatten (List.map (fun (pri, poly, hnf, path, gr) ->
- make_resolves env sigma (true,hnf,Flags.is_verbose())
+ make_resolves env sigma (true,hnf,not !Flags.quiet)
pri poly ~name:path gr) clist)
in
let hint = make_hint ~local dbname (AddHints r) in
@@ -1238,18 +1236,15 @@ let prepare_hint check (poly,local) env init (sigma,c) =
(* We re-abstract over uninstantiated evars and universes.
It is actually a bit stupid to generalize over evars since the first
thing make_resolves will do is to re-instantiate the products *)
- let sigma, subst = Evd.nf_univ_variables sigma in
+ let sigma, _ = Evd.nf_univ_variables sigma in
let c = Evarutil.nf_evar sigma c in
- let c = EConstr.Unsafe.to_constr c in
- let c = CVars.subst_univs_constr subst c in
- let c = EConstr.of_constr c in
let c = drop_extra_implicit_args sigma c in
let vars = ref (collect_vars sigma c) in
let subst = ref [] in
let rec find_next_evar c = match EConstr.kind sigma c with
| Evar (evk,args as ev) ->
(* We skip the test whether args is the identity or not *)
- let t = existential_type sigma ev in
+ let t = Evarutil.nf_evar sigma (existential_type sigma ev) in
let t = List.fold_right (fun (e,id) c -> replace_term sigma e id c) !subst t in
if not (closed0 sigma c) then
error "Hints with holes dependent on a bound variable not supported.";
@@ -1435,7 +1430,7 @@ let pr_hints_db (name,db,hintlist) =
let pr_hint_list_for_head c =
let dbs = current_db () in
let validate (name, db) =
- let hints = List.map (fun v -> 0, v) (Hint_db.map_all Id.Pred.full c db) in
+ let hints = List.map (fun v -> 0, v) (Hint_db.map_all ~secvars:Id.Pred.full c db) in
(name, db, hints)
in
let valid_dbs = List.map validate dbs in
diff --git a/tactics/hints.mli b/tactics/hints.mli
index 467fd46d53..3a0339ff57 100644
--- a/tactics/hints.mli
+++ b/tactics/hints.mli
@@ -9,7 +9,6 @@
open Pp
open Util
open Names
-open Term
open EConstr
open Environ
open Globnames
diff --git a/tactics/hipattern.ml b/tactics/hipattern.ml
index 851554b832..15b40b42d1 100644
--- a/tactics/hipattern.ml
+++ b/tactics/hipattern.ml
@@ -40,7 +40,6 @@ let mkmeta n = Nameops.make_ident "X" (Some n)
let meta1 = mkmeta 1
let meta2 = mkmeta 2
let meta3 = mkmeta 3
-let meta4 = mkmeta 4
let op2bool = function Some _ -> true | None -> false
diff --git a/tactics/hipattern.mli b/tactics/hipattern.mli
index dd09c3a4d7..82a3d47b59 100644
--- a/tactics/hipattern.mli
+++ b/tactics/hipattern.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open Evd
open EConstr
open Coqlib
diff --git a/tactics/inv.ml b/tactics/inv.ml
index 904a17417a..266cac5c7d 100644
--- a/tactics/inv.ml
+++ b/tactics/inv.ml
@@ -13,7 +13,6 @@ open Names
open Nameops
open Term
open Termops
-open Environ
open EConstr
open Vars
open Namegen
diff --git a/tactics/inv.mli b/tactics/inv.mli
index 446a62f6db..5835e763dd 100644
--- a/tactics/inv.mli
+++ b/tactics/inv.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open EConstr
open Misctypes
open Tactypes
diff --git a/tactics/leminv.ml b/tactics/leminv.ml
index daa962f1d6..83f3da30a9 100644
--- a/tactics/leminv.ml
+++ b/tactics/leminv.ml
@@ -260,22 +260,23 @@ let add_inversion_lemma_exn na com comsort bool tac =
(* Applying a given inversion lemma *)
(* ================================= *)
-let lemInv id c gls =
+let lemInv id c =
+ Proofview.Goal.enter { enter = begin fun gls ->
try
- let open Tacmach in
let clause = mk_clenv_from_env (pf_env gls) (project gls) None (c, pf_unsafe_type_of gls c) in
let clause = clenv_constrain_last_binding (EConstr.mkVar id) clause in
- Proofview.V82.of_tactic (Clenvtac.res_pf clause ~flags:(Unification.elim_flags ()) ~with_evars:false) gls
+ Clenvtac.res_pf clause ~flags:(Unification.elim_flags ()) ~with_evars:false
with
| NoSuchBinding ->
user_err
- (hov 0 (pr_econstr_env (Refiner.pf_env gls) (Refiner.project gls) c ++ spc () ++ str "does not refer to an inversion lemma."))
+ (hov 0 (pr_econstr_env (pf_env gls) (project gls) c ++ spc () ++ str "does not refer to an inversion lemma."))
| UserError (a,b) ->
user_err ~hdr:"LemInv"
(str "Cannot refine current goal with the lemma " ++
- pr_leconstr_env (Refiner.pf_env gls) (Refiner.project gls) c)
+ pr_leconstr_env (pf_env gls) (project gls) c)
+ end }
-let lemInv_gen id c = try_intros_until (fun id -> Proofview.V82.tactic (lemInv id c)) id
+let lemInv_gen id c = try_intros_until (fun id -> lemInv id c) id
let lemInvIn id c ids =
Proofview.Goal.enter { enter = begin fun gl ->
@@ -289,7 +290,7 @@ let lemInvIn id c ids =
else
(tclTHEN (tclDO nb_of_new_hyp intro) (intros_replacing ids))
in
- ((tclTHEN (tclTHEN (bring_hyps hyps) (Proofview.V82.tactic (lemInv id c)))
+ ((tclTHEN (tclTHEN (bring_hyps hyps) (lemInv id c))
(intros_replace_ids)))
end }
diff --git a/tactics/leminv.mli b/tactics/leminv.mli
index 26d4ac994b..a343fc81a7 100644
--- a/tactics/leminv.mli
+++ b/tactics/leminv.mli
@@ -7,7 +7,6 @@
(************************************************************************)
open Names
-open Term
open EConstr
open Constrexpr
open Misctypes
diff --git a/tactics/tacticals.ml b/tactics/tacticals.ml
index 90b7d6581a..c8441a8cc9 100644
--- a/tactics/tacticals.ml
+++ b/tactics/tacticals.ml
@@ -51,10 +51,8 @@ let tclAT_LEAST_ONCE = Refiner.tclAT_LEAST_ONCE
let tclFAIL = Refiner.tclFAIL
let tclFAIL_lazy = Refiner.tclFAIL_lazy
let tclDO = Refiner.tclDO
-let tclWEAK_PROGRESS = Refiner.tclWEAK_PROGRESS
let tclPROGRESS = Refiner.tclPROGRESS
let tclSHOWHYPS = Refiner.tclSHOWHYPS
-let tclNOTSAMEGOAL = Refiner.tclNOTSAMEGOAL
let tclTHENTRY = Refiner.tclTHENTRY
let tclIFTHENELSE = Refiner.tclIFTHENELSE
let tclIFTHENSELSE = Refiner.tclIFTHENSELSE
@@ -734,13 +732,11 @@ module New = struct
let case_nodep_then_using =
general_elim_then_using gl_make_case_nodep false
- let pf_constr_of_global ref tac =
- Proofview.Goal.enter { enter = begin fun gl ->
- let env = Proofview.Goal.env gl in
- let sigma = Tacmach.New.project gl in
- let (sigma, c) = Evd.fresh_global env sigma ref in
- let c = EConstr.of_constr c in
- Proofview.Unsafe.tclEVARS sigma <*> (tac c)
- end }
+ let pf_constr_of_global ref =
+ Proofview.tclEVARMAP >>= fun sigma ->
+ Proofview.tclENV >>= fun env ->
+ let (sigma, c) = Evd.fresh_global env sigma ref in
+ let c = EConstr.of_constr c in
+ Proofview.Unsafe.tclEVARS sigma <*> Proofview.tclUNIT c
end
diff --git a/tactics/tacticals.mli b/tactics/tacticals.mli
index 3b90ec514a..5a4ecbac75 100644
--- a/tactics/tacticals.mli
+++ b/tactics/tacticals.mli
@@ -44,10 +44,8 @@ val tclAT_LEAST_ONCE : tactic -> tactic
val tclFAIL : int -> std_ppcmds -> tactic
val tclFAIL_lazy : int -> std_ppcmds Lazy.t -> tactic
val tclDO : int -> tactic -> tactic
-val tclWEAK_PROGRESS : tactic -> tactic
val tclPROGRESS : tactic -> tactic
val tclSHOWHYPS : tactic -> tactic
-val tclNOTSAMEGOAL : tactic -> tactic
val tclTHENTRY : tactic -> tactic -> tactic
val tclMAP : ('a -> tactic) -> 'a list -> tactic
@@ -265,5 +263,5 @@ module New : sig
val elim_on_ba : (branch_assumptions -> unit Proofview.tactic) -> branch_args -> unit Proofview.tactic
val case_on_ba : (branch_assumptions -> unit Proofview.tactic) -> branch_args -> unit Proofview.tactic
- val pf_constr_of_global : Globnames.global_reference -> (constr -> unit Proofview.tactic) -> unit Proofview.tactic
+ val pf_constr_of_global : Globnames.global_reference -> constr Proofview.tactic
end
diff --git a/tactics/tactics.ml b/tactics/tactics.ml
index e792585822..211a7338b4 100644
--- a/tactics/tactics.ml
+++ b/tactics/tactics.ml
@@ -512,6 +512,9 @@ let rec check_mutind env sigma k cl = match EConstr.kind sigma (strip_outer_cast
else
let open Context.Rel.Declaration in
check_mutind (push_rel (LocalAssum (na, c1)) env) sigma (pred k) b
+| LetIn (na, c1, t, b) ->
+ let open Context.Rel.Declaration in
+ check_mutind (push_rel (LocalDef (na, c1, t)) env) sigma k b
| _ -> error "Not enough products."
(* Refine as a fixpoint *)
@@ -2811,20 +2814,18 @@ let generalize_goal_gen env sigma ids i ((occs,c,b),na) t cl =
mkProd_or_LetIn decl cl', sigma'
let generalize_goal gl i ((occs,c,b),na as o) (cl,sigma) =
- let env = Tacmach.pf_env gl in
- let ids = Tacmach.pf_ids_of_hyps gl in
- let sigma, t = Typing.type_of env sigma c in
- generalize_goal_gen env sigma ids i o t cl
-
-let new_generalize_goal gl i ((occs,c,b),na as o) (cl,sigma) =
- let env = Tacmach.New.pf_env gl in
- let ids = Tacmach.New.pf_ids_of_hyps gl in
+ let open Tacmach.New in
+ let env = pf_env gl in
+ let ids = pf_ids_of_hyps gl in
let sigma, t = Typing.type_of env sigma c in
generalize_goal_gen env sigma ids i o t cl
-let old_generalize_dep ?(with_let=false) c gl =
+let generalize_dep ?(with_let=false) c =
+ let open Tacmach.New in
+ let open Tacticals.New in
+ Proofview.Goal.nf_s_enter { s_enter = begin fun gl ->
let env = pf_env gl in
- let sign = pf_hyps gl in
+ let sign = Proofview.Goal.hyps gl in
let sigma = project gl in
let init_ids = ids_of_named_context (Global.named_context()) in
let seek (d:named_declaration) (toquant:named_context) =
@@ -2843,11 +2844,11 @@ let old_generalize_dep ?(with_let=false) c gl =
-> id::tothin
| _ -> tothin
in
- let cl' = it_mkNamedProd_or_LetIn (Tacmach.pf_concl gl) to_quantify in
+ let cl' = it_mkNamedProd_or_LetIn (pf_concl gl) to_quantify in
let body =
if with_let then
match EConstr.kind sigma c with
- | Var id -> id |> Tacmach.pf_get_hyp gl |> NamedDecl.get_value
+ | Var id -> id |> (fun id -> pf_get_hyp id gl) |> NamedDecl.get_value
| _ -> None
else None
in
@@ -2856,20 +2857,19 @@ let old_generalize_dep ?(with_let=false) c gl =
(** Check that the generalization is indeed well-typed *)
let (evd, _) = Typing.type_of env evd cl'' in
let args = Context.Named.to_instance mkVar to_quantify_rev in
- tclTHENLIST
- [tclEVARS evd;
- Proofview.V82.of_tactic (apply_type cl'' (if Option.is_empty body then c::args else args));
- Proofview.V82.of_tactic (clear (List.rev tothin'))]
- gl
-
-let generalize_dep ?(with_let = false) c =
- Proofview.V82.tactic (old_generalize_dep ~with_let c)
+ let tac =
+ tclTHEN
+ (apply_type cl'' (if Option.is_empty body then c::args else args))
+ (clear (List.rev tothin'))
+ in
+ Sigma.Unsafe.of_pair (tac, evd)
+ end }
(** *)
let generalize_gen_let lconstr = Proofview.Goal.s_enter { s_enter = begin fun gl ->
let env = Proofview.Goal.env gl in
let newcl, evd =
- List.fold_right_i (new_generalize_goal gl) 0 lconstr
+ List.fold_right_i (generalize_goal gl) 0 lconstr
(Tacmach.New.pf_concl gl,Tacmach.New.project gl)
in
let (evd, _) = Typing.type_of env evd newcl in
@@ -4724,7 +4724,7 @@ let symmetry_red allowred =
| Some eq_data,_,_ ->
Tacticals.New.tclTHEN
(convert_concl_no_check concl DEFAULTcast)
- (Tacticals.New.pf_constr_of_global eq_data.sym apply)
+ (Tacticals.New.pf_constr_of_global eq_data.sym >>= apply)
| None,eq,eq_kind -> prove_symmetry eq eq_kind
end }
@@ -4820,8 +4820,8 @@ let transitivity_red allowred t =
Tacticals.New.tclTHEN
(convert_concl_no_check concl DEFAULTcast)
(match t with
- | None -> Tacticals.New.pf_constr_of_global eq_data.trans eapply
- | Some t -> Tacticals.New.pf_constr_of_global eq_data.trans (fun trans -> apply_list [trans;t]))
+ | None -> Tacticals.New.pf_constr_of_global eq_data.trans >>= eapply
+ | Some t -> Tacticals.New.pf_constr_of_global eq_data.trans >>= fun trans -> apply_list [trans; t])
| None,eq,eq_kind ->
match t with
| None -> Tacticals.New.tclZEROMSG (str"etransitivity not supported for this relation.")
@@ -5040,10 +5040,6 @@ end
(** Tacticals defined directly in term of Proofview *)
module New = struct
- open Proofview.Notations
-
- let exact_proof c = exact_proof c
-
open Genredexpr
open Locus
diff --git a/tactics/term_dnet.ml b/tactics/term_dnet.ml
index 2c863c42a6..726fd23b64 100644
--- a/tactics/term_dnet.ml
+++ b/tactics/term_dnet.ml
@@ -49,7 +49,7 @@ struct
| DNil
(* debug *)
- let pr_dconstr f : 'a t -> std_ppcmds = function
+ let _pr_dconstr f : 'a t -> std_ppcmds = function
| DRel -> str "*"
| DSort -> str "Sort"
| DRef _ -> str "Ref"
diff --git a/test-suite/bugs/closed/4306.v b/test-suite/bugs/closed/4306.v
new file mode 100644
index 0000000000..4aef5bb95e
--- /dev/null
+++ b/test-suite/bugs/closed/4306.v
@@ -0,0 +1,32 @@
+Require Import List.
+Require Import Arith.
+Require Import Recdef.
+Require Import Omega.
+
+Function foo (xys : (list nat * list nat)) {measure (fun xys => length (fst xys) + length (snd xys))} : list nat :=
+ match xys with
+ | (nil, _) => snd xys
+ | (_, nil) => fst xys
+ | (x :: xs', y :: ys') => match Compare_dec.nat_compare x y with
+ | Lt => x :: foo (xs', y :: ys')
+ | Eq => x :: foo (xs', ys')
+ | Gt => y :: foo (x :: xs', ys')
+ end
+ end.
+Proof.
+ intros; simpl; omega.
+ intros; simpl; omega.
+ intros; simpl; omega.
+Qed.
+
+Function bar (xys : (list nat * list nat)) {measure (fun xys => length (fst xys) + length (snd xys))} : list nat :=
+ let (xs, ys) := xys in
+ match (xs, ys) with
+ | (nil, _) => ys
+ | (_, nil) => xs
+ | (x :: xs', y :: ys') => match Compare_dec.nat_compare x y with
+ | Lt => x :: foo (xs', ys)
+ | Eq => x :: foo (xs', ys')
+ | Gt => y :: foo (xs, ys')
+ end
+ end. \ No newline at end of file
diff --git a/test-suite/bugs/closed/5321.v b/test-suite/bugs/closed/5321.v
new file mode 100644
index 0000000000..03514e23b1
--- /dev/null
+++ b/test-suite/bugs/closed/5321.v
@@ -0,0 +1,18 @@
+Definition proj1_sig_path {A} {P : A -> Prop} {u v : sig P} (p : u = v)
+ : proj1_sig u = proj1_sig v
+ := f_equal (@proj1_sig _ _) p.
+
+Definition proj2_sig_path {A} {P : A -> Prop} {u v : sig P} (p : u = v)
+ : eq_rect _ _ (proj2_sig u) _ (proj1_sig_path p) = proj2_sig v
+ := match p with eq_refl => eq_refl end.
+
+Goal forall sz : nat,
+ let sz' := sz in
+ forall pf : sz = sz',
+ let feq_refl := exist (fun x : nat => sz = x) sz' eq_refl in
+ let fpf := exist (fun x : nat => sz = x) sz' pf in feq_refl = fpf ->
+proj2_sig feq_refl = proj2_sig fpf.
+Proof.
+ intros.
+ etransitivity; [ | exact (proj2_sig_path H) ].
+ Fail clearbody fpf.
diff --git a/test-suite/bugs/closed/5377.v b/test-suite/bugs/closed/5377.v
new file mode 100644
index 0000000000..130d9f9abf
--- /dev/null
+++ b/test-suite/bugs/closed/5377.v
@@ -0,0 +1,54 @@
+Goal ((forall (t : Type) (x y : t),
+ True ->
+ x = y)) -> False.
+Proof.
+ intro HG.
+ let P := lazymatch goal with
+ | [ H : forall t x y, True -> @?P t x y
+ |- _ ]
+ => P
+ end in
+ pose (f := P).
+ unify f (fun (t : Type) (x y : t) => x = y).
+Abort.
+
+Goal True.
+Proof.
+let c := lazymatch constr:(fun (T : nat -> Type) (y : nat) (_ : T y) => y) with
+ | fun _ y _ => @?C y => C
+ end in
+pose (f := c).
+unify f (fun n : nat => n).
+Abort.
+
+Goal (forall x : nat, x = x -> x = x \/ x = x) -> True.
+Proof.
+intro.
+let P := lazymatch goal with
+| [ H : forall y, @?P y -> @?P y \/ _ |- _ ]
+ => P
+end in
+pose (f := P).
+unify f (fun x : nat => x = x).
+Abort.
+
+Goal (forall x : nat, x = x -> x = x \/ x = x) -> True.
+Proof.
+intro.
+lazymatch goal with
+| [ H : forall y, @?P y -> @?Q y \/ _ |- _ ]
+ => idtac
+end.
+Abort.
+
+Axiom eq : forall {T} (_ : T), Prop.
+
+Goal forall _ : (forall t (_ : eq t) (x : t), eq x), Prop.
+Proof.
+intro.
+let P := lazymatch goal with
+| [ H : forall t _ x, @?P t x |- _ ]
+ => P
+end in
+pose (f := P).
+Abort.
diff --git a/test-suite/bugs/closed/5435.v b/test-suite/bugs/closed/5435.v
new file mode 100644
index 0000000000..60ace5ce96
--- /dev/null
+++ b/test-suite/bugs/closed/5435.v
@@ -0,0 +1,2 @@
+Definition foo (x : nat) := Eval native_compute in x.
+
diff --git a/test-suite/bugs/closed/5449.v b/test-suite/bugs/closed/5449.v
new file mode 100644
index 0000000000..d7fc2aaa00
--- /dev/null
+++ b/test-suite/bugs/closed/5449.v
@@ -0,0 +1,6 @@
+(* An example of decide equality which was failing due to a lhs dep into the rhs *)
+
+Require Import Coq.PArith.BinPos.
+Goal forall x y, {Pos.compare_cont Gt x y = Gt} + {Pos.compare_cont Gt x y <> Gt}.
+intros.
+decide equality.
diff --git a/test-suite/bugs/closed/5460.v b/test-suite/bugs/closed/5460.v
new file mode 100644
index 0000000000..50221cdd83
--- /dev/null
+++ b/test-suite/bugs/closed/5460.v
@@ -0,0 +1,11 @@
+(* Bugs in computing dependencies in pattern-matching compilation *)
+
+Inductive A := a1 | a2.
+Inductive B := b.
+Inductive C : A -> Type := c : C a1 | d : C a2.
+Definition P (x : A) (y : C x) (z : B) : nat :=
+ match z, x, y with
+ | b, a1, c => 0
+ | b, a2, d => 0
+ | _, _, _ => 1
+ end.
diff --git a/test-suite/bugs/closed/5469.v b/test-suite/bugs/closed/5469.v
new file mode 100644
index 0000000000..fce671c754
--- /dev/null
+++ b/test-suite/bugs/closed/5469.v
@@ -0,0 +1,3 @@
+(* Some problems with the special treatment of curly braces *)
+
+Reserved Notation "'a' { x }" (at level 0, format "'a' { x }").
diff --git a/test-suite/bugs/closed/5470.v b/test-suite/bugs/closed/5470.v
new file mode 100644
index 0000000000..5b3984b6df
--- /dev/null
+++ b/test-suite/bugs/closed/5470.v
@@ -0,0 +1,3 @@
+(* This used to raise an anomaly *)
+
+Fail Reserved Notation "x +++ y" (at level 70, x binder).
diff --git a/test-suite/bugs/closed/5476.v b/test-suite/bugs/closed/5476.v
new file mode 100644
index 0000000000..b2d9d943bc
--- /dev/null
+++ b/test-suite/bugs/closed/5476.v
@@ -0,0 +1,28 @@
+Require Setoid.
+
+Goal forall (P : Prop) (T : Type) (m m' : T) (T0 T1 : Type) (P2 : forall _ :
+Prop, Prop)
+ (P0 : Set) (x0 : P0) (P1 : forall (_ : P0) (_ : T), Prop)
+ (P3 : forall (_ : forall (_ : P0) (_ : T0) (_ : Prop), Prop) (_ :
+T) (_ : Prop), Prop)
+ (o : forall _ : P0, option T1)
+ (_ : P3
+ (fun (k : P0) (_ : T0) (_ : Prop) =>
+ match o k return Prop with
+ | Some _ => True
+ | None => False
+ end) m' P) (_ : P2 (P1 x0 m))
+ (_ : forall (f : forall (_ : P0) (_ : T0) (_ : Prop), Prop) (m1 m2
+: T)
+ (k : P0) (e : T0) (_ : P2 (P1 k m1)), iff (P3 f m2 P)
+(f k e (P3 f m1 P))), False.
+Proof.
+ intros ???????????? H0 H H1.
+ rewrite H1 in H0; eauto with nocore.
+ { lazymatch goal with
+ | H : match ?X with _ => _ end |- _
+ => first [ lazymatch goal with
+ | [ H' : context[X] |- _ ] => idtac H
+ end
+ | fail 1 "could not find" X ]
+ end.
diff --git a/test-suite/bugs/closed/5501.v b/test-suite/bugs/closed/5501.v
new file mode 100644
index 0000000000..24739a3658
--- /dev/null
+++ b/test-suite/bugs/closed/5501.v
@@ -0,0 +1,21 @@
+Set Universe Polymorphism.
+
+Record Pred@{A} :=
+ { car :> Type@{A}
+ ; P : car -> Prop
+ }.
+
+Class All@{A} (A : Pred@{A}) : Type :=
+ { proof : forall (a : A), P A a
+ }.
+
+Record Pred_All@{A} : Type :=
+ { P' :> Pred@{A}
+ ; P'_All : All P'
+ }.
+
+Global Instance Pred_All_instance (A : Pred_All) : All A := P'_All A.
+
+Definition Pred_All_proof {A : Pred_All} (a : A) : P A a.
+Proof.
+solve[auto using proof].
diff --git a/test-suite/failure/proofirrelevance.v b/test-suite/failure/proofirrelevance.v
index b62f9b6867..bb9579d487 100644
--- a/test-suite/failure/proofirrelevance.v
+++ b/test-suite/failure/proofirrelevance.v
@@ -1,6 +1,5 @@
-(* This was working in version 8.1beta (bug in the Sort-polymorphism
- of inductive types), but this is inconsistent with classical logic
- in Prop *)
+(* This was working in version 8.1beta (bug in template polymorphism),
+ but this is inconsistent with classical logic in Prop *)
Inductive bool_in_prop : Type := hide : bool -> bool_in_prop
with bool : Type := true : bool | false : bool.
diff --git a/test-suite/output/PatternsInBinders.out b/test-suite/output/PatternsInBinders.out
index c012a86b01..95be04c32c 100644
--- a/test-suite/output/PatternsInBinders.out
+++ b/test-suite/output/PatternsInBinders.out
@@ -37,3 +37,5 @@ fun '(x, y) '(z, t) => swap (x, y) = (z, t)
: A * B -> B * A -> Prop
forall '(x, y) '(z, t), swap (x, y) = (z, t)
: Prop
+fun (pat : nat) '(x, y) => x + y = pat
+ : nat -> nat * nat -> Prop
diff --git a/test-suite/output/PatternsInBinders.v b/test-suite/output/PatternsInBinders.v
index 6fa357a90c..0bad472f41 100644
--- a/test-suite/output/PatternsInBinders.v
+++ b/test-suite/output/PatternsInBinders.v
@@ -64,3 +64,6 @@ Check fun '((x,y) : A*B) '(z,t) => swap (x,y) = (z,t).
Check forall '(x,y) '((z,t) : B*A), swap (x,y) = (z,t).
End Suboptimal.
+
+(** Test risk of collision for internal name *)
+Check fun pat => fun '(x,y) => x+y = pat.
diff --git a/test-suite/output/Search.out b/test-suite/output/Search.out
index 81fda176ec..7446c17d98 100644
--- a/test-suite/output/Search.out
+++ b/test-suite/output/Search.out
@@ -98,6 +98,14 @@ h: n <> newdef n
h': newdef n <> n
h: n <> newdef n
h: n <> newdef n
+h: n <> newdef n
+h': newdef n <> n
+The command has indeed failed with message:
+No such goal.
+The command has indeed failed with message:
+Query commands only support the single numbered goal selector.
+The command has indeed failed with message:
+Query commands only support the single numbered goal selector.
h: P n
h': ~ P n
h: P n
diff --git a/test-suite/output/Search.v b/test-suite/output/Search.v
index 2a0f0b407c..82096f29bf 100644
--- a/test-suite/output/Search.v
+++ b/test-suite/output/Search.v
@@ -10,11 +10,19 @@ Search (@eq _ _ _) true -false "prop" -"intro". (* andb_prop *)
Definition newdef := fun x:nat => x.
Goal forall n:nat, n <> newdef n -> newdef n <> n -> False.
- intros n h h'.
+ cut False.
+ intros _ n h h'.
Search n. (* search hypothesis *)
Search newdef. (* search hypothesis *)
Search ( _ <> newdef _). (* search hypothesis, pattern *)
Search ( _ <> newdef _) -"h'". (* search hypothesis, pattern *)
+
+ 1:Search newdef.
+ 2:Search newdef.
+
+ Fail 3:Search newdef.
+ Fail 1-2:Search newdef.
+ Fail all:Search newdef.
Abort.
Goal forall n (P:nat -> Prop), P n -> ~P n -> False.
diff --git a/test-suite/success/Case19.v b/test-suite/success/Case19.v
index c29e529783..e59828defe 100644
--- a/test-suite/success/Case19.v
+++ b/test-suite/success/Case19.v
@@ -1,5 +1,5 @@
(* This used to fail in Coq version 8.1 beta due to a non variable
- universe (issued by the inductive sort-polymorphism) being sent by
+ universe (issued by template polymorphism) being sent by
pretyping to the kernel (bug #1182) *)
Variable T : Type.
diff --git a/test-suite/success/ImplicitArguments.v b/test-suite/success/ImplicitArguments.v
index f702aa62f1..f07773f8bd 100644
--- a/test-suite/success/ImplicitArguments.v
+++ b/test-suite/success/ImplicitArguments.v
@@ -21,3 +21,9 @@ Fixpoint app {A : Type} {n m : nat} (v : vector A n) (w : vector A m) : vector A
(* Test sharing information between different hypotheses *)
Parameters (a:_) (b:a=0).
+
+(* These examples were failing due to a lifting wrongly taking let-in into account *)
+
+Definition foo6 (x:=1) : forall {n:nat}, n=n := fun n => eq_refl.
+
+Fixpoint foo7 (x:=1) (n:nat) {p:nat} {struct n} : nat.
diff --git a/test-suite/success/Notations.v b/test-suite/success/Notations.v
index 52acad7460..837f2efd06 100644
--- a/test-suite/success/Notations.v
+++ b/test-suite/success/Notations.v
@@ -121,6 +121,7 @@ Notation " |- {{ a }} b" := (a=b) (no associativity, at level 10).
Goal True.
{{ exact I. }}
Qed.
+
Check |- {{ 0 }} 0.
(* Check parsing of { and } is not affected by notations #3479 *)
@@ -135,3 +136,9 @@ Notation "" := (@nil) (only printing).
(* Check that a notation cannot be neither parsing nor printing. *)
Fail Notation "'foobarkeyword'" := (@nil) (only parsing, only printing).
+
+(* Check "where" clause for inductive types with parameters *)
+
+Reserved Notation "x === y" (at level 50).
+Inductive EQ {A} (x:A) : A -> Prop := REFL : x === x
+ where "x === y" := (EQ x y).
diff --git a/test-suite/success/all-check.v b/test-suite/success/all-check.v
new file mode 100644
index 0000000000..391bc540e4
--- /dev/null
+++ b/test-suite/success/all-check.v
@@ -0,0 +1,3 @@
+Goal True.
+Fail all:Check _.
+Abort.
diff --git a/test-suite/success/polymorphism.v b/test-suite/success/polymorphism.v
index 878875bd92..66ff55edcb 100644
--- a/test-suite/success/polymorphism.v
+++ b/test-suite/success/polymorphism.v
@@ -321,4 +321,34 @@ Definition unwrap' := fun (X : Type) (b : box X) => let (unw) := b in unw.
Fail Definition bad : False := TypeNeqSmallType.paradox (unwrap' Type (wrap _
Type)) eq_refl.
-End Hurkens'. \ No newline at end of file
+End Hurkens'.
+
+Module Anonymous.
+ Set Universe Polymorphism.
+
+ Definition defaultid := (fun x => x) : Type -> Type.
+ Definition collapseid := defaultid@{_ _}.
+ Check collapseid@{_}.
+
+ Definition anonid := (fun x => x) : Type -> Type@{_}.
+ Check anonid@{_}.
+
+ Definition defaultalg := (fun x : Type => x) (Type : Type).
+ Definition usedefaultalg := defaultalg@{_ _ _}.
+ Check usedefaultalg@{_ _}.
+
+ Definition anonalg := (fun x : Type@{_} => x) (Type : Type).
+ Check anonalg@{_ _}.
+
+ Definition unrelated@{i j} := nat.
+ Definition useunrelated := unrelated@{_ _}.
+ Check useunrelated@{_ _}.
+
+ Definition inthemiddle@{i j k} :=
+ let _ := defaultid@{i j} in
+ anonalg@{k j}.
+ (* i <= j < k *)
+ Definition collapsethemiddle := inthemiddle@{i _ j}.
+ Check collapsethemiddle@{_ _}.
+
+End Anonymous.
diff --git a/test-suite/success/record_syntax.v b/test-suite/success/record_syntax.v
index db2bbb0dc7..07a5bc0606 100644
--- a/test-suite/success/record_syntax.v
+++ b/test-suite/success/record_syntax.v
@@ -45,3 +45,11 @@ Record Foo := { foo : unit; }.
Definition foo_ := {| foo := tt; |}.
End E.
+
+Module F.
+
+Record Foo := { foo : nat * nat -> nat -> nat }.
+
+Definition foo_ := {| foo '(x,y) n := x+y+n |}.
+
+End F.
diff --git a/theories/.dir-locals.el b/theories/.dir-locals.el
new file mode 100644
index 0000000000..4e8830f6c1
--- /dev/null
+++ b/theories/.dir-locals.el
@@ -0,0 +1,4 @@
+((coq-mode . ((eval . (let ((default-directory (locate-dominating-file
+ buffer-file-name ".dir-locals.el")))
+ (setq-local coq-prog-args `("-coqlib" ,(expand-file-name "..") "-R" ,(expand-file-name ".") "Coq"))
+ (setq-local coq-prog-name (expand-file-name "../bin/coqtop")))))))
diff --git a/theories/Classes/CMorphisms.v b/theories/Classes/CMorphisms.v
index 1cfca41692..74ca5d4c8a 100644
--- a/theories/Classes/CMorphisms.v
+++ b/theories/Classes/CMorphisms.v
@@ -1,4 +1,4 @@
-(* -*- coding: utf-8 -*- *)
+(* -*- coding: utf-8; coq-prog-args: ("-coqlib" "../.." "-R" ".." "Coq" "-top" "Coq.Classes.CMorphisms") -*- *)
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)
diff --git a/theories/Classes/Morphisms.v b/theories/Classes/Morphisms.v
index 06511ace57..6396e5390a 100644
--- a/theories/Classes/Morphisms.v
+++ b/theories/Classes/Morphisms.v
@@ -1,4 +1,4 @@
-(* -*- coding: utf-8 -*- *)
+(* -*- coding: utf-8; coq-prog-args: ("-coqlib" "../.." "-R" ".." "Coq" "-top" "Coq.Classes.Morphisms") -*- *)
(************************************************************************)
(* v * The Coq Proof Assistant / The Coq Development Team *)
(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)
diff --git a/theories/Init/Datatypes.v b/theories/Init/Datatypes.v
index 11d80dbc33..41e1fea61d 100644
--- a/theories/Init/Datatypes.v
+++ b/theories/Init/Datatypes.v
@@ -65,7 +65,7 @@ Infix "&&" := andb : bool_scope.
Lemma andb_prop : forall a b:bool, andb a b = true -> a = true /\ b = true.
Proof.
- destruct a; destruct b; intros; split; try (reflexivity || discriminate).
+ destruct a, b; repeat split; assumption.
Qed.
Hint Resolve andb_prop: bool.
diff --git a/theories/Init/Logic.v b/theories/Init/Logic.v
index 9b58c524e4..3eefe9a849 100644
--- a/theories/Init/Logic.v
+++ b/theories/Init/Logic.v
@@ -223,7 +223,7 @@ Proof.
Qed.
(** [(IF_then_else P Q R)], written [IF P then Q else R] denotes
- either [P] and [Q], or [~P] and [Q] *)
+ either [P] and [Q], or [~P] and [R] *)
Definition IF_then_else (P Q R:Prop) := P /\ Q \/ ~ P /\ R.
@@ -262,9 +262,9 @@ Notation "'exists' x .. y , p" := (ex (fun x => .. (ex (fun y => p)) ..))
Notation "'exists2' x , p & q" := (ex2 (fun x => p) (fun x => q))
(at level 200, x ident, p at level 200, right associativity) : type_scope.
-Notation "'exists2' x : t , p & q" := (ex2 (fun x:t => p) (fun x:t => q))
- (at level 200, x ident, t at level 200, p at level 200, right associativity,
- format "'[' 'exists2' '/ ' x : t , '/ ' '[' p & '/' q ']' ']'")
+Notation "'exists2' x : A , p & q" := (ex2 (A:=A) (fun x => p) (fun x => q))
+ (at level 200, x ident, A at level 200, p at level 200, right associativity,
+ format "'[' 'exists2' '/ ' x : A , '/ ' '[' p & '/' q ']' ']'")
: type_scope.
(** Derived rules for universal quantification *)
@@ -609,6 +609,11 @@ Proof.
destruct 1; auto.
Qed.
+Lemma inhabited_covariant (A B : Type) : (A -> B) -> inhabited A -> inhabited B.
+Proof.
+ intros f [x];exact (inhabits (f x)).
+Qed.
+
(** Declaration of stepl and stepr for eq and iff *)
Lemma eq_stepl : forall (A : Type) (x y z : A), x = y -> x = z -> z = y.
diff --git a/theories/Init/Specif.v b/theories/Init/Specif.v
index 2cc2ecbc20..43a441fc51 100644
--- a/theories/Init/Specif.v
+++ b/theories/Init/Specif.v
@@ -207,6 +207,17 @@ Definition sig2_eta {A P Q} (p : { a : A | P a & Q a })
: p = exist2 _ _ (proj1_sig (sig_of_sig2 p)) (proj2_sig (sig_of_sig2 p)) (proj3_sig p).
Proof. destruct p; reflexivity. Defined.
+(** [exists x : A, B] is equivalent to [inhabited {x : A | B}] *)
+Lemma exists_to_inhabited_sig {A P} : (exists x : A, P x) -> inhabited {x : A | P x}.
+Proof.
+ intros [x y]. exact (inhabits (exist _ x y)).
+Qed.
+
+Lemma inhabited_sig_to_exists {A P} : inhabited {x : A | P x} -> exists x : A, P x.
+Proof.
+ intros [[x y]];exists x;exact y.
+Qed.
+
(** [sumbool] is a boolean type equipped with the justification of
their value *)
diff --git a/theories/Init/Tactics.v b/theories/Init/Tactics.v
index 5d1e87ae0c..7a846cd1b3 100644
--- a/theories/Init/Tactics.v
+++ b/theories/Init/Tactics.v
@@ -236,3 +236,10 @@ Tactic Notation "clear" "dependent" hyp(h) :=
Tactic Notation "revert" "dependent" hyp(h) :=
generalize dependent h.
+
+(** Provide an error message for dependent induction that reports an import is
+required to use it. Importing Coq.Program.Equality will shadow this notation
+with the actual [dependent induction] tactic. *)
+
+Tactic Notation "dependent" "induction" ident(H) :=
+ fail "To use dependent induction, first [Require Import Coq.Program.Equality.]".
diff --git a/theories/Init/_CoqProject b/theories/Init/_CoqProject
new file mode 100644
index 0000000000..bff79d34bf
--- /dev/null
+++ b/theories/Init/_CoqProject
@@ -0,0 +1,2 @@
+-R .. Coq
+-arg -noinit
diff --git a/theories/Logic/ChoiceFacts.v b/theories/Logic/ChoiceFacts.v
index 07e8b6ef8d..116897f4ce 100644
--- a/theories/Logic/ChoiceFacts.v
+++ b/theories/Logic/ChoiceFacts.v
@@ -8,94 +8,9 @@
(************************************************************************)
(** Some facts and definitions concerning choice and description in
- intuitionistic logic.
-
-We investigate the relations between the following choice and
-description principles
-
-- AC_rel = relational form of the (non extensional) axiom of choice
- (a "set-theoretic" axiom of choice)
-- AC_fun = functional form of the (non extensional) axiom of choice
- (a "type-theoretic" axiom of choice)
-- DC_fun = functional form of the dependent axiom of choice
-- ACw_fun = functional form of the countable axiom of choice
-- AC! = functional relation reification
- (known as axiom of unique choice in topos theory,
- sometimes called principle of definite description in
- the context of constructive type theory, sometimes
- called axiom of no choice)
-
-- AC_fun_repr = functional choice of a representative in an equivalence class
-- AC_fun_setoid_gen = functional form of the general form of the (so-called
- extensional) axiom of choice over setoids
-- AC_fun_setoid = functional form of the (so-called extensional) axiom of
- choice from setoids
-- AC_fun_setoid_simple = functional form of the (so-called extensional) axiom of
- choice from setoids on locally compatible relations
-
-- GAC_rel = guarded relational form of the (non extensional) axiom of choice
-- GAC_fun = guarded functional form of the (non extensional) axiom of choice
-- GAC! = guarded functional relation reification
-
-- OAC_rel = "omniscient" relational form of the (non extensional) axiom of choice
-- OAC_fun = "omniscient" functional form of the (non extensional) axiom of choice
- (called AC* in Bell [[Bell]])
-- OAC!
-
-- ID_iota = intuitionistic definite description
-- ID_epsilon = intuitionistic indefinite description
-
-- D_iota = (weakly classical) definite description principle
-- D_epsilon = (weakly classical) indefinite description principle
-
-- PI = proof irrelevance
-- IGP = independence of general premises
- (an unconstrained generalisation of the constructive principle of
- independence of premises)
-- Drinker = drinker's paradox (small form)
- (called Ex in Bell [[Bell]])
-- EM = excluded-middle
-
-- Ext_pred_repr = choice of a representative among extensional predicates
-- Ext_pred = extensionality of predicates
-- Ext_fun_prop_repr = choice of a representative among extensional functions to Prop
-
-We let also
-
-- IPL_2 = 2nd-order impredicative minimal predicate logic (with ex. quant.)
-- IPL^2 = 2nd-order functional minimal predicate logic (with ex. quant.)
-- IPL_2^2 = 2nd-order impredicative, 2nd-order functional minimal pred. logic (with ex. quant.)
-
-with no prerequisite on the non-emptiness of domains
-
-Table of contents
-
-1. Definitions
-
-2. IPL_2^2 |- AC_rel + AC! = AC_fun
-
-3.1. typed IPL_2 + Sigma-types + PI |- AC_rel = GAC_rel and IPL_2 |- AC_rel + IGP -> GAC_rel and IPL_2 |- GAC_rel = OAC_rel
-
-3.2. IPL^2 |- AC_fun + IGP = GAC_fun = OAC_fun = AC_fun + Drinker
-
-3.3. D_iota -> ID_iota and D_epsilon <-> ID_epsilon + Drinker
-
-4. Derivability of choice for decidable relations with well-ordered codomain
-
-5. Equivalence of choices on dependent or non dependent functional types
-
-6. Non contradiction of constructive descriptions wrt functional choices
-
-7. Definite description transports classical logic to the computational world
-
-8. Choice -> Dependent choice -> Countable choice
-
-9.1. AC_fun_ext = AC_fun + Ext_fun_repr + EM
-
-9.2. AC_fun_ext = AC_fun + Ext_prop_fun_repr + PI
-
-References:
-
+ intuitionistic logic. *)
+(** * References: *)
+(**
[[Bell]] John L. Bell, Choice principles in intuitionistic set theory,
unpublished.
@@ -133,47 +48,75 @@ Variable P:A->Prop.
(** ** Constructive choice and description *)
-(** AC_rel *)
+(** AC_rel = relational form of the (non extensional) axiom of choice
+ (a "set-theoretic" axiom of choice) *)
Definition RelationalChoice_on :=
forall R:A->B->Prop,
(forall x : A, exists y : B, R x y) ->
(exists R' : A->B->Prop, subrelation R' R /\ forall x, exists! y, R' x y).
-(** AC_fun *)
+(** AC_fun = functional form of the (non extensional) axiom of choice
+ (a "type-theoretic" axiom of choice) *)
(* Note: This is called Type-Theoretic Description Axiom (TTDA) in
[[Werner97]] (using a non-standard meaning of "description"). This
is called intensional axiom of choice (AC_int) in [[Carlström04]] *)
+Definition FunctionalChoice_on_rel (R:A->B->Prop) :=
+ (forall x:A, exists y : B, R x y) ->
+ exists f : A -> B, (forall x:A, R x (f x)).
+
Definition FunctionalChoice_on :=
forall R:A->B->Prop,
(forall x : A, exists y : B, R x y) ->
(exists f : A->B, forall x : A, R x (f x)).
-(** DC_fun *)
+(** AC_fun_dep = functional form of the (non extensional) axiom of
+ choice, with dependent functions *)
+Definition DependentFunctionalChoice_on (A:Type) (B:A -> Type) :=
+ forall R:forall x:A, B x -> Prop,
+ (forall x:A, exists y : B x, R x y) ->
+ (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+
+(** AC_trunc = axiom of choice for propositional truncations
+ (truncation and quantification commute) *)
+Definition InhabitedForallCommute_on (A : Type) (B : A -> Type) :=
+ (forall x, inhabited (B x)) -> inhabited (forall x, B x).
+
+(** DC_fun = functional form of the dependent axiom of choice *)
Definition FunctionalDependentChoice_on :=
forall (R:A->A->Prop),
(forall x, exists y, R x y) -> forall x0,
(exists f : nat -> A, f 0 = x0 /\ forall n, R (f n) (f (S n))).
-(** ACw_fun *)
+(** ACw_fun = functional form of the countable axiom of choice *)
Definition FunctionalCountableChoice_on :=
forall (R:nat->A->Prop),
(forall n, exists y, R n y) ->
(exists f : nat -> A, forall n, R n (f n)).
-(** AC! or Functional Relation Reification (known as Axiom of Unique Choice
- in topos theory; also called principle of definite description *)
+(** AC! = functional relation reification
+ (known as axiom of unique choice in topos theory,
+ sometimes called principle of definite description in
+ the context of constructive type theory, sometimes
+ called axiom of no choice) *)
Definition FunctionalRelReification_on :=
forall R:A->B->Prop,
(forall x : A, exists! y : B, R x y) ->
(exists f : A->B, forall x : A, R x (f x)).
-(** AC_fun_repr *)
+(** AC_dep! = functional relation reification, with dependent functions
+ see AC! *)
+Definition DependentFunctionalRelReification_on (A:Type) (B:A -> Type) :=
+ forall (R:forall x:A, B x -> Prop),
+ (forall x:A, exists! y : B x, R x y) ->
+ (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+
+(** AC_fun_repr = functional choice of a representative in an equivalence class *)
(* Note: This is called Type-Theoretic Choice Axiom (TTCA) in
[[Werner97]] (by reference to the extensional set-theoretic
@@ -187,7 +130,8 @@ Definition RepresentativeFunctionalChoice_on :=
(Equivalence R) ->
(exists f : A->A, forall x : A, (R x (f x)) /\ forall x', R x x' -> f x = f x').
-(** AC_fun_setoid *)
+(** AC_fun_setoid = functional form of the (so-called extensional) axiom of
+ choice from setoids *)
Definition SetoidFunctionalChoice_on :=
forall R : A -> A -> Prop,
@@ -197,7 +141,8 @@ Definition SetoidFunctionalChoice_on :=
(forall x, exists y, T x y) ->
exists f : A -> B, forall x : A, T x (f x) /\ (forall x' : A, R x x' -> f x = f x').
-(** AC_fun_setoid_gen *)
+(** AC_fun_setoid_gen = functional form of the general form of the (so-called
+ extensional) axiom of choice over setoids *)
(* Note: This is called extensional axiom of choice (AC_ext) in
[[Carlström04]]. *)
@@ -213,7 +158,8 @@ Definition GeneralizedSetoidFunctionalChoice_on :=
exists f : A -> B,
forall x : A, T x (f x) /\ (forall x' : A, R x x' -> S (f x) (f x')).
-(** AC_fun_setoid_simple *)
+(** AC_fun_setoid_simple = functional form of the (so-called extensional) axiom of
+ choice from setoids on locally compatible relations *)
Definition SimpleSetoidFunctionalChoice_on A B :=
forall R : A -> A -> Prop,
@@ -222,19 +168,19 @@ Definition SimpleSetoidFunctionalChoice_on A B :=
(forall x, exists y, forall x', R x x' -> T x' y) ->
exists f : A -> B, forall x : A, T x (f x) /\ (forall x' : A, R x x' -> f x = f x').
-(** ID_epsilon (constructive version of indefinite description;
- combined with proof-irrelevance, it may be connected to
- Carlström's type theory with a constructive indefinite description
- operator) *)
+(** ID_epsilon = constructive version of indefinite description;
+ combined with proof-irrelevance, it may be connected to
+ Carlström's type theory with a constructive indefinite description
+ operator *)
Definition ConstructiveIndefiniteDescription_on :=
forall P:A->Prop,
(exists x, P x) -> { x:A | P x }.
-(** ID_iota (constructive version of definite description; combined
- with proof-irrelevance, it may be connected to Carlström's and
- Stenlund's type theory with a constructive definite description
- operator) *)
+(** ID_iota = constructive version of definite description;
+ combined with proof-irrelevance, it may be connected to
+ Carlström's and Stenlund's type theory with a
+ constructive definite description operator) *)
Definition ConstructiveDefiniteDescription_on :=
forall P:A->Prop,
@@ -242,7 +188,7 @@ Definition ConstructiveDefiniteDescription_on :=
(** ** Weakly classical choice and description *)
-(** GAC_rel *)
+(** GAC_rel = guarded relational form of the (non extensional) axiom of choice *)
Definition GuardedRelationalChoice_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -250,7 +196,7 @@ Definition GuardedRelationalChoice_on :=
(exists R' : A->B->Prop,
subrelation R' R /\ forall x, P x -> exists! y, R' x y).
-(** GAC_fun *)
+(** GAC_fun = guarded functional form of the (non extensional) axiom of choice *)
Definition GuardedFunctionalChoice_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -258,7 +204,7 @@ Definition GuardedFunctionalChoice_on :=
(forall x : A, P x -> exists y : B, R x y) ->
(exists f : A->B, forall x, P x -> R x (f x)).
-(** GFR_fun *)
+(** GAC! = guarded functional relation reification *)
Definition GuardedFunctionalRelReification_on :=
forall P : A->Prop, forall R : A->B->Prop,
@@ -266,27 +212,28 @@ Definition GuardedFunctionalRelReification_on :=
(forall x : A, P x -> exists! y : B, R x y) ->
(exists f : A->B, forall x : A, P x -> R x (f x)).
-(** OAC_rel *)
+(** OAC_rel = "omniscient" relational form of the (non extensional) axiom of choice *)
Definition OmniscientRelationalChoice_on :=
forall R : A->B->Prop,
exists R' : A->B->Prop,
subrelation R' R /\ forall x : A, (exists y : B, R x y) -> exists! y, R' x y.
-(** OAC_fun *)
+(** OAC_fun = "omniscient" functional form of the (non extensional) axiom of choice
+ (called AC* in Bell [[Bell]]) *)
Definition OmniscientFunctionalChoice_on :=
forall R : A->B->Prop,
inhabited B ->
exists f : A->B, forall x : A, (exists y : B, R x y) -> R x (f x).
-(** D_epsilon *)
+(** D_epsilon = (weakly classical) indefinite description principle *)
Definition EpsilonStatement_on :=
forall P:A->Prop,
inhabited A -> { x:A | (exists x, P x) -> P x }.
-(** D_iota *)
+(** D_iota = (weakly classical) definite description principle *)
Definition IotaStatement_on :=
forall P:A->Prop,
@@ -300,14 +247,20 @@ Notation RelationalChoice :=
(forall A B : Type, RelationalChoice_on A B).
Notation FunctionalChoice :=
(forall A B : Type, FunctionalChoice_on A B).
-Definition FunctionalDependentChoice :=
+Notation DependentFunctionalChoice :=
+ (forall A (B:A->Type), DependentFunctionalChoice_on B).
+Notation InhabitedForallCommute :=
+ (forall A (B : A -> Type), InhabitedForallCommute_on B).
+Notation FunctionalDependentChoice :=
(forall A : Type, FunctionalDependentChoice_on A).
-Definition FunctionalCountableChoice :=
+Notation FunctionalCountableChoice :=
(forall A : Type, FunctionalCountableChoice_on A).
Notation FunctionalChoiceOnInhabitedSet :=
(forall A B : Type, inhabited B -> FunctionalChoice_on A B).
Notation FunctionalRelReification :=
(forall A B : Type, FunctionalRelReification_on A B).
+Notation DependentFunctionalRelReification :=
+ (forall A (B:A->Type), DependentFunctionalRelReification_on B).
Notation RepresentativeFunctionalChoice :=
(forall A : Type, RepresentativeFunctionalChoice_on A).
Notation SetoidFunctionalChoice :=
@@ -341,38 +294,87 @@ Notation EpsilonStatement :=
(** Subclassical schemes *)
+(** PI = proof irrelevance *)
Definition ProofIrrelevance :=
forall (A:Prop) (a1 a2:A), a1 = a2.
+(** IGP = independence of general premises
+ (an unconstrained generalisation of the constructive principle of
+ independence of premises) *)
Definition IndependenceOfGeneralPremises :=
forall (A:Type) (P:A -> Prop) (Q:Prop),
inhabited A ->
(Q -> exists x, P x) -> exists x, Q -> P x.
+(** Drinker = drinker's paradox (small form)
+ (called Ex in Bell [[Bell]]) *)
Definition SmallDrinker'sParadox :=
forall (A:Type) (P:A -> Prop), inhabited A ->
exists x, (exists x, P x) -> P x.
+(** EM = excluded-middle *)
Definition ExcludedMiddle :=
forall P:Prop, P \/ ~ P.
(** Extensional schemes *)
+(** Ext_prop_repr = choice of a representative among extensional propositions *)
Local Notation ExtensionalPropositionRepresentative :=
(forall (A:Type),
exists h : Prop -> Prop,
forall P : Prop, (P <-> h P) /\ forall Q, (P <-> Q) -> h P = h Q).
+(** Ext_pred_repr = choice of a representative among extensional predicates *)
Local Notation ExtensionalPredicateRepresentative :=
(forall (A:Type),
exists h : (A->Prop) -> (A->Prop),
forall (P : A -> Prop), (forall x, P x <-> h P x) /\ forall Q, (forall x, P x <-> Q x) -> h P = h Q).
+(** Ext_fun_repr = choice of a representative among extensional functions *)
Local Notation ExtensionalFunctionRepresentative :=
(forall (A B:Type),
exists h : (A->B) -> (A->B),
forall (f : A -> B), (forall x, f x = h f x) /\ forall g, (forall x, f x = g x) -> h f = h g).
+(** We let also
+
+- IPL_2 = 2nd-order impredicative minimal predicate logic (with ex. quant.)
+- IPL^2 = 2nd-order functional minimal predicate logic (with ex. quant.)
+- IPL_2^2 = 2nd-order impredicative, 2nd-order functional minimal pred. logic (with ex. quant.)
+
+with no prerequisite on the non-emptiness of domains
+*)
+
+(**********************************************************************)
+(** * Table of contents *)
+
+(* This is very fragile. *)
+(**
+1. Definitions
+
+2. IPL_2^2 |- AC_rel + AC! = AC_fun
+
+3.1. typed IPL_2 + Sigma-types + PI |- AC_rel = GAC_rel and IPL_2 |- AC_rel + IGP -> GAC_rel and IPL_2 |- GAC_rel = OAC_rel
+
+3.2. IPL^2 |- AC_fun + IGP = GAC_fun = OAC_fun = AC_fun + Drinker
+
+3.3. D_iota -> ID_iota and D_epsilon <-> ID_epsilon + Drinker
+
+4. Derivability of choice for decidable relations with well-ordered codomain
+
+5. AC_fun = AC_fun_dep = AC_trunc
+
+6. Non contradiction of constructive descriptions wrt functional choices
+
+7. Definite description transports classical logic to the computational world
+
+8. Choice -> Dependent choice -> Countable choice
+
+9.1. AC_fun_setoid = AC_fun + Ext_fun_repr + EM
+
+9.2. AC_fun_setoid = AC_fun + Ext_pred_repr + PI
+ *)
+
(**********************************************************************)
(** * AC_rel + AC! = AC_fun
@@ -400,9 +402,6 @@ Proof.
apply HR'R; assumption.
Qed.
-Notation description_rel_choice_imp_funct_choice :=
- functional_rel_reification_and_rel_choice_imp_fun_choice (compat "8.6").
-
Lemma fun_choice_imp_rel_choice :
forall A B : Type, FunctionalChoice_on A B -> RelationalChoice_on A B.
Proof.
@@ -416,8 +415,6 @@ Proof.
trivial.
Qed.
-Notation funct_choice_imp_rel_choice := fun_choice_imp_rel_choice (compat "8.6").
-
Lemma fun_choice_imp_functional_rel_reification :
forall A B : Type, FunctionalChoice_on A B -> FunctionalRelReification_on A B.
Proof.
@@ -431,8 +428,6 @@ Proof.
exists f; exact H0.
Qed.
-Notation funct_choice_imp_description := fun_choice_imp_functional_rel_reification (compat "8.6").
-
Corollary fun_choice_iff_rel_choice_and_functional_rel_reification :
forall A B : Type, FunctionalChoice_on A B <->
RelationalChoice_on A B /\ FunctionalRelReification_on A B.
@@ -444,8 +439,6 @@ Proof.
intros [H H0]; exact (functional_rel_reification_and_rel_choice_imp_fun_choice H0 H).
Qed.
-Notation FunChoice_Equiv_RelChoice_and_ParamDefinDescr :=
- fun_choice_iff_rel_choice_and_functional_rel_reification (compat "8.6").
(**********************************************************************)
(** * Connection between the guarded, non guarded and omniscient choices *)
@@ -687,10 +680,6 @@ Qed.
Require Import Wf_nat.
Require Import Decidable.
-Definition FunctionalChoice_on_rel (A B:Type) (R:A->B->Prop) :=
- (forall x:A, exists y : B, R x y) ->
- exists f : A -> B, (forall x:A, R x (f x)).
-
Lemma classical_denumerable_description_imp_fun_choice :
forall A:Type,
FunctionalRelReification_on A nat ->
@@ -712,18 +701,10 @@ Proof.
Qed.
(**********************************************************************)
-(** * Choice on dependent and non dependent function types are equivalent *)
+(** * AC_fun = AC_fun_dep = AC_trunc *)
(** ** Choice on dependent and non dependent function types are equivalent *)
-Definition DependentFunctionalChoice_on (A:Type) (B:A -> Type) :=
- forall R:forall x:A, B x -> Prop,
- (forall x:A, exists y : B x, R x y) ->
- (exists f : (forall x:A, B x), forall x:A, R x (f x)).
-
-Notation DependentFunctionalChoice :=
- (forall A (B:A->Type), DependentFunctionalChoice_on B).
-
(** The easy part *)
Theorem dep_non_dep_functional_choice :
@@ -760,15 +741,34 @@ Proof.
destruct Heq using eq_indd; trivial.
Qed.
-(** ** Reification of dependent and non dependent functional relation are equivalent *)
+(** ** Functional choice and truncation choice are equivalent *)
-Definition DependentFunctionalRelReification_on (A:Type) (B:A -> Type) :=
- forall (R:forall x:A, B x -> Prop),
- (forall x:A, exists! y : B x, R x y) ->
- (exists f : (forall x:A, B x), forall x:A, R x (f x)).
+Theorem functional_choice_to_inhabited_forall_commute :
+ FunctionalChoice -> InhabitedForallCommute.
+Proof.
+ intros choose0 A B Hinhab.
+ pose proof (non_dep_dep_functional_choice choose0) as choose;clear choose0.
+ assert (Hexists : forall x, exists _ : B x, True).
+ { intros x;apply inhabited_sig_to_exists.
+ refine (inhabited_covariant _ (Hinhab x)).
+ intros y;exists y;exact I. }
+ apply choose in Hexists.
+ destruct Hexists as [f _].
+ exact (inhabits f).
+Qed.
-Notation DependentFunctionalRelReification :=
- (forall A (B:A->Type), DependentFunctionalRelReification_on B).
+Theorem inhabited_forall_commute_to_functional_choice :
+ InhabitedForallCommute -> FunctionalChoice.
+Proof.
+ intros choose A B R Hexists.
+ assert (Hinhab : forall x, inhabited {y : B | R x y}).
+ { intros x;apply exists_to_inhabited_sig;trivial. }
+ apply choose in Hinhab. destruct Hinhab as [f].
+ exists (fun x => proj1_sig (f x)).
+ exact (fun x => proj2_sig (f x)).
+Qed.
+
+(** ** Reification of dependent and non dependent functional relation are equivalent *)
(** The easy part *)
@@ -1304,3 +1304,15 @@ Proof.
apply repr_fun_choice_imp_excluded_middle.
now apply setoid_fun_choice_imp_repr_fun_choice.
Qed.
+
+(**********************************************************************)
+(** * Compatibility notations *)
+Notation description_rel_choice_imp_funct_choice :=
+ functional_rel_reification_and_rel_choice_imp_fun_choice (compat "8.6").
+
+Notation funct_choice_imp_rel_choice := fun_choice_imp_rel_choice (compat "8.6").
+
+Notation FunChoice_Equiv_RelChoice_and_ParamDefinDescr :=
+ fun_choice_iff_rel_choice_and_functional_rel_reification (compat "8.6").
+
+Notation funct_choice_imp_description := fun_choice_imp_functional_rel_reification (compat "8.6").
diff --git a/theories/Reals/DiscrR.v b/theories/Reals/DiscrR.v
index 05911cd539..7f26c1b86f 100644
--- a/theories/Reals/DiscrR.v
+++ b/theories/Reals/DiscrR.v
@@ -22,11 +22,6 @@ Proof.
intros; rewrite H; reflexivity.
Qed.
-Lemma IZR_neq : forall z1 z2:Z, z1 <> z2 -> IZR z1 <> IZR z2.
-Proof.
-intros; red; intro; elim H; apply eq_IZR; assumption.
-Qed.
-
Ltac discrR :=
try
match goal with
diff --git a/theories/Reals/RIneq.v b/theories/Reals/RIneq.v
index 7e1cc3e036..711703ad70 100644
--- a/theories/Reals/RIneq.v
+++ b/theories/Reals/RIneq.v
@@ -1926,6 +1926,17 @@ Proof.
omega.
Qed.
+Lemma IZR_neq : forall z1 z2:Z, z1 <> z2 -> IZR z1 <> IZR z2.
+Proof.
+intros; red; intro; elim H; apply eq_IZR; assumption.
+Qed.
+
+Hint Extern 0 (IZR _ <= IZR _) => apply IZR_le, Zle_bool_imp_le, eq_refl : real.
+Hint Extern 0 (IZR _ >= IZR _) => apply Rle_ge, IZR_le, Zle_bool_imp_le, eq_refl : real.
+Hint Extern 0 (IZR _ < IZR _) => apply IZR_lt, eq_refl : real.
+Hint Extern 0 (IZR _ > IZR _) => apply IZR_lt, eq_refl : real.
+Hint Extern 0 (IZR _ <> IZR _) => apply IZR_neq, Zeq_bool_neq, eq_refl : real.
+
Lemma one_IZR_lt1 : forall n:Z, -1 < IZR n < 1 -> n = 0%Z.
Proof.
intros z [H1 H2].
diff --git a/theories/Reals/Ranalysis5.v b/theories/Reals/Ranalysis5.v
index f9da88aad4..ccb4207ba0 100644
--- a/theories/Reals/Ranalysis5.v
+++ b/theories/Reals/Ranalysis5.v
@@ -15,6 +15,7 @@ Require Import RiemannInt.
Require Import SeqProp.
Require Import Max.
Require Import Omega.
+Require Import Lra.
Local Open Scope R_scope.
(** * Preliminaries lemmas *)
@@ -245,14 +246,8 @@ Lemma IVT_interv_prelim0 : forall (x y:R) (P:R->bool) (N:nat),
x <= Dichotomy_ub x y P N <= y /\ x <= Dichotomy_lb x y P N <= y.
Proof.
assert (Sublemma : forall x y lb ub, lb <= x <= ub /\ lb <= y <= ub -> lb <= (x+y) / 2 <= ub).
- intros x y lb ub Hyp.
- split.
- replace lb with ((lb + lb) * /2) by field.
- unfold Rdiv ; apply Rmult_le_compat_r ; intuition.
- now apply Rlt_le, Rinv_0_lt_compat, IZR_lt.
- replace ub with ((ub + ub) * /2) by field.
- unfold Rdiv ; apply Rmult_le_compat_r ; intuition.
- now apply Rlt_le, Rinv_0_lt_compat, IZR_lt.
+ intros x y lb ub Hyp.
+ lra.
intros x y P N x_lt_y.
induction N.
simpl ; intuition.
@@ -1029,10 +1024,7 @@ Qed.
Lemma ub_lt_2_pos : forall x ub lb, lb < x -> x < ub -> 0 < (ub-lb)/2.
Proof.
intros x ub lb lb_lt_x x_lt_ub.
- assert (T : 0 < ub - lb).
- fourier.
- unfold Rdiv ; apply Rlt_mult_inv_pos ; intuition.
-now apply IZR_lt.
+lra.
Qed.
Definition mkposreal_lb_ub (x lb ub:R) (lb_lt_x:lb<x) (x_lt_ub:x<ub) : posreal.
diff --git a/theories/Reals/Rfunctions.v b/theories/Reals/Rfunctions.v
index 99acdd0a1c..6061363331 100644
--- a/theories/Reals/Rfunctions.v
+++ b/theories/Reals/Rfunctions.v
@@ -532,6 +532,36 @@ Qed.
(*******************************)
(*i Due to L.Thery i*)
+Section PowerRZ.
+
+Local Coercion Z_of_nat : nat >-> Z.
+
+(* the following section should probably be somewhere else, but not sure where *)
+Section Z_compl.
+
+Local Open Scope Z_scope.
+
+(* Provides a way to reason directly on Z in terms of nats instead of positive *)
+Inductive Z_spec (x : Z) : Z -> Type :=
+| ZintNull : x = 0 -> Z_spec x 0
+| ZintPos (n : nat) : x = n -> Z_spec x n
+| ZintNeg (n : nat) : x = - n -> Z_spec x (- n).
+
+Lemma intP (x : Z) : Z_spec x x.
+Proof.
+ destruct x as [|p|p].
+ - now apply ZintNull.
+ - rewrite <-positive_nat_Z at 2.
+ apply ZintPos.
+ now rewrite positive_nat_Z.
+ - rewrite <-Pos2Z.opp_pos.
+ rewrite <-positive_nat_Z at 2.
+ apply ZintNeg.
+ now rewrite positive_nat_Z.
+Qed.
+
+End Z_compl.
+
Definition powerRZ (x:R) (n:Z) :=
match n with
| Z0 => 1
@@ -658,6 +688,74 @@ Proof.
auto with real.
Qed.
+Local Open Scope Z_scope.
+
+Lemma pow_powerRZ (r : R) (n : nat) :
+ (r ^ n)%R = powerRZ r (Z_of_nat n).
+Proof.
+ induction n; [easy|simpl].
+ now rewrite SuccNat2Pos.id_succ.
+Qed.
+
+Lemma powerRZ_ind (P : Z -> R -> R -> Prop) :
+ (forall x, P 0 x 1%R) ->
+ (forall x n, P (Z.of_nat n) x (x ^ n)%R) ->
+ (forall x n, P ((-(Z.of_nat n))%Z) x (Rinv (x ^ n))) ->
+ forall x (m : Z), P m x (powerRZ x m)%R.
+Proof.
+ intros ? ? ? x m.
+ destruct (intP m) as [Hm|n Hm|n Hm].
+ - easy.
+ - now rewrite <- pow_powerRZ.
+ - unfold powerRZ.
+ destruct n as [|n]; [ easy |].
+ rewrite Nat2Z.inj_succ, <- Zpos_P_of_succ_nat, Pos2Z.opp_pos.
+ now rewrite <- Pos2Z.opp_pos, <- positive_nat_Z.
+Qed.
+
+Lemma powerRZ_inv x alpha : (x <> 0)%R -> powerRZ (/ x) alpha = Rinv (powerRZ x alpha).
+Proof.
+ intros; destruct (intP alpha).
+ - now simpl; rewrite Rinv_1.
+ - now rewrite <-!pow_powerRZ, ?Rinv_pow, ?pow_powerRZ.
+ - unfold powerRZ.
+ destruct (- n).
+ + now rewrite Rinv_1.
+ + now rewrite Rinv_pow.
+ + now rewrite <-Rinv_pow.
+Qed.
+
+Lemma powerRZ_neg x : forall alpha, x <> R0 -> powerRZ x (- alpha) = powerRZ (/ x) alpha.
+Proof.
+ intros [|n|n] H ; simpl.
+ - easy.
+ - now rewrite Rinv_pow.
+ - rewrite Rinv_pow by now apply Rinv_neq_0_compat.
+ now rewrite Rinv_involutive.
+Qed.
+
+Lemma powerRZ_mult_distr :
+ forall m x y, ((0 <= m)%Z \/ (x * y <> 0)%R) ->
+ (powerRZ (x*y) m = powerRZ x m * powerRZ y m)%R.
+Proof.
+ intros m x0 y0 Hmxy.
+ destruct (intP m) as [ | | n Hm ].
+ - now simpl; rewrite Rmult_1_l.
+ - now rewrite <- !pow_powerRZ, Rpow_mult_distr.
+ - destruct Hmxy as [H|H].
+ + assert(m = 0) as -> by now omega.
+ now rewrite <- Hm, Rmult_1_l.
+ + assert(x0 <> 0)%R by now intros ->; apply H; rewrite Rmult_0_l.
+ assert(y0 <> 0)%R by now intros ->; apply H; rewrite Rmult_0_r.
+ rewrite !powerRZ_neg by assumption.
+ rewrite Rinv_mult_distr by assumption.
+ now rewrite <- !pow_powerRZ, Rpow_mult_distr.
+Qed.
+
+End PowerRZ.
+
+Local Infix "^Z" := powerRZ (at level 30, right associativity) : R_scope.
+
(*******************************)
(* For easy interface *)
(*******************************)
diff --git a/theories/Reals/Rpower.v b/theories/Reals/Rpower.v
index b8040bb4f5..0e0246cbfa 100644
--- a/theories/Reals/Rpower.v
+++ b/theories/Reals/Rpower.v
@@ -473,6 +473,20 @@ Proof.
apply exp_Ropp.
Qed.
+Lemma powerRZ_Rpower x z : (0 < x)%R -> powerRZ x z = Rpower x (IZR z).
+Proof.
+ intros Hx.
+ assert (x <> 0)%R
+ by now intros Habs; rewrite Habs in Hx; apply (Rlt_irrefl 0).
+ destruct (intP z).
+ - now rewrite Rpower_O.
+ - rewrite <- pow_powerRZ, <- Rpower_pow by assumption.
+ now rewrite INR_IZR_INZ.
+ - rewrite opp_IZR, Rpower_Ropp.
+ rewrite powerRZ_neg, powerRZ_inv by assumption.
+ now rewrite <- pow_powerRZ, <- INR_IZR_INZ, Rpower_pow.
+Qed.
+
Theorem Rle_Rpower :
forall e n m:R, 1 < e -> 0 <= n -> n <= m -> e ^R n <= e ^R m.
Proof.
diff --git a/tools/coq_makefile.ml b/tools/coq_makefile.ml
index ed89bda2cf..4875cb62bf 100644
--- a/tools/coq_makefile.ml
+++ b/tools/coq_makefile.ml
@@ -56,48 +56,48 @@ let lib_dirs =
let usage () =
- output_string stderr "Usage summary:
-
-coq_makefile .... [file.v] ... [file.ml[i4]?] ... [file.ml{lib,pack}]
- ... [any] ... [-extra[-phony] result dependencies command]
- ... [-I dir] ... [-R physicalpath logicalpath]
- ... [-Q physicalpath logicalpath] ... [VARIABLE = value]
- ... [-arg opt] ... [-opt|-byte] [-no-install] [-f file] [-o file]
- [-h] [--help]
-
-[file.v]: Coq file to be compiled
-[file.ml[i4]?]: Objective Caml file to be compiled
-[file.ml{lib,pack}]: ocamlbuild file that describes a Objective Caml
- library/module
-[any] : subdirectory that should be \"made\" and has a Makefile itself
- to do so. Very fragile and discouraged.
-[-extra result dependencies command]: add target \"result\" with command
- \"command\" and dependencies \"dependencies\". If \"result\" is not
- generic (do not contains a %), \"result\" is built by _make all_ and
- deleted by _make clean_.
-[-extra-phony result dependencies command]: add a PHONY target \"result\"
- with command \"command\" and dependencies \"dependencies\". Note that
- _-extra-phony foo bar \"\"_ is a regular way to add the target \"bar\" as
- as a dependencies of an already defined target \"foo\".
-[-I dir]: look for Objective Caml dependencies in \"dir\"
-[-R physicalpath logicalpath]: look for Coq dependencies resursively
- starting from \"physicalpath\". The logical path associated to the
- physical path is \"logicalpath\".
-[-Q physicalpath logicalpath]: look for Coq dependencies starting from
- \"physicalpath\". The logical path associated to the physical path
- is \"logicalpath\".
-[VARIABLE = value]: Add the variable definition \"VARIABLE=value\"
-[-byte]: compile with byte-code version of coq
-[-opt]: compile with native-code version of coq
-[-arg opt]: send option \"opt\" to coqc
-[-install opt]: where opt is \"user\" to force install into user directory,
- \"none\" to build a makefile with no install target or
- \"global\" to force install in $COQLIB directory
-[-f file]: take the contents of file as arguments
-[-o file]: output should go in file file
- Output file outside the current directory is forbidden.
-[-h]: print this usage summary
-[--help]: equivalent to [-h]\n";
+ output_string stderr "Usage summary:\
+\n\
+\ncoq_makefile .... [file.v] ... [file.ml[i4]?] ... [file.ml{lib,pack}]\
+\n ... [any] ... [-extra[-phony] result dependencies command]\
+\n ... [-I dir] ... [-R physicalpath logicalpath]\
+\n ... [-Q physicalpath logicalpath] ... [VARIABLE = value]\
+\n ... [-arg opt] ... [-opt|-byte] [-no-install] [-f file] [-o file]\
+\n [-h] [--help]\
+\n\
+\n[file.v]: Coq file to be compiled\
+\n[file.ml[i4]?]: Objective Caml file to be compiled\
+\n[file.ml{lib,pack}]: ocamlbuild file that describes a Objective Caml\
+\n library/module\
+\n[any] : subdirectory that should be \"made\" and has a Makefile itself\
+\n to do so. Very fragile and discouraged.\
+\n[-extra result dependencies command]: add target \"result\" with command\
+\n \"command\" and dependencies \"dependencies\". If \"result\" is not\
+\n generic (do not contains a %), \"result\" is built by _make all_ and\
+\n deleted by _make clean_.\
+\n[-extra-phony result dependencies command]: add a PHONY target \"result\"\
+\n with command \"command\" and dependencies \"dependencies\". Note that\
+\n _-extra-phony foo bar \"\"_ is a regular way to add the target \"bar\" as\
+\n as a dependencies of an already defined target \"foo\".\
+\n[-I dir]: look for Objective Caml dependencies in \"dir\"\
+\n[-R physicalpath logicalpath]: look for Coq dependencies resursively\
+\n starting from \"physicalpath\". The logical path associated to the\
+\n physical path is \"logicalpath\".\
+\n[-Q physicalpath logicalpath]: look for Coq dependencies starting from\
+\n \"physicalpath\". The logical path associated to the physical path\
+\n is \"logicalpath\".\
+\n[VARIABLE = value]: Add the variable definition \"VARIABLE=value\"\
+\n[-byte]: compile with byte-code version of coq\
+\n[-opt]: compile with native-code version of coq\
+\n[-arg opt]: send option \"opt\" to coqc\
+\n[-install opt]: where opt is \"user\" to force install into user directory,\
+\n \"none\" to build a makefile with no install target or\
+\n \"global\" to force install in $COQLIB directory\
+\n[-f file]: take the contents of file as arguments\
+\n[-o file]: output should go in file file\
+\n Output file outside the current directory is forbidden.\
+\n[-h]: print this usage summary\
+\n[--help]: equivalent to [-h]\n";
exit 1
let is_genrule r = (* generic rule (like bar%foo: ...) *)
@@ -264,8 +264,8 @@ let where_put_doc = function
then
physical_dir_of_logical_dir pr
else
- let () = prerr_string "Warning: -Q options don't have a correct common prefix,
- install-doc will put anything in $INSTALLDEFAULTROOT\n" in
+ let () = prerr_string ("Warning: -Q options don't have a correct common prefix,"
+ ^ " install-doc will put anything in $INSTALLDEFAULTROOT\n") in
"$(INSTALLDEFAULTROOT)"
|_,inc_i,((_,lp,_)::q as inc_r) ->
let pr = List.fold_left (fun a (_,b,_) -> string_prefix a b) lp q in
@@ -277,8 +277,8 @@ let where_put_doc = function
then
physical_dir_of_logical_dir pr
else
- let () = prerr_string "Warning: -R/-Q options don't have a correct common prefix,
- install-doc will put anything in $INSTALLDEFAULTROOT\n" in
+ let () = prerr_string ("Warning: -R/-Q options don't have a correct common prefix,"
+ ^ " install-doc will put anything in $INSTALLDEFAULTROOT\n") in
"$(INSTALLDEFAULTROOT)"
let install (vfiles,(mlis,ml4s,mls,mllibs,mlpacks),_,sds) inc = function
@@ -518,8 +518,8 @@ let variables is_install opt (args,defs) =
if !some_ml4file || !some_mlfile || !some_mlifile then begin
print "COQSRCLIBS?=" ;
List.iter (fun c -> print "-I \"$(COQLIB)"; print c ; print "\" \\\n") lib_dirs ;
- List.iter (fun c -> print " \\
- -I \"$(COQLIB)/"; print c; print "\"") Coq_config.plugins_dirs; print "\n";
+ List.iter (fun c -> print " \\\
+\n -I \"$(COQLIB)/"; print c; print "\"") Coq_config.plugins_dirs; print "\n";
print "ZFLAGS=$(OCAMLLIBS) $(COQSRCLIBS) -I $(CAMLP4LIB)\n\n";
print "CAMLC?=$(OCAMLFIND) ocamlc -c -rectypes -thread -safe-string\n";
print "CAMLOPTC?=$(OCAMLFIND) opt -c -rectypes -thread -safe-string\n";
@@ -529,8 +529,8 @@ let variables is_install opt (args,defs) =
print "CAMLLIB?=$(shell $(OCAMLFIND) printconf stdlib)\n";
print "GRAMMARS?=grammar.cma\n";
print "CAMLP4EXTEND=pa_extend.cmo q_MLast.cmo pa_macro.cmo\n";
- print "PP?=-pp '$(CAMLP4O) -I $(CAMLLIB) -I $(COQLIB)/grammar compat5.cmo \\
- $(CAMLP4EXTEND) $(GRAMMARS) $(CAMLP4OPTIONS) -impl'\n\n";
+ print "PP?=-pp '$(CAMLP4O) -I $(CAMLLIB) -I $(COQLIB)/grammar compat5.cmo \\\
+\n $(CAMLP4EXTEND) $(GRAMMARS) $(CAMLP4OPTIONS) -impl'\n\n";
end;
match is_install with
| Project_file.NoInstall -> ()
@@ -816,14 +816,14 @@ let all_target (vfiles, (_,_,_,_,mlpackfiles as mlfiles), sps, sds) inc =
let banner () =
print (Printf.sprintf
-"#############################################################################
-## v # The Coq Proof Assistant ##
-## <O___,, # INRIA - CNRS - LIX - LRI - PPS ##
-## \\VV/ # ##
-## // # Makefile automagically generated by coq_makefile V%s ##
-#############################################################################
-
-" (Coq_config.version ^ String.make (10 - String.length Coq_config.version) ' '))
+"#############################################################################\
+\n## v # The Coq Proof Assistant ##\
+\n## <O___,, # INRIA - CNRS - LIX - LRI - PPS ##\
+\n## \\VV/ # ##\
+\n## // # Makefile automagically generated by coq_makefile V%s ##\
+\n#############################################################################\
+\n\n"
+(Coq_config.version ^ String.make (10 - String.length Coq_config.version) ' '))
let warning () =
print "# WARNING\n#\n";
diff --git a/tools/coqc.ml b/tools/coqc.ml
index b12d48710f..552a943c8c 100644
--- a/tools/coqc.ml
+++ b/tools/coqc.ml
@@ -77,12 +77,12 @@ let parse_args () =
| ("-v"|"--version") :: _ -> Usage.version 0
| ("-where") :: _ ->
- Envars.set_coqlib (fun x -> x);
+ Envars.set_coqlib ~fail:(fun x -> x);
print_endline (Envars.coqlib ());
exit 0
| ("-config" | "--config") :: _ ->
- Envars.set_coqlib (fun x -> x);
+ Envars.set_coqlib ~fail:(fun x -> x);
Usage.print_config ();
exit 0
diff --git a/tools/coqdep.ml b/tools/coqdep.ml
index a9f1b73765..1c1c1be6aa 100644
--- a/tools/coqdep.ml
+++ b/tools/coqdep.ml
@@ -502,7 +502,7 @@ let coqdep () =
let user = coqlib//"user-contrib" in
if Sys.file_exists user then add_rec_dir_no_import add_coqlib_known user [];
List.iter (fun s -> add_rec_dir_no_import add_coqlib_known s [])
- (Envars.xdg_dirs (fun x -> Feedback.msg_warning (Pp.str x)));
+ (Envars.xdg_dirs ~warn:(fun x -> Feedback.msg_warning (Pp.str x)));
List.iter (fun s -> add_rec_dir_no_import add_coqlib_known s []) Envars.coqpath;
end;
List.iter (fun (f,d) -> add_mli_known f d ".mli") !mliAccu;
diff --git a/tools/coqdoc/output.mli b/tools/coqdoc/output.mli
index 853bc29aa4..235f2588c8 100644
--- a/tools/coqdoc/output.mli
+++ b/tools/coqdoc/output.mli
@@ -64,7 +64,6 @@ val keyword : string -> loc -> unit
val ident : string -> loc option -> unit
val sublexer : char -> loc -> unit
val sublexer_in_doc : char -> unit
-val initialize : unit -> unit
val proofbox : unit -> unit
diff --git a/tools/coqwc.mll b/tools/coqwc.mll
index b4fc738d0e..cd07d4216f 100644
--- a/tools/coqwc.mll
+++ b/tools/coqwc.mll
@@ -239,6 +239,7 @@ let process_channel ch =
if !skip_header then read_header lb;
spec lb
+[@@@ocaml.warning "-52"]
let process_file f =
try
let ch = open_in f in
@@ -251,6 +252,7 @@ let process_file f =
flush stdout; eprintf "coqwc: %s: Is a directory\n" f; flush stderr
| Sys_error s ->
flush stdout; eprintf "coqwc: %s\n" s; flush stderr
+[@@@ocaml.warning "+52"]
(*s Parsing of the command line. *)
diff --git a/toplevel/coqinit.ml b/toplevel/coqinit.ml
index ffd0d78051..2b9a04dad8 100644
--- a/toplevel/coqinit.ml
+++ b/toplevel/coqinit.ml
@@ -27,12 +27,12 @@ let set_rcfile s = rcfile := s; rcfile_specified := true
let load_rc = ref true
let no_load_rc () = load_rc := false
-let load_rcfile() =
+let load_rcfile sid =
if !load_rc then
try
if !rcfile_specified then
if CUnix.file_readable_p !rcfile then
- Vernac.load_vernac false !rcfile
+ Vernac.load_vernac false sid !rcfile
else raise (Sys_error ("Cannot read rcfile: "^ !rcfile))
else
try
@@ -43,8 +43,8 @@ let load_rcfile() =
Envars.home ~warn / "."^rcdefaultname^"."^Coq_config.version;
Envars.home ~warn / "."^rcdefaultname
] in
- Vernac.load_vernac false inferedrc
- with Not_found -> ()
+ Vernac.load_vernac false sid inferedrc
+ with Not_found -> sid
(*
Flags.if_verbose
mSGNL (str ("No coqrc or coqrc."^Coq_config.version^
@@ -55,7 +55,8 @@ let load_rcfile() =
let () = Feedback.msg_info (str"Load of rcfile failed.") in
iraise reraise
else
- Flags.if_verbose Feedback.msg_info (str"Skipping rcfile loading.")
+ (Flags.if_verbose Feedback.msg_info (str"Skipping rcfile loading.");
+ sid)
(* Recursively puts dir in the LoadPath if -nois was not passed *)
let add_stdlib_path ~unix_path ~coq_root ~with_ml =
diff --git a/toplevel/coqinit.mli b/toplevel/coqinit.mli
index 4ff87628c8..3b42289eec 100644
--- a/toplevel/coqinit.mli
+++ b/toplevel/coqinit.mli
@@ -13,7 +13,7 @@ val set_debug : unit -> unit
val set_rcfile : string -> unit
val no_load_rc : unit -> unit
-val load_rcfile : unit -> unit
+val load_rcfile : Stateid.t -> Stateid.t
val push_include : string -> Names.DirPath.t -> bool -> unit
(** [push_include phys_path log_path implicit] *)
diff --git a/toplevel/coqloop.ml b/toplevel/coqloop.ml
index 2282932d47..9a4f476bd3 100644
--- a/toplevel/coqloop.ml
+++ b/toplevel/coqloop.ml
@@ -7,11 +7,6 @@
(************************************************************************)
open Pp
-open CErrors
-open Util
-open Flags
-open Vernac
-open Pcoq
let top_stderr x =
Format.fprintf !Topfmt.err_ft "@[%a@]%!" pp_with x
@@ -24,7 +19,7 @@ type input_buffer = {
mutable str : Bytes.t; (* buffer of already read characters *)
mutable len : int; (* number of chars in the buffer *)
mutable bols : int list; (* offsets in str of beginning of lines *)
- mutable tokens : Gram.coq_parsable; (* stream of tokens *)
+ mutable tokens : Pcoq.Gram.coq_parsable; (* stream of tokens *)
mutable start : int } (* stream count of the first char of the buffer *)
(* Double the size of the buffer. *)
@@ -61,7 +56,7 @@ let prompt_char ic ibuf count =
| ll::_ -> Int.equal ibuf.len ll
| [] -> Int.equal ibuf.len 0
in
- if bol && not !print_emacs then top_stderr (str (ibuf.prompt()));
+ if bol && not !Flags.print_emacs then top_stderr (str (ibuf.prompt()));
try
let c = input_char ic in
if c == '\n' then ibuf.bols <- (ibuf.len+1) :: ibuf.bols;
@@ -78,7 +73,7 @@ let reset_input_buffer ic ibuf =
ibuf.str <- Bytes.empty;
ibuf.len <- 0;
ibuf.bols <- [];
- ibuf.tokens <- Gram.parsable (Stream.from (prompt_char ic ibuf));
+ ibuf.tokens <- Pcoq.Gram.parsable (Stream.from (prompt_char ic ibuf));
ibuf.start <- 0
(* Functions to print underlined locations from an input buffer. *)
@@ -89,7 +84,7 @@ module TopErr = struct
let get_bols_of_loc ibuf (bp,ep) =
let add_line (b,e) lines =
- if b < 0 || e < b then anomaly (Pp.str "Bad location");
+ if b < 0 || e < b then CErrors.anomaly (Pp.str "Bad location");
match lines with
| ([],None) -> ([], Some (b,e))
| (fl,oe) -> ((b,e)::fl, oe)
@@ -154,27 +149,13 @@ let valid_buffer_loc ib loc =
not (Loc.is_ghost loc) &&
let (b,e) = Loc.unloc loc in b-ib.start >= 0 && e-ib.start < ib.len && b<=e
-(* This is specific to the toplevel *)
-let pr_loc loc =
- if Loc.is_ghost loc then str"<unknown>"
- else
- let fname = loc.Loc.fname in
- if CString.equal fname "" then
- Loc.(str"Toplevel input, characters " ++ int loc.bp ++
- str"-" ++ int loc.ep ++ str":")
- else
- Loc.(str"File " ++ str "\"" ++ str fname ++ str "\"" ++
- str", line " ++ int loc.line_nb ++ str", characters " ++
- int (loc.bp-loc.bol_pos) ++ str"-" ++ int (loc.ep-loc.bol_pos) ++
- str":")
-
(* Toplevel error explanation. *)
let error_info_for_buffer ?loc buf =
Option.map (fun loc ->
let fname = loc.Loc.fname in
let hl, loc =
(* We are in the toplevel *)
- if String.equal fname "" then
+ if CString.equal fname "" then
let nloc = adjust_loc_buf buf loc in
if valid_buffer_loc buf loc then
(fnl () ++ print_highlight_location buf nloc, nloc)
@@ -182,7 +163,7 @@ let error_info_for_buffer ?loc buf =
else (mt (), nloc)
(* we are in batch mode, don't adjust location *)
else (mt (), loc)
- in pr_loc loc ++ hl
+ in Topfmt.pr_loc loc ++ hl
) loc
(* Actual printing routine *)
@@ -223,7 +204,7 @@ let make_emacs_prompt() =
let pending = Stm.get_all_proof_names() in
let pendingprompt =
List.fold_left
- (fun acc x -> acc ^ (if String.is_empty acc then "" else "|") ^ Names.Id.to_string x)
+ (fun acc x -> acc ^ (if CString.is_empty acc then "" else "|") ^ Names.Id.to_string x)
"" pending in
let proof_info = if dpth >= 0 then string_of_int dpth else "0" in
if !Flags.print_emacs then statnum ^ " |" ^ pendingprompt ^ "| " ^ proof_info ^ " < "
@@ -243,7 +224,7 @@ let top_buffer =
str = Bytes.empty;
len = 0;
bols = [];
- tokens = Gram.parsable (Stream.of_list []);
+ tokens = Pcoq.Gram.parsable (Stream.of_list []);
start = 0 }
let set_prompt prompt =
@@ -257,10 +238,10 @@ let set_prompt prompt =
let parse_to_dot =
let rec dot st = match Stream.next st with
| Tok.KEYWORD ("."|"...") -> ()
- | Tok.EOI -> raise End_of_input
+ | Tok.EOI -> raise Stm.End_of_input
| _ -> dot st
in
- Gram.Entry.of_parser "Coqtoplevel.dot" dot
+ Pcoq.Gram.Entry.of_parser "Coqtoplevel.dot" dot
(* If an error occurred while parsing, we try to read the input until a dot
token is encountered.
@@ -268,21 +249,19 @@ let parse_to_dot =
let rec discard_to_dot () =
try
- Gram.entry_parse parse_to_dot top_buffer.tokens
+ Pcoq.Gram.entry_parse parse_to_dot top_buffer.tokens
with
| Token.Error _ | CLexer.Error.E _ -> discard_to_dot ()
- | End_of_input -> raise End_of_input
+ | Stm.End_of_input -> raise Stm.End_of_input
| e when CErrors.noncritical e -> ()
-let read_sentence input =
- try
- let (loc, _ as r) = Vernac.parse_sentence input in
- CWarnings.set_current_loc loc; r
+let read_sentence sid input =
+ try Stm.parse_sentence sid input
with reraise ->
let reraise = CErrors.push reraise in
discard_to_dot ();
TopErr.print_toplevel_parse_error reraise top_buffer;
- iraise reraise
+ Exninfo.iraise reraise
(** Coqloop Console feedback handler *)
let coqloop_feed (fb : Feedback.feedback) = let open Feedback in
@@ -299,6 +278,9 @@ let coqloop_feed (fb : Feedback.feedback) = let open Feedback in
| FileDependency (_,_) -> ()
| FileLoaded (_,_) -> ()
| Custom (_,_,_) -> ()
+ (* Re-enable when we switch back to feedback-based error printing *)
+ | Message (Error,loc,msg) -> ()
+ (* TopErr.print_error_for_buffer ?loc lvl msg top_buffer *)
| Message (lvl,loc,msg) ->
TopErr.print_error_for_buffer ?loc lvl msg top_buffer
@@ -312,25 +294,28 @@ let coqloop_feed (fb : Feedback.feedback) = let open Feedback in
is caught and handled (i.e. not re-raised).
*)
-let do_vernac () =
+let do_vernac sid =
top_stderr (fnl());
- if !print_emacs then top_stderr (str (top_buffer.prompt()));
+ if !Flags.print_emacs then top_stderr (str (top_buffer.prompt()));
resynch_buffer top_buffer;
try
let input = (top_buffer.tokens, None) in
- Vernac.process_expr top_buffer.tokens (read_sentence input)
+ Vernac.process_expr sid (read_sentence sid (fst input))
with
- | End_of_input | CErrors.Quit ->
+ | Stm.End_of_input | CErrors.Quit ->
top_stderr (fnl ()); raise CErrors.Quit
| CErrors.Drop -> (* Last chance *)
if Mltop.is_ocaml_top() then raise CErrors.Drop
- else Feedback.msg_error (str "There is no ML toplevel.")
- (* Exception printing is done now by the feedback listener. *)
- (* XXX: We need this hack due to the side effects of the exception
- printer and the reliance of Stm.define on attaching crutial
- state to exceptions *)
- | any -> ignore (CErrors.(iprint (push any)))
-
+ else (Feedback.msg_error (str "There is no ML toplevel."); sid)
+ (* Exception printing should be done by the feedback listener,
+ however this is not yet ready so we rely on the exception for
+ now. *)
+ | any ->
+ let (e, info) = CErrors.push any in
+ let loc = Loc.get_loc info in
+ let msg = CErrors.iprint (e, info) in
+ TopErr.print_error_for_buffer ?loc Feedback.Error msg top_buffer;
+ sid
(** Main coq loop : read vernacular expressions until Drop is entered.
Ctrl-C is handled internally as Sys.Break instead of aborting Coq.
@@ -348,11 +333,16 @@ let loop_flush_all () =
let rec loop () =
Sys.catch_break true;
- if !Flags.print_emacs then Vernacentries.qed_display_script := false;
- Flags.coqtop_ui := true;
try
reset_input_buffer stdin top_buffer;
- while true do do_vernac(); loop_flush_all () done
+ (* Be careful to keep this loop tail-recursive *)
+ let rec vernac_loop sid =
+ let nsid = do_vernac sid in
+ loop_flush_all ();
+ vernac_loop nsid
+ (* We recover the current stateid, threading from the caller is
+ not possible due exceptions. *)
+ in vernac_loop (Stm.get_current_state ())
with
| CErrors.Drop -> ()
| CErrors.Quit -> exit 0
diff --git a/toplevel/coqloop.mli b/toplevel/coqloop.mli
index 8a34ded6d9..13e860a88a 100644
--- a/toplevel/coqloop.mli
+++ b/toplevel/coqloop.mli
@@ -6,8 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Pp
-
(** The Coq toplevel loop. *)
(** A buffer for the character read from a channel. We store the command
@@ -31,7 +29,7 @@ val coqloop_feed : Feedback.feedback -> unit
(** Parse and execute one vernac command. *)
-val do_vernac : unit -> unit
+val do_vernac : Stateid.t -> Stateid.t
(** Main entry point of Coq: read and execute vernac commands. *)
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index aca94e63d2..5687418f2d 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -8,11 +8,8 @@
open Pp
open CErrors
-open Util
open Flags
-open Names
open Libnames
-open States
open Coqinit
let () = at_exit flush_all
@@ -133,10 +130,10 @@ let engage () =
let set_batch_mode () = batch_mode := true
-let toplevel_default_name = DirPath.make [Id.of_string "Top"]
+let toplevel_default_name = Names.(DirPath.make [Id.of_string "Top"])
let toplevel_name = ref toplevel_default_name
let set_toplevel_name dir =
- if DirPath.is_empty dir then error "Need a non empty toplevel module name";
+ if Names.DirPath.is_empty dir then error "Need a non empty toplevel module name";
toplevel_name := dir
let remove_top_ml () = Mltop.remove ()
@@ -150,9 +147,9 @@ let set_inputstate s =
warn_deprecated_inputstate ();
inputstate:=s
let inputstate () =
- if not (String.is_empty !inputstate) then
+ if not (CString.is_empty !inputstate) then
let fname = Loadpath.locate_file (CUnix.make_suffix !inputstate ".coq") in
- intern_state fname
+ States.intern_state fname
let warn_deprecated_outputstate =
CWarnings.create ~name:"deprecated-outputstate" ~category:"deprecated"
@@ -164,9 +161,9 @@ let set_outputstate s =
warn_deprecated_outputstate ();
outputstate:=s
let outputstate () =
- if not (String.is_empty !outputstate) then
+ if not (CString.is_empty !outputstate) then
let fname = CUnix.make_suffix !outputstate ".coq" in
- extern_state fname
+ States.extern_state fname
let set_include d p implicit =
let p = dirpath_of_string p in
@@ -175,15 +172,15 @@ let set_include d p implicit =
let load_vernacular_list = ref ([] : (string * bool) list)
let add_load_vernacular verb s =
load_vernacular_list := ((CUnix.make_suffix s ".v"),verb) :: !load_vernacular_list
-let load_vernacular () =
- List.iter
- (fun (s,b) ->
+let load_vernacular sid =
+ List.fold_left
+ (fun sid (s,v) ->
let s = Loadpath.locate_file s in
if !Flags.beautify then
- with_option beautify_file (Vernac.load_vernac b) s
+ with_option beautify_file (Vernac.load_vernac v sid) s
else
- Vernac.load_vernac b s)
- (List.rev !load_vernacular_list)
+ Vernac.load_vernac v sid s)
+ sid (List.rev !load_vernacular_list)
let load_vernacular_obj = ref ([] : string list)
let add_vernac_obj s = load_vernacular_obj := s :: !load_vernacular_obj
@@ -218,7 +215,7 @@ let glob_opt = ref false
let add_compile verbose s =
set_batch_mode ();
- Flags.make_silent true;
+ Flags.quiet := true;
if not !glob_opt then Dumpglob.dump_to_dotglob ();
(** make the file name explicit; needed not to break up Coq loadpath stuff. *)
let s =
@@ -250,7 +247,7 @@ let set_emacs () =
if not (Option.is_empty !toploop) then
error "Flag -emacs is incompatible with a custom toplevel loop";
Flags.print_emacs := true;
- Vernacentries.qed_display_script := false;
+ Printer.enable_goal_tags_printing := true;
color := `OFF
(** Options for CoqIDE *)
@@ -296,7 +293,7 @@ let init_gc () =
between coqtop and coqc. *)
let usage () =
- Envars.set_coqlib CErrors.error;
+ Envars.set_coqlib ~fail:CErrors.error;
init_load_path ();
if !batch_mode then Usage.print_usage_coqc ()
else begin
@@ -380,7 +377,7 @@ let get_host_port opt s =
let get_error_resilience opt = function
| "on" | "all" | "yes" -> `All
| "off" | "no" -> `None
- | s -> `Only (String.split ',' s)
+ | s -> `Only (CString.split ',' s)
let get_task_list s = List.map int_of_string (Str.split (Str.regexp ",") s)
@@ -388,7 +385,7 @@ let vio_tasks = ref []
let add_vio_task f =
set_batch_mode ();
- Flags.make_silent true;
+ Flags.quiet := true;
vio_tasks := f :: !vio_tasks
let check_vio_tasks () =
@@ -402,7 +399,7 @@ let vio_files_j = ref 0
let vio_checking = ref false
let add_vio_file f =
set_batch_mode ();
- Flags.make_silent true;
+ Flags.quiet := true;
vio_files := f :: !vio_files
let set_vio_checking_j opt j =
@@ -434,10 +431,10 @@ let get_native_name s =
(** Prints info which is either an error or an anomaly and then exits
with the appropriate error code *)
-let fatal_error info anomaly =
- let msg = info ++ fnl () in
- Format.fprintf !Topfmt.err_ft "@[%a@]%!" pp_with msg;
- exit (if anomaly then 129 else 1)
+let fatal_error ?extra exn =
+ Topfmt.print_err_exn ?extra exn;
+ let exit_code = if CErrors.(is_anomaly exn || not (handled exn)) then 129 else 1 in
+ exit exit_code
let parse_args arglist =
let args = ref arglist in
@@ -567,7 +564,7 @@ let parse_args arglist =
|"-output-context" -> output_context := true
|"-profile-ltac" -> Flags.profile_ltac := true
|"-q" -> no_load_rc ()
- |"-quiet"|"-silent" -> Flags.make_silent true; Flags.make_warn false
+ |"-quiet"|"-silent" -> Flags.quiet := true; Flags.make_warn false
|"-quick" -> Flags.compilation_mode := BuildVio
|"-list-tags" -> print_tags := true
|"-time" -> Flags.time := true
@@ -600,11 +597,7 @@ let parse_args arglist =
in
try
parse ()
- with
- | UserError(_, s) as e ->
- if ismt s then exit 1
- else fatal_error (CErrors.print e) false
- | any -> fatal_error (CErrors.print any) (CErrors.is_anomaly any)
+ with any -> fatal_error any
let init_toplevel arglist =
init_gc ();
@@ -617,7 +610,7 @@ let init_toplevel arglist =
(* If we have been spawned by the Spawn module, this has to be done
* early since the master waits us to connect back *)
Spawned.init_channels ();
- Envars.set_coqlib CErrors.error;
+ Envars.set_coqlib ~fail:CErrors.error;
if !print_where then (print_endline(Envars.coqlib ()); exit(exitcode ()));
if !print_config then (Usage.print_config (); exit (exitcode ()));
if !print_tags then (print_style_tags (); exit (exitcode ()));
@@ -625,7 +618,7 @@ let init_toplevel arglist =
init_load_path ();
Option.iter Mltop.load_ml_object_raw !toploop;
let extras = !toploop_init extras in
- if not (List.is_empty extras) then begin
+ if not (CList.is_empty extras) then begin
prerr_endline ("Don't know what to do with "^String.concat " " extras);
prerr_endline "See -help for the list of supported options";
exit 1
@@ -634,29 +627,29 @@ let init_toplevel arglist =
inputstate ();
Mltop.init_known_plugins ();
engage ();
- if (not !batch_mode || List.is_empty !compile_list)
+ if (not !batch_mode || CList.is_empty !compile_list)
&& Global.env_is_initial ()
then Declaremods.start_library !toplevel_name;
init_library_roots ();
load_vernac_obj ();
require ();
Stm.init ();
- load_rcfile();
- load_vernacular ();
+ let sid = load_rcfile (Stm.get_current_state ()) in
+ (* XXX: We ignore this for now, but should be threaded to the toplevels *)
+ let _sid = load_vernacular sid in
compile_files ();
schedule_vio_checking ();
schedule_vio_compilation ();
check_vio_tasks ();
outputstate ()
with any ->
- let any = CErrors.push any in
flush_all();
- let msg =
- if !batch_mode then mt ()
- else str "Error during initialization: " ++ CErrors.iprint any ++ fnl ()
+ let extra =
+ if !batch_mode && not Stateid.(equal (Stm.get_current_state ()) dummy)
+ then None
+ else Some (str "Error during initialization: ")
in
- let is_anomaly e = CErrors.is_anomaly e || not (CErrors.handled e) in
- fatal_error msg (is_anomaly (fst any))
+ fatal_error ?extra any
end;
if !batch_mode then begin
flush_all();
diff --git a/toplevel/usage.ml b/toplevel/usage.ml
index 66f782ffbe..e457ca61d0 100644
--- a/toplevel/usage.ml
+++ b/toplevel/usage.ml
@@ -83,7 +83,7 @@ let print_usage_channel co command =
\n -m, --memory display total heap size at program exit\
\n (use environment variable\
\n OCAML_GC_STATS=\"/tmp/gclog.txt\"\
-\n for full Gc stats dump)
+\n for full Gc stats dump)\
\n -native-compiler precompile files for the native_compute machinery\
\n -h, -help, --help print this list of options\
\n";
diff --git a/toplevel/vernac.ml b/toplevel/vernac.ml
index 9917a49b42..9f6f77ef1d 100644
--- a/toplevel/vernac.ml
+++ b/toplevel/vernac.ml
@@ -13,116 +13,34 @@ open CErrors
open Util
open Flags
open Vernacexpr
+open Vernacprop
(* The functions in this module may raise (unexplainable!) exceptions.
Use the module Coqtoplevel, which catches these exceptions
(the exceptions are explained only at the toplevel). *)
-let user_error loc s = CErrors.user_err ~loc (str s)
-
-(* Navigation commands are allowed in a coqtop session but not in a .v file *)
-
-let rec is_navigation_vernac = function
- | VernacResetInitial
- | VernacResetName _
- | VernacBacktrack _
- | VernacBackTo _
- | VernacBack _
- | VernacStm _ -> true
- | VernacRedirect (_, (_,c))
- | VernacTime (_,c) ->
- is_navigation_vernac c (* Time Back* is harmless *)
- | c -> is_deep_navigation_vernac c
-
-and is_deep_navigation_vernac = function
- | VernacTimeout (_,c) | VernacFail c -> is_navigation_vernac c
- | _ -> false
-
-(* NB: Reset is now allowed again as asked by A. Chlipala *)
-
-let is_reset = function
- | VernacResetInitial | VernacResetName _ -> true
- | _ -> false
-
-let checknav_simple loc cmd =
+let checknav_simple (loc, cmd) =
if is_navigation_vernac cmd && not (is_reset cmd) then
- user_error loc "Navigation commands forbidden in files."
+ CErrors.user_err ~loc (str "Navigation commands forbidden in files.")
-let checknav_deep loc ast =
+let checknav_deep (loc, ast) =
if is_deep_navigation_vernac ast then
- user_error loc "Navigation commands forbidden in nested commands."
-
-(* When doing Load on a file, two behaviors are possible:
-
- - either the history stack is grown by only one command,
- the "Load" itself. This is mandatory for command-counting
- interfaces (CoqIDE).
-
- - either each individual sub-commands in the file is added
- to the history stack. This allows commands like Show Script
- to work across the loaded file boundary (cf. bug #2820).
-
- The best of the two could probably be combined someday,
- in the meanwhile we use a flag. *)
-
-let atomic_load = ref true
-
-let _ =
- Goptions.declare_bool_option
- { Goptions.optsync = true;
- Goptions.optdepr = false;
- Goptions.optname = "atomic registration of commands in a Load";
- Goptions.optkey = ["Atomic";"Load"];
- Goptions.optread = (fun () -> !atomic_load);
- Goptions.optwrite = ((:=) atomic_load) }
+ CErrors.user_err ~loc (str "Navigation commands forbidden in nested commands.")
let disable_drop = function
| Drop -> CErrors.error "Drop is forbidden."
| e -> e
-(* Opening and closing a channel. Open it twice when verbose: the first
- channel is used to read the commands, and the second one to print them.
- Note: we could use only one thanks to seek_in, but seeking on and on in
- the file we parse seems a bit risky to me. B.B. *)
-
-let open_file_twice_if verbosely longfname =
- let in_chan = open_utf8_file_in longfname in
- let verb_ch =
- if verbosely then Some (open_utf8_file_in longfname) else None in
- let po = Pcoq.Gram.parsable ~file:longfname (Stream.of_channel in_chan) in
- (in_chan, longfname, (po, verb_ch))
-
-let close_input in_chan (_,verb) =
- try
- close_in in_chan;
- match verb with
- | Some verb_ch -> close_in verb_ch
- | _ -> ()
- with e when CErrors.noncritical e -> ()
-
-let verbose_phrase verbch loc =
- let loc = Loc.unloc loc in
- match verbch with
- | Some ch ->
- let len = snd loc - fst loc in
- let s = Bytes.create len in
- seek_in ch (fst loc);
- really_input ch s 0 len;
- Feedback.msg_notice (str (Bytes.to_string s))
- | None -> ()
-
-exception End_of_input
-
-let parse_sentence = Flags.with_option Flags.we_are_parsing
- (fun (po, verbch) ->
- match Pcoq.Gram.entry_parse Pcoq.main_entry po with
- | Some (loc,_ as com) -> verbose_phrase verbch loc; com
- | None -> raise End_of_input)
+(* Echo from a buffer based on position.
+ XXX: Should move to utility file. *)
+let vernac_echo loc in_chan = let open Loc in
+ let len = loc.ep - loc.bp in
+ seek_in in_chan loc.bp;
+ Feedback.msg_notice @@ str @@ really_input_string in_chan len
(* vernac parses the given stream, executes interpfun on the syntax tree it
* parses, and is verbose on "primitives" commands if verbosely is true *)
-let chan_beautify = ref stdout
let beautify_suffix = ".beautified"
let set_formatter_translator ch =
@@ -184,50 +102,113 @@ let print_cmd_header loc com =
Pp.pp_with !Topfmt.std_ft (pp_cmd_header loc com);
Format.pp_print_flush !Topfmt.std_ft ()
-let rec interp_vernac po chan_beautify checknav (loc,com) =
+let pr_open_cur_subgoals () =
+ try Printer.pr_open_subgoals ()
+ with Proof_global.NoCurrentProof -> Pp.str ""
+
+let vernac_error msg =
+ Format.fprintf !Topfmt.err_ft "@[%a@]%!" Pp.pp_with msg;
+ flush_all ();
+ exit 1
+
+(* Reenable when we get back to feedback printing *)
+(* let is_end_of_input any = match any with *)
+(* Stm.End_of_input -> true *)
+(* | _ -> false *)
+
+let rec interp_vernac sid (loc,com) =
let interp = function
| VernacLoad (verbosely, fname) ->
let fname = Envars.expand_path_macros ~warn:(fun x -> Feedback.msg_warning (str x)) fname in
let fname = CUnix.make_suffix fname ".v" in
let f = Loadpath.locate_file fname in
- load_vernac verbosely f
-
- | v -> Stm.interp (Flags.is_verbose()) (loc,v)
+ load_vernac verbosely sid f
+ | v ->
+ let nsid, ntip = Stm.add ~ontop:sid (not !Flags.quiet) (loc,v) in
+
+ (* Main STM interaction *)
+ if ntip <> `NewTip then
+ anomaly (str "vernac.ml: We got an unfocus operation on the toplevel!");
+ (* Due to bug #5363 we cannot use observe here as we should,
+ it otherwise reveals bugs *)
+ (* Stm.observe nsid; *)
+
+ let check_proof = Flags.(!compilation_mode = BuildVo || not !batch_mode) in
+ if check_proof then Stm.finish ();
+
+ (* We could use a more refined criteria that depends on the
+ vernac. For now we imitate the old approach. *)
+ let hide_goals = !Flags.batch_mode || is_query v || !Flags.quiet ||
+ not (Proof_global.there_are_pending_proofs ()) in
+
+ if not hide_goals then Feedback.msg_notice (pr_open_cur_subgoals ());
+ nsid
in
try
- checknav loc com;
- if !beautify then pr_new_syntax po chan_beautify loc (Some com);
- (* XXX: This is not 100% correct if called from an IDE context *)
+ (* The -time option is only supported from console-based
+ clients due to the way it prints. *)
if !Flags.time then print_cmd_header loc com;
let com = if !Flags.time then VernacTime (loc,com) else com in
interp com
with reraise ->
+ ignore(Stm.edit_at sid);
let (reraise, info) = CErrors.push reraise in
let loc' = Option.default Loc.ghost (Loc.get_loc info) in
if Loc.is_ghost loc' then iraise (reraise, Loc.add_loc info loc)
else iraise (reraise, info)
(* Load a vernac file. CErrors are annotated with file and location *)
-and load_vernac verbosely file =
+and load_vernac verbosely sid file =
let chan_beautify =
if !Flags.beautify_file then open_out (file^beautify_suffix) else stdout in
- let (in_chan, fname, input) = open_file_twice_if verbosely file in
+ let in_chan = open_utf8_file_in file in
+ let in_echo = if verbosely then Some (open_utf8_file_in file) else None in
+ let in_pa = Pcoq.Gram.parsable ~file (Stream.of_channel in_chan) in
+ let rsid = ref sid in
try
(* we go out of the following infinite loop when a End_of_input is
* raised, which means that we raised the end of the file being loaded *)
while true do
- let loc_ast = Flags.silently parse_sentence input in
- CWarnings.set_current_loc (fst loc_ast);
- Flags.silently (interp_vernac (fst input) chan_beautify checknav_simple) loc_ast;
- done
+ let loc, ast =
+ Stm.parse_sentence !rsid in_pa
+ (* If an error in parsing occurs, we propagate the exception
+ so the caller of load_vernac will take care of it. However,
+ in the future it could be possible that we want to handle
+ all the errors as feedback events, thus in this case we
+ should relay the exception here for convenience. A
+ possibility is shown below, however we may want to refactor
+ this code:
+
+ try Stm.parse_sentence !rsid in_pa
+ with
+ | any when not is_end_of_input any ->
+ let (e, info) = CErrors.push any in
+ let loc = Loc.get_loc info in
+ let msg = CErrors.iprint (e, info) in
+ Feedback.msg_error ?loc msg;
+ iraise (e, info)
+ *)
+ in
+ (* Printing of vernacs *)
+ if !beautify then pr_new_syntax in_pa chan_beautify loc (Some ast);
+ Option.iter (vernac_echo loc) in_echo;
+
+ checknav_simple (loc, ast);
+ let nsid = Flags.silently (interp_vernac !rsid) (loc, ast) in
+ rsid := nsid
+ done;
+ !rsid
with any -> (* whatever the exception *)
let (e, info) = CErrors.push any in
- close_input in_chan input; (* we must close the file first *)
+ close_in in_chan;
+ Option.iter close_in in_echo;
match e with
- | End_of_input ->
+ | Stm.End_of_input ->
+ (* Is this called so comments at EOF are printed? *)
if !beautify then
- pr_new_syntax (fst input) chan_beautify (Loc.make_loc (max_int,max_int)) None;
+ pr_new_syntax in_pa chan_beautify (Loc.make_loc (max_int,max_int)) None;
if !Flags.beautify_file then close_out chan_beautify;
+ !rsid
| reraise ->
if !Flags.beautify_file then close_out chan_beautify;
iraise (disable_drop e, info)
@@ -239,7 +220,9 @@ and load_vernac verbosely file =
of a new state label). An example of state-preserving command is one coming
from the query panel of Coqide. *)
-let process_expr po loc_ast = interp_vernac po stdout checknav_deep loc_ast
+let process_expr sid loc_ast =
+ checknav_deep loc_ast;
+ interp_vernac sid loc_ast
(* XML output hooks *)
let (f_xml_start_library, xml_start_library) = Hook.make ~default:ignore ()
@@ -265,13 +248,10 @@ let chop_extension f =
let ensure_bname src tgt =
let src, tgt = Filename.basename src, Filename.basename tgt in
let src, tgt = chop_extension src, chop_extension tgt in
- if src <> tgt then begin
- Feedback.msg_error (str "Source and target file names must coincide, directories can differ" ++ fnl () ++
- str "Source: " ++ str src ++ fnl () ++
- str "Target: " ++ str tgt);
- flush_all ();
- exit 1
- end
+ if src <> tgt then
+ vernac_error (str "Source and target file names must coincide, directories can differ" ++ fnl () ++
+ str "Source: " ++ str src ++ fnl () ++
+ str "Target: " ++ str tgt)
let ensure ext src tgt = ensure_bname src tgt; ensure_ext ext tgt
@@ -280,17 +260,15 @@ let ensure_vo v vo = ensure ".vo" v vo
let ensure_vio v vio = ensure ".vio" v vio
let ensure_exists f =
- if not (Sys.file_exists f) then begin
- Feedback.msg_error (hov 0 (str "Can't find file" ++ spc () ++ str f));
- exit 1
- end
+ if not (Sys.file_exists f) then
+ vernac_error (hov 0 (str "Can't find file" ++ spc () ++ str f))
(* Compile a vernac file *)
let compile verbosely f =
let check_pending_proofs () =
let pfs = Pfedit.get_all_proof_names () in
- if not (List.is_empty pfs) then
- (Feedback.msg_error (str "There are pending proofs"); flush_all (); exit 1) in
+ if not (List.is_empty pfs) then vernac_error (str "There are pending proofs")
+ in
match !Flags.compilation_mode with
| BuildVo ->
let long_f_dot_v = ensure_v f in
@@ -308,7 +286,7 @@ let compile verbosely f =
Dumpglob.dump_string ("F" ^ Names.DirPath.to_string ldir ^ "\n");
if !Flags.xml_export then Hook.get f_xml_start_library ();
let wall_clock1 = Unix.gettimeofday () in
- let _ = load_vernac verbosely long_f_dot_v in
+ let _ = load_vernac verbosely (Stm.get_current_state ()) long_f_dot_v in
Stm.join ();
let wall_clock2 = Unix.gettimeofday () in
check_pending_proofs ();
@@ -328,7 +306,7 @@ let compile verbosely f =
let ldir = Flags.verbosely Library.start_library long_f_dot_vio in
Dumpglob.noglob ();
Stm.set_compilation_hints long_f_dot_vio;
- let _ = load_vernac verbosely long_f_dot_v in
+ let _ = load_vernac verbosely (Stm.get_current_state ()) long_f_dot_v in
Stm.finish ();
check_pending_proofs ();
Stm.snapshot_vio ldir long_f_dot_vio;
@@ -345,8 +323,8 @@ let compile verbosely f =
let compile v f =
ignore(CoqworkmgrApi.get 1);
- compile v f;
+ begin
+ try compile v f
+ with any -> Topfmt.print_err_exn any
+ end;
CoqworkmgrApi.giveback 1
-
-let () = Hook.set Stm.process_error_hook
- ExplainErr.process_vernac_interp_error
diff --git a/toplevel/vernac.mli b/toplevel/vernac.mli
index 0d9f5871a3..bbc095c687 100644
--- a/toplevel/vernac.mli
+++ b/toplevel/vernac.mli
@@ -8,30 +8,20 @@
(** Parsing of vernacular. *)
-(** Read a vernac command on the specified input (parse only).
- Raises [End_of_file] if EOF (or Ctrl-D) is reached. *)
-
-val parse_sentence : Pcoq.Gram.coq_parsable * in_channel option ->
- Loc.t * Vernacexpr.vernac_expr
-
-(** Reads and executes vernac commands from a stream. *)
-
-exception End_of_input
-
-val process_expr : Pcoq.Gram.coq_parsable -> Loc.t * Vernacexpr.vernac_expr -> unit
+(** [process_expr sid cmd] Executes vernac command [cmd]. Callers are
+ expected to handle and print errors in form of exceptions, however
+ care is taken so the state machine is left in a consistent
+ state. *)
+val process_expr : Stateid.t -> Vernacexpr.vernac_expr Loc.located -> Stateid.t
+
+(** [load_vernac echo sid file] Loads [file] on top of [sid], will
+ echo the commands if [echo] is set. Callers are expected to handle
+ and print errors in form of exceptions. *)
+val load_vernac : bool -> Stateid.t -> string -> Stateid.t
+
+(** Compile a vernac file, (f is assumed without .v suffix) *)
+val compile : bool -> string -> unit
(** Set XML hooks *)
val xml_start_library : (unit -> unit) Hook.t
val xml_end_library : (unit -> unit) Hook.t
-
-(** Load a vernac file, verbosely or not. Errors are annotated with file
- and location *)
-
-val load_vernac : bool -> string -> unit
-
-
-(** Compile a vernac file, verbosely or not (f is assumed without .v suffix) *)
-
-val compile : bool -> string -> unit
-
-val is_navigation_vernac : Vernacexpr.vernac_expr -> bool
diff --git a/vernac/auto_ind_decl.ml b/vernac/auto_ind_decl.ml
index b9c4c6cc5d..f363deac69 100644
--- a/vernac/auto_ind_decl.ml
+++ b/vernac/auto_ind_decl.ml
@@ -9,7 +9,6 @@
(* This file is about the automatic generation of schemes about
decidable equality, created by Vincent Siles, Oct 2007 *)
-open Tacmach
open CErrors
open Util
open Pp
@@ -28,8 +27,6 @@ open Proofview.Notations
module RelDecl = Context.Rel.Declaration
-let out_punivs = Univ.out_punivs
-
(**********************************************************************)
(* Generic synthesis of boolean equality *)
@@ -95,7 +92,7 @@ let destruct_on_using c id =
let destruct_on_as c l =
destruct false None c (Some (dl,l)) None
-(* reconstruct the inductive with the correct deBruijn indexes *)
+(* reconstruct the inductive with the correct de Bruijn indexes *)
let mkFullInd (ind,u) n =
let mib = Global.lookup_mind (fst ind) in
let nparams = mib.mind_nparams in
@@ -174,7 +171,7 @@ let build_beq_scheme mode kn =
(* give a type A, this function tries to find the equality on A declared
previously *)
(* nlist = the number of args (A , B , ... )
- eqA = the deBruijn index of the first eq param
+ eqA = the de Bruijn index of the first eq param
ndx = how much to translate due to the 2nd Case
*)
let compute_A_equality rel_list nlist eqA ndx t =
@@ -718,7 +715,6 @@ let compute_lb_goal ind lnamesparrec nparrec =
))), eff
let compute_lb_tact mode lb_scheme_key ind lnamesparrec nparrec =
- let open EConstr in
let list_id = list_id lnamesparrec in
let avoid = ref [] in
let first_intros =
diff --git a/vernac/class.ml b/vernac/class.ml
index 95114ec396..104f3c1db5 100644
--- a/vernac/class.ml
+++ b/vernac/class.ml
@@ -311,7 +311,7 @@ let add_coercion_hook poly local ref =
| Global -> false
| Discharge -> assert false
in
- let () = try_add_new_coercion ref stre poly in
+ let () = try_add_new_coercion ref ~local:stre poly in
let msg = pr_global_env Id.Set.empty ref ++ str " is now a coercion" in
Flags.if_verbose Feedback.msg_info msg
@@ -324,6 +324,6 @@ let add_subclass_hook poly local ref =
| Discharge -> assert false
in
let cl = class_of_global ref in
- try_add_new_coercion_subclass cl stre poly
+ try_add_new_coercion_subclass cl ~local:stre poly
let add_subclass_hook poly = Lemmas.mk_hook (add_subclass_hook poly)
diff --git a/vernac/classes.ml b/vernac/classes.ml
index 8337199655..d515b0c9b2 100644
--- a/vernac/classes.ml
+++ b/vernac/classes.ml
@@ -66,8 +66,6 @@ let _ =
Hook.set Typeclasses.classes_transparent_state_hook
(fun () -> Hints.Hint_db.transparent_state (Hints.searchtable_map typeclasses_db))
-open Vernacexpr
-
(** TODO: add subinstances *)
let existing_instance glob g info =
let c = global g in
diff --git a/vernac/command.ml b/vernac/command.ml
index 781bf32239..2fa2aa4e33 100644
--- a/vernac/command.ml
+++ b/vernac/command.ml
@@ -96,7 +96,7 @@ let interp_definition pl bl p red_option c ctypopt =
let evdref = ref (Evd.from_ctx ctx) in
let impls, ((env_bl, ctx), imps1) = interp_context_evars env evdref bl in
let ctx = List.map (fun d -> map_rel_decl EConstr.Unsafe.to_constr d) ctx in
- let nb_args = List.length ctx in
+ let nb_args = Context.Rel.nhyps ctx in
let imps,pl,ce =
match ctypopt with
None ->
@@ -234,7 +234,7 @@ match local with
let _ = declare_variable ident decl in
let () = assumption_message ident in
let () =
- if is_verbose () && Pfedit.refining () then
+ if not !Flags.quiet && Pfedit.refining () then
Feedback.msg_info (str"Variable" ++ spc () ++ pr_id ident ++
strbrk " is not visible from current goals")
in
@@ -258,7 +258,7 @@ match local with
let () = Universes.register_universe_binders gr pl in
let () = assumption_message ident in
let () = Typeclasses.declare_instance None false gr in
- let () = if is_coe then Class.try_add_new_coercion gr local p in
+ let () = if is_coe then Class.try_add_new_coercion gr ~local p in
let inst =
if p (* polymorphic *) then Univ.UContext.instance ctx
else Univ.Instance.empty
@@ -266,7 +266,7 @@ match local with
(gr,inst,Lib.is_modtype_strict ())
let interp_assumption evdref env impls bl c =
- let c = prod_constr_expr c bl in
+ let c = mkCProdN (local_binders_loc bl) bl c in
let ty, impls = interp_type_evars_impls env evdref ~impls c in
let ty = EConstr.Unsafe.to_constr ty in
(ty, impls)
@@ -603,12 +603,13 @@ let interp_mutual_inductive (paramsl,indl) notations poly prv finite =
lift_implicits (Context.Rel.nhyps ctx_params) impls) arities in
let arities = List.map pi1 arities and aritypoly = List.map pi2 arities in
let impls = compute_internalization_env env0 (Inductive params) indnames fullarities indimpls in
+ let implsforntn = compute_internalization_env env0 Variable indnames fullarities indimpls in
let mldatas = List.map2 (mk_mltype_data evdref env_params params) arities indnames in
let constructors =
Metasyntax.with_syntax_protection (fun () ->
(* Temporary declaration of notations and scopes *)
- List.iter (Metasyntax.set_notation_for_interpretation impls) notations;
+ List.iter (Metasyntax.set_notation_for_interpretation implsforntn) notations;
(* Interpret the constructor types *)
List.map3 (interp_cstrs env_ar_params evdref impls) mldatas arities indl)
() in
@@ -751,7 +752,7 @@ let do_mutual_inductive indl poly prv finite =
(* Declare the possible notations of inductive types *)
List.iter Metasyntax.add_notation_interpretation ntns;
(* Declare the coercions *)
- List.iter (fun qid -> Class.try_add_new_coercion (locate qid) false poly) coes;
+ List.iter (fun qid -> Class.try_add_new_coercion (locate qid) ~local:false poly) coes;
(* If positivity is assumed declares itself as unsafe. *)
if Environ.deactivated_guard (Global.env ()) then Feedback.feedback Feedback.AddedAxiom else ()
@@ -848,7 +849,7 @@ type structured_fixpoint_expr = {
let interp_fix_context env evdref isfix fix =
let before, after = if isfix then split_at_annot fix.fix_binders fix.fix_annot else [], fix.fix_binders in
let impl_env, ((env', ctx), imps) = interp_context_evars env evdref before in
- let impl_env', ((env'', ctx'), imps') = interp_context_evars ~impl_env ~shift:(List.length before) env' evdref after in
+ let impl_env', ((env'', ctx'), imps') = interp_context_evars ~impl_env ~shift:(Context.Rel.nhyps ctx) env' evdref after in
let annot = Option.map (fun _ -> List.length (assums_of_rel_context ctx)) fix.fix_annot in
((env'', ctx' @ ctx), (impl_env',imps @ imps'), annot)
@@ -879,8 +880,10 @@ let prepare_recursive_declaration fixnames fixtypes fixdefs =
(* Jump over let-bindings. *)
-let compute_possible_guardness_evidences (ids,_,na) =
- match na with
+let compute_possible_guardness_evidences (ctx,_,recindex) =
+ (* A recursive index is characterized by the number of lambdas to
+ skip before finding the relevant inductive argument *)
+ match recindex with
| Some i -> [i]
| None ->
(* If recursive argument was not given by user, we try all args.
@@ -888,7 +891,7 @@ let compute_possible_guardness_evidences (ids,_,na) =
but doing it properly involves delta-reduction, and it finally
doesn't seem to worth the effort (except for huge mutual
fixpoints ?) *)
- List.interval 0 (List.length ids - 1)
+ List.interval 0 (Context.Rel.nhyps ctx - 1)
type recursive_preentry =
Id.t list * constr option list * types list
@@ -1129,7 +1132,7 @@ let interp_recursive isfix fixl notations =
let fixtypes = List.map2 build_fix_type fixctxs fixccls in
let fixtypes = List.map (fun c -> nf_evar !evdref c) fixtypes in
let fiximps = List.map3
- (fun ctximps cclimps (_,ctx) -> ctximps@(Impargs.lift_implicits (List.length ctx) cclimps))
+ (fun ctximps cclimps (_,ctx) -> ctximps@(Impargs.lift_implicits (Context.Rel.nhyps ctx) cclimps))
fixctximps fixcclimps fixctxs in
let rec_sign =
List.fold_left2
@@ -1168,10 +1171,10 @@ let interp_recursive isfix fixl notations =
let fixdefs = List.map (fun c -> Option.map EConstr.Unsafe.to_constr c) fixdefs in
let fixdefs = List.map (Option.map nf) fixdefs in
let fixtypes = List.map nf fixtypes in
- let fixctxnames = List.map (fun (_,ctx) -> List.map RelDecl.get_name ctx) fixctxs in
+ let fixctxs = List.map (fun (_,ctx) -> ctx) fixctxs in
(* Build the fix declaration block *)
- (env,rec_sign,all_universes,evd), (fixnames,fixdefs,fixtypes), List.combine3 fixctxnames fiximps fixannots
+ (env,rec_sign,all_universes,evd), (fixnames,fixdefs,fixtypes), List.combine3 fixctxs fiximps fixannots
let check_recursive isfix env evd (fixnames,fixdefs,_) =
check_evars_are_solved env evd Evd.empty;
@@ -1187,21 +1190,18 @@ let interp_fixpoint l ntns =
let interp_cofixpoint l ntns =
let (env,_,pl,evd),fix,info = interp_recursive false l ntns in
- check_recursive false env evd fix;
+ check_recursive false env evd fix;
(fix,pl,Evd.evar_universe_context evd,info)
let declare_fixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) indexes ntns =
if List.exists Option.is_empty fixdefs then
(* Some bodies to define by proof *)
let thms =
- List.map3 (fun id t (len,imps,_) -> ((id,pl),(t,(len,imps))))
+ List.map3 (fun id t (ctx,imps,_) -> ((id,pl),(t,(List.map RelDecl.get_name ctx,imps))))
fixnames fixtypes fiximps in
let init_tac =
- Some (List.map (Option.cata (EConstr.of_constr %> Tacmach.refine_no_check) Tacticals.tclIDTAC)
+ Some (List.map (Option.cata (EConstr.of_constr %> Tactics.exact_no_check) Tacticals.New.tclIDTAC)
fixdefs) in
- let init_tac =
- Option.map (List.map Proofview.V82.tactic) init_tac
- in
let evd = Evd.from_ctx ctx in
Lemmas.start_proof_with_initialization (Global,poly,DefinitionBody Fixpoint)
evd (Some(false,indexes,init_tac)) thms None (Lemmas.mk_hook (fun _ _ -> ()))
@@ -1231,14 +1231,11 @@ let declare_cofixpoint local poly ((fixnames,fixdefs,fixtypes),pl,ctx,fiximps) n
if List.exists Option.is_empty fixdefs then
(* Some bodies to define by proof *)
let thms =
- List.map3 (fun id t (len,imps,_) -> ((id,pl),(t,(len,imps))))
+ List.map3 (fun id t (ctx,imps,_) -> ((id,pl),(t,(List.map RelDecl.get_name ctx,imps))))
fixnames fixtypes fiximps in
let init_tac =
- Some (List.map (Option.cata (EConstr.of_constr %> Tacmach.refine_no_check) Tacticals.tclIDTAC)
+ Some (List.map (Option.cata (EConstr.of_constr %> Tactics.exact_no_check) Tacticals.New.tclIDTAC)
fixdefs) in
- let init_tac =
- Option.map (List.map Proofview.V82.tactic) init_tac
- in
let evd = Evd.from_ctx ctx in
Lemmas.start_proof_with_initialization (Global,poly, DefinitionBody CoFixpoint)
evd (Some(true,[],init_tac)) thms None (Lemmas.mk_hook (fun _ _ -> ()))
diff --git a/vernac/command.mli b/vernac/command.mli
index 7cd0afeec3..9bbc2fdac1 100644
--- a/vernac/command.mli
+++ b/vernac/command.mli
@@ -138,24 +138,24 @@ type recursive_preentry =
val interp_fixpoint :
structured_fixpoint_expr list -> decl_notation list ->
recursive_preentry * lident list option * Evd.evar_universe_context *
- (Name.t list * Impargs.manual_implicits * int option) list
+ (EConstr.rel_context * Impargs.manual_implicits * int option) list
val interp_cofixpoint :
structured_fixpoint_expr list -> decl_notation list ->
recursive_preentry * lident list option * Evd.evar_universe_context *
- (Name.t list * Impargs.manual_implicits * int option) list
+ (EConstr.rel_context * Impargs.manual_implicits * int option) list
(** Registering fixpoints and cofixpoints in the environment *)
val declare_fixpoint :
locality -> polymorphic ->
recursive_preentry * lident list option * Evd.evar_universe_context *
- (Name.t list * Impargs.manual_implicits * int option) list ->
+ (Context.Rel.t * Impargs.manual_implicits * int option) list ->
lemma_possible_guards -> decl_notation list -> unit
val declare_cofixpoint : locality -> polymorphic ->
recursive_preentry * lident list option * Evd.evar_universe_context *
- (Name.t list * Impargs.manual_implicits * int option) list ->
+ (Context.Rel.t * Impargs.manual_implicits * int option) list ->
decl_notation list -> unit
(** Entry points for the vernacular commands Fixpoint and CoFixpoint *)
diff --git a/vernac/ind_tables.ml b/vernac/ind_tables.ml
index 85d0b6194c..c6588684a4 100644
--- a/vernac/ind_tables.ml
+++ b/vernac/ind_tables.ml
@@ -151,7 +151,7 @@ let define_individual_scheme_base kind suff f mode idopt (mind,i as ind) =
let const = define mode id c mib.mind_polymorphic ctx in
declare_scheme kind [|ind,const|];
const, Safe_typing.add_private
- (Safe_typing.private_con_of_scheme kind (Global.safe_env()) [ind,const]) eff
+ (Safe_typing.private_con_of_scheme ~kind (Global.safe_env()) [ind,const]) eff
let define_individual_scheme kind mode names (mind,i as ind) =
match Hashtbl.find scheme_object_table kind with
@@ -172,7 +172,7 @@ let define_mutual_scheme_base kind suff f mode names mind =
consts,
Safe_typing.add_private
(Safe_typing.private_con_of_scheme
- kind (Global.safe_env()) (Array.to_list schemes))
+ ~kind (Global.safe_env()) (Array.to_list schemes))
eff
let define_mutual_scheme kind mode names mind =
@@ -185,7 +185,7 @@ let find_scheme_on_env_too kind ind =
let s = String.Map.find kind (Indmap.find ind !scheme_map) in
s, Safe_typing.add_private
(Safe_typing.private_con_of_scheme
- kind (Global.safe_env()) [ind, s])
+ ~kind (Global.safe_env()) [ind, s])
Safe_typing.empty_private_constants
let find_scheme ?(mode=InternalTacticRequest) kind (mind,i as ind) =
diff --git a/vernac/lemmas.ml b/vernac/lemmas.ml
index 993a2c260d..b79795aebd 100644
--- a/vernac/lemmas.ml
+++ b/vernac/lemmas.ml
@@ -28,10 +28,8 @@ open Pretyping
open Termops
open Namegen
open Reductionops
-open Constrexpr
open Constrintern
open Impargs
-open Context.Rel.Declaration
module RelDecl = Context.Rel.Declaration
module NamedDecl = Context.Named.Declaration
@@ -88,25 +86,9 @@ let adjust_guardness_conditions const = function
let find_mutually_recursive_statements thms =
let n = List.length thms in
- let inds = List.map (fun (id,(t,impls,annot)) ->
+ let inds = List.map (fun (id,(t,impls)) ->
let (hyps,ccl) = decompose_prod_assum t in
let x = (id,(t,impls)) in
- match annot with
- (* Explicit fixpoint decreasing argument is given *)
- | Some (Some (_,id),CStructRec) ->
- let i,b,typ = lookup_rel_id id hyps in
- (match kind_of_term t with
- | Ind ((kn,_ as ind), u) when
- let mind = Global.lookup_mind kn in
- mind.mind_finite == Decl_kinds.Finite && Option.is_empty b ->
- [ind,x,i],[]
- | _ ->
- error "Decreasing argument is not an inductive assumption.")
- (* Unsupported cases *)
- | Some (_,(CWfRec _|CMeasureRec _)) ->
- error "Only structural decreasing is supported for mutual statements."
- (* Cofixpoint or fixpoint w/o explicit decreasing argument *)
- | None | Some (None, CStructRec) ->
let whnf_hyp_hds = map_rel_context_in_env
(fun env c -> EConstr.Unsafe.to_constr (fst (whd_all_stack env Evd.empty (EConstr.of_constr c))))
(Global.env()) hyps in
@@ -116,10 +98,10 @@ let find_mutually_recursive_statements thms =
match kind_of_term t with
| Ind ((kn,_ as ind),u) when
let mind = Global.lookup_mind kn in
- mind.mind_finite <> Decl_kinds.CoFinite && is_local_assum decl ->
+ mind.mind_finite <> Decl_kinds.CoFinite ->
[ind,x,i]
| _ ->
- []) 0 (List.rev whnf_hyp_hds)) in
+ []) 0 (List.rev (List.filter RelDecl.is_local_assum whnf_hyp_hds))) in
let ind_ccl =
let cclenv = push_rel_context hyps (Global.env()) in
let whnf_ccl,_ = whd_all_stack cclenv Evd.empty (EConstr.of_constr ccl) in
@@ -178,7 +160,7 @@ let find_mutually_recursive_statements thms =
(finite,guard,None), ordered_inds
let look_for_possibly_mutual_statements = function
- | [id,(t,impls,None)] ->
+ | [id,(t,impls)] ->
(* One non recursively proved theorem *)
None,[id,(t,impls)],None
| _::_ as thms ->
@@ -458,7 +440,7 @@ let start_proof_com ?inference_hook kind thms hook =
| None -> Evd.from_env env0
| Some l -> Evd.from_ctx (Evd.make_evar_universe_context env0 l))
in
- let thms = List.map (fun (sopt,(bl,t,guard)) ->
+ let thms = List.map (fun (sopt,(bl,t)) ->
let impls, ((env, ctx), imps) = interp_context_evars env0 evdref bl in
let t', imps' = interp_type_evars_impls ~impls env evdref t in
let flags = all_and_fail_flags in
@@ -467,8 +449,7 @@ let start_proof_com ?inference_hook kind thms hook =
let ids = List.map RelDecl.get_name ctx in
(compute_proof_name (pi1 kind) sopt,
(EConstr.Unsafe.to_constr (nf_evar !evdref (EConstr.it_mkProd_or_LetIn t' ctx)),
- (ids, imps @ lift_implicits (List.length ids) imps'),
- guard)))
+ (ids, imps @ lift_implicits (Context.Rel.nhyps ctx) imps'))))
thms in
let recguard,thms,snl = look_for_possibly_mutual_statements thms in
let evd, nf = Evarutil.nf_evars_and_universes !evdref in
diff --git a/vernac/lemmas.mli b/vernac/lemmas.mli
index 681413a297..d06b8fd14b 100644
--- a/vernac/lemmas.mli
+++ b/vernac/lemmas.mli
@@ -41,8 +41,8 @@ val start_proof_com :
val start_proof_with_initialization :
goal_kind -> Evd.evar_map ->
(bool * lemma_possible_guards * unit Proofview.tactic list option) option ->
- ((Id.t * universe_binders option) *
- (types * (Name.t list * Impargs.manual_explicitation list))) list
+ ((Id.t (* name of thm *) * universe_binders option) *
+ (types (* type of thm *) * (Name.t list (* names to pre-introduce *) * Impargs.manual_explicitation list))) list
-> int list option -> unit declaration_hook -> unit
val universe_proof_terminator :
diff --git a/vernac/metasyntax.ml b/vernac/metasyntax.ml
index 7e98d114a3..bb5be4cb05 100644
--- a/vernac/metasyntax.ml
+++ b/vernac/metasyntax.ml
@@ -522,11 +522,35 @@ let read_recursive_format sl fmt =
let slfmt, fmt = get_head fmt in
slfmt, get_tail (slfmt, fmt)
+let warn_skip_spaces_curly =
+ CWarnings.create ~name:"skip-spaces-curly" ~category:"parsing"
+ (fun () ->strbrk "Skipping spaces inside curly brackets")
+
+let rec drop_spacing = function
+ | UnpCut _ :: fmt -> warn_skip_spaces_curly (); drop_spacing fmt
+ | UnpTerminal s' :: fmt when String.equal s' (String.make (String.length s') ' ') -> warn_skip_spaces_curly (); drop_spacing fmt
+ | fmt -> fmt
+
+let has_closing_curly_brace symbs fmt =
+ (* TODO: recognize and fail in case a box overlaps a pair of curly braces *)
+ let fmt = drop_spacing fmt in
+ match symbs, fmt with
+ | NonTerminal s :: symbs, (UnpTerminal s' as u) :: fmt when Id.equal s (Id.of_string s') ->
+ let fmt = drop_spacing fmt in
+ (match fmt with
+ | UnpTerminal "}" :: fmt -> Some (u :: fmt)
+ | _ -> None)
+ | _ -> None
+
let hunks_of_format (from,(vars,typs)) symfmt =
+ let a = ref None in
let rec aux = function
| symbs, (UnpTerminal s' as u) :: fmt
when String.equal s' (String.make (String.length s') ' ') ->
let symbs, l = aux (symbs,fmt) in symbs, u :: l
+ | symbs, (UnpTerminal "{") :: fmt when (a := has_closing_curly_brace symbs fmt; !a <> None) ->
+ let newfmt = Option.get !a in
+ aux (symbs,newfmt)
| Terminal s :: symbs, (UnpTerminal s') :: fmt
when String.equal s (String.drop_simple_quotes s') ->
let symbs, l = aux (symbs,fmt) in symbs, UnpTerminal s :: l
@@ -814,6 +838,15 @@ let check_useless_entry_types recvars mainvars etyps =
(pr_id x ++ str " is unbound in the notation.")
| _ -> ()
+let check_binder_type recvars etyps =
+ let l1,l2 = List.split recvars in
+ let l = l1@l2 in
+ List.iter (function
+ | (x,ETBinder b) when not (List.mem x l) ->
+ CErrors.user_err (str (if b then "binder" else "closed binder") ++
+ strbrk " is only for use in recursive notations for binders.")
+ | _ -> ()) etyps
+
let not_a_syntax_modifier = function
| SetOnlyParsing -> true
| SetOnlyPrinting -> true
@@ -981,10 +1014,6 @@ let check_curly_brackets_notation_exists () =
error "Notations involving patterns of the form \"{ _ }\" are treated \n\
specially and require that the notation \"{ _ }\" is already reserved."
-let warn_skip_spaces_curly =
- CWarnings.create ~name:"skip-spaces-curly" ~category:"parsing"
- (fun () ->strbrk "Skipping spaces inside curly brackets")
-
(* Remove patterns of the form "{ _ }", unless it is the "{ _ }" notation *)
let remove_curly_brackets l =
let rec skip_break acc = function
@@ -1057,9 +1086,10 @@ let compute_syntax_data df modifiers =
let toks = split_notation_string df in
let recvars,mainvars,symbols = analyze_notation_tokens toks in
let _ = check_useless_entry_types recvars mainvars mods.etyps in
+ let _ = check_binder_type recvars mods.etyps in
(* Notations for interp and grammar *)
- let ntn_for_interp = make_notation_key symbols in
+let ntn_for_interp = make_notation_key symbols in
let symbols' = remove_curly_brackets symbols in
let ntn_for_grammar = make_notation_key symbols' in
if not onlyprint then check_rule_productivity symbols';
@@ -1166,7 +1196,7 @@ let inNotation : notation_obj -> obj =
(**********************************************************************)
let with_lib_stk_protection f x =
- let fs = Lib.freeze `No in
+ let fs = Lib.freeze ~marshallable:`No in
try let a = f x in Lib.unfreeze fs; a
with reraise ->
let reraise = CErrors.push reraise in
diff --git a/vernac/mltop.ml b/vernac/mltop.ml
index 2396cf04a4..056ffca5c8 100644
--- a/vernac/mltop.ml
+++ b/vernac/mltop.ml
@@ -138,7 +138,7 @@ let dir_ml_load s =
match !load with
| WithTop _ -> ml_load s
| WithoutTop ->
- let warn = Flags.is_verbose() in
+ let warn = not !Flags.quiet in
let _,gname = find_file_in_path ~warn !coq_mlpath_copy s in
ml_load gname
@@ -365,7 +365,7 @@ let trigger_ml_object verb cache reinit ?path name =
else begin
let file = file_of_name (Option.default name path) in
let path =
- if_verbose_load (verb && is_verbose ()) load_ml_object name ?path file in
+ if_verbose_load (verb && not !quiet) load_ml_object name ?path file in
add_loaded_module name (Some path);
if cache then perform_cache_obj name
end
diff --git a/vernac/obligations.ml b/vernac/obligations.ml
index ea2401b5ce..e0520216b2 100644
--- a/vernac/obligations.ml
+++ b/vernac/obligations.ml
@@ -8,7 +8,7 @@ open Declare
(**
- Get types of existentials ;
- Flatten dependency tree (prefix order) ;
- - Replace existentials by De Bruijn indices in term, applied to the right arguments ;
+ - Replace existentials by de Bruijn indices in term, applied to the right arguments ;
- Apply term prefixed by quantification on "existentials".
*)
@@ -51,7 +51,7 @@ type oblinfo =
ev_tac: unit Proofview.tactic option;
ev_deps: Int.Set.t }
-(** Substitute evar references in t using De Bruijn indices,
+(** Substitute evar references in t using de Bruijn indices,
where n binders were passed through. *)
let subst_evar_constr evs n idf t =
@@ -102,7 +102,7 @@ let subst_evar_constr evs n idf t =
t', !seen, !transparent
-(** Substitute variable references in t using De Bruijn indices,
+(** Substitute variable references in t using de Bruijn indices,
where n binders were passed through. *)
let subst_vars acc n t =
let var_index id = Util.List.index Id.equal id acc in
diff --git a/vernac/obligations.mli b/vernac/obligations.mli
index 11366fe91b..a276f9f9a3 100644
--- a/vernac/obligations.mli
+++ b/vernac/obligations.mli
@@ -12,7 +12,6 @@ open Evd
open Names
open Pp
open Globnames
-open Vernacexpr
open Decl_kinds
(** Forward declaration. *)
diff --git a/vernac/record.ml b/vernac/record.ml
index 8b4b7606fc..53722b8f61 100644
--- a/vernac/record.ml
+++ b/vernac/record.ml
@@ -216,7 +216,7 @@ let warning_or_error coe indsp err =
(pr_id fi ++ strbrk " cannot be defined because it is not typable.")
in
if coe then user_err ~hdr:"structure" st;
- Flags.if_verbose Feedback.msg_info (hov 0 st)
+ warn_cannot_define_projection (hov 0 st)
type field_status =
| NoProjection of Name.t
diff --git a/vernac/search.ml b/vernac/search.ml
index 6279b17ae0..5b6e9a9c3c 100644
--- a/vernac/search.ml
+++ b/vernac/search.ml
@@ -14,11 +14,9 @@ open Declarations
open Libobject
open Environ
open Pattern
-open Printer
open Libnames
open Globnames
open Nametab
-open Goptions
module NamedDecl = Context.Named.Declaration
diff --git a/vernac/search.mli b/vernac/search.mli
index 82b79f75de..e34522d8af 100644
--- a/vernac/search.mli
+++ b/vernac/search.mli
@@ -6,7 +6,6 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-open Pp
open Names
open Term
open Environ
diff --git a/vernac/topfmt.ml b/vernac/topfmt.ml
index ee55366927..6d9d71a62b 100644
--- a/vernac/topfmt.ml
+++ b/vernac/topfmt.ml
@@ -106,49 +106,45 @@ module Tag = struct
end
-type logger = ?loc:Loc.t -> level -> std_ppcmds -> unit
-
let msgnl_with ?pre_hdr fmt strm =
pp_with fmt (strm ++ fnl ());
Format.pp_print_flush fmt ()
-(* XXX: This is really painful! *)
module Emacs = struct
(* Special chars for emacs, to detect warnings inside goal output *)
- let emacs_quote_start = String.make 1 (Char.chr 254)
- let emacs_quote_end = String.make 1 (Char.chr 255)
+ let quote_warning_start = "<warning>"
+ let quote_warning_end = "</warning>"
- let emacs_quote_err g =
- hov 0 (str emacs_quote_start ++ g ++ str emacs_quote_end)
+ let quote_info_start = "<infomsg>"
+ let quote_info_end = "</infomsg>"
- let emacs_quote_info_start = "<infomsg>"
- let emacs_quote_info_end = "</infomsg>"
+ let quote_emacs q_start q_end msg =
+ hov 0 (seq [str q_start; brk(0,0); msg; brk(0,0); str q_end])
- let emacs_quote_info g =
- hov 0 (str emacs_quote_info_start++ brk(0,0) ++ g ++ brk(0,0) ++ str emacs_quote_info_end)
+ let quote_warning = quote_emacs quote_warning_start quote_warning_end
+ let quote_info = quote_emacs quote_info_start quote_info_end
end
-open Emacs
-
let dbg_hdr = tag Tag.debug (str "Debug:") ++ spc ()
let info_hdr = mt ()
let warn_hdr = tag Tag.warning (str "Warning:") ++ spc ()
let err_hdr = tag Tag.error (str "Error:") ++ spc ()
-let ann_hdr = tag Tag.error (str "Anomaly:") ++ spc ()
let make_body quoter info ?pre_hdr s =
pr_opt_no_spc (fun x -> x ++ fnl ()) pre_hdr ++ quoter (hov 0 (info ++ s))
+(* The empty quoter *)
+let noq x = x
(* Generic logger *)
-let gen_logger dbg err ?pre_hdr level msg = match level with
+let gen_logger dbg warn ?pre_hdr level msg = match level with
| Debug -> msgnl_with !std_ft (make_body dbg dbg_hdr ?pre_hdr msg)
| Info -> msgnl_with !std_ft (make_body dbg info_hdr ?pre_hdr msg)
- | Notice -> msgnl_with !std_ft (make_body dbg info_hdr ?pre_hdr msg)
+ | Notice -> msgnl_with !std_ft (make_body noq info_hdr ?pre_hdr msg)
| Warning -> Flags.if_warn (fun () ->
- msgnl_with !err_ft (make_body err warn_hdr ?pre_hdr msg)) ()
- | Error -> msgnl_with !err_ft (make_body err err_hdr ?pre_hdr msg)
+ msgnl_with !err_ft (make_body warn warn_hdr ?pre_hdr msg)) ()
+ | Error -> msgnl_with !err_ft (make_body noq err_hdr ?pre_hdr msg)
(** Standard loggers *)
@@ -259,17 +255,30 @@ let init_color_output () =
- Warning/Error: emacs_quote_err
- Notice: unquoted
*)
-let emacs_logger = gen_logger emacs_quote_info emacs_quote_err
-
-(* Output to file, used only in extraction so a candidate for removal *)
-let ft_logger old_logger ft ?loc level mesg =
- let id x = x in
- match level with
- | Debug -> msgnl_with ft (make_body id dbg_hdr mesg)
- | Info -> msgnl_with ft (make_body id info_hdr mesg)
- | Notice -> msgnl_with ft mesg
- | Warning -> old_logger ?loc level mesg
- | Error -> old_logger ?loc level mesg
+let emacs_logger = gen_logger Emacs.quote_info Emacs.quote_warning
+
+
+(* This is specific to the toplevel *)
+let pr_loc loc =
+ if Loc.is_ghost loc then str"<unknown>"
+ else
+ let fname = loc.Loc.fname in
+ if CString.equal fname "" then
+ Loc.(str"Toplevel input, characters " ++ int loc.bp ++
+ str"-" ++ int loc.ep ++ str":")
+ else
+ Loc.(str"File " ++ str "\"" ++ str fname ++ str "\"" ++
+ str", line " ++ int loc.line_nb ++ str", characters " ++
+ int (loc.bp-loc.bol_pos) ++ str"-" ++ int (loc.ep-loc.bol_pos) ++
+ str":")
+
+let print_err_exn ?extra any =
+ let (e, info) = CErrors.push any in
+ let loc = Loc.get_loc info in
+ let msg_loc = pr_loc (Option.default Loc.ghost loc) in
+ let pre_hdr = pr_opt_no_spc (fun x -> x) extra ++ msg_loc in
+ let msg = CErrors.iprint (e, info) ++ fnl () in
+ std_logger ~pre_hdr Feedback.Error msg
let with_output_to_file fname func input =
(* XXX FIXME: redirect std_ft *)
diff --git a/vernac/topfmt.mli b/vernac/topfmt.mli
index 909dd70775..6c8e0ae2fa 100644
--- a/vernac/topfmt.mli
+++ b/vernac/topfmt.mli
@@ -36,19 +36,22 @@ val get_depth_boxes : unit -> int option
val set_margin : int option -> unit
val get_margin : unit -> int option
-(** Headers for tagging *)
-val err_hdr : Pp.std_ppcmds
-val ann_hdr : Pp.std_ppcmds
-
(** Console display of feedback, we may add some location information *)
val std_logger : ?pre_hdr:Pp.std_ppcmds -> Feedback.level -> Pp.std_ppcmds -> unit
val emacs_logger : ?pre_hdr:Pp.std_ppcmds -> Feedback.level -> Pp.std_ppcmds -> unit
+(** Color output *)
val init_color_output : unit -> unit
val clear_styles : unit -> unit
val parse_color_config : string -> unit
val dump_tags : unit -> (string * Terminal.style) list
+(** Error printing *)
+(* To be deprecated when we can fully move to feedback-based error
+ printing. *)
+val pr_loc : Loc.t -> Pp.std_ppcmds
+val print_err_exn : ?extra:Pp.std_ppcmds -> exn -> unit
+
(** [with_output_to_file file f x] executes [f x] with logging
redirected to a file [file] *)
val with_output_to_file : string -> ('a -> 'b) -> 'a -> 'b
diff --git a/vernac/vernac.mllib b/vernac/vernac.mllib
index 283c095eb6..d631fae8a8 100644
--- a/vernac/vernac.mllib
+++ b/vernac/vernac.mllib
@@ -1,3 +1,4 @@
+Vernacprop
Lemmas
Himsg
ExplainErr
diff --git a/vernac/vernacentries.ml b/vernac/vernacentries.ml
index 53d49ddbcf..2cb6f3918f 100644
--- a/vernac/vernacentries.ml
+++ b/vernac/vernacentries.ml
@@ -84,24 +84,10 @@ let show_universes () =
Feedback.msg_notice (Termops.pr_evar_universe_context (Evd.evar_universe_context sigma));
Feedback.msg_notice (str"Normalized constraints: " ++ Univ.pr_universe_context_set (Termops.pr_evd_level sigma) ctx)
-let show_prooftree () =
- (* Spiwack: proof tree is currently not working *)
- ()
-
-let enable_goal_printing = ref true
-
-let print_subgoals () =
- if !enable_goal_printing && is_verbose ()
- then begin
- Feedback.msg_notice (pr_open_subgoals ())
- end
-
-let try_print_subgoals () =
- try print_subgoals () with Proof_global.NoCurrentProof | UserError _ -> ()
-
-
- (* Simulate the Intro(s) tactic *)
+(* Spiwack: proof tree is currently not working *)
+let show_prooftree () = ()
+(* Simulate the Intro(s) tactic *)
let show_intro all =
let open EConstr in
let pf = get_pftreestate() in
@@ -491,7 +477,7 @@ let vernac_definition locality p (local,k) ((loc,id as lid),pl) def =
(match def with
| ProveBody (bl,t) -> (* local binders, typ *)
start_proof_and_print (local,p,DefinitionBody k)
- [Some (lid,pl), (bl,t,None)] hook
+ [Some (lid,pl), (bl,t)] hook
| DefineBody (bl,red_option,c,typ_opt) ->
let red_option = match red_option with
| None -> None
@@ -513,8 +499,6 @@ let vernac_start_proof locality p kind l lettop =
(str "Let declarations can only be used in proof editing mode.");
start_proof_and_print (local, p, Proof kind) l no_hook
-let qed_display_script = ref true
-
let vernac_end_proof ?proof = function
| Admitted -> save_proof ?proof Admitted
| Proved (_,_) as e -> save_proof ?proof e
@@ -796,7 +780,7 @@ let vernac_require from import qidl =
in
let locate (loc, qid) =
try
- let warn = Flags.is_verbose () in
+ let warn = not !Flags.quiet in
let (_, dir, f) = Library.locate_qualified_library ?root ~warn qid in
(dir, f)
with
@@ -1248,8 +1232,8 @@ let _ =
optdepr = false;
optname = "silent";
optkey = ["Silent"];
- optread = is_silent;
- optwrite = make_silent }
+ optread = (fun () -> !Flags.quiet);
+ optwrite = ((:=) Flags.quiet) }
let _ =
declare_bool_option
@@ -1381,15 +1365,6 @@ let _ =
declare_bool_option
{ optsync = true;
optdepr = false;
- optname = "record printing";
- optkey = ["Printing";"Records"];
- optread = (fun () -> !Flags.record_print);
- optwrite = (fun b -> Flags.record_print := b) }
-
-let _ =
- declare_bool_option
- { optsync = true;
- optdepr = false;
optname = "use of the program extension";
optkey = ["Program";"Mode"];
optread = (fun () -> !Flags.program_mode);
@@ -1438,15 +1413,6 @@ let _ =
let _ =
declare_int_option
- { optsync = false;
- optdepr = false;
- optname = "the hypotheses limit";
- optkey = ["Hyps";"Limit"];
- optread = Flags.print_hyps_limit;
- optwrite = Flags.set_print_hyps_limit }
-
-let _ =
- declare_int_option
{ optsync = true;
optdepr = false;
optname = "the printing depth";
@@ -1567,7 +1533,14 @@ let get_current_context_of_args = function
| Some n -> get_goal_context n
| None -> get_current_context ()
-let vernac_check_may_eval redexp glopt rc =
+let query_command_selector ~loc = function
+ | None -> None
+ | Some (SelectNth n) -> Some n
+ | _ -> user_err ~loc ~hdr:"query_command_selector"
+ (str "Query commands only support the single numbered goal selector.")
+
+let vernac_check_may_eval ~loc redexp glopt rc =
+ let glopt = query_command_selector ~loc glopt in
let (sigma, env) = get_current_context_of_args glopt in
let sigma', c = interp_open_constr env sigma rc in
let c = EConstr.Unsafe.to_constr c in
@@ -1629,9 +1602,10 @@ exception NoHyp
(* Printing "About" information of a hypothesis of the current goal.
We only print the type and a small statement to this comes from the
goal. Precondition: there must be at least one current goal. *)
-let print_about_hyp_globs ref_or_by_not glnumopt =
+let print_about_hyp_globs ~loc ref_or_by_not glopt =
let open Context.Named.Declaration in
try
+ let glnumopt = query_command_selector ~loc glopt in
let gl,id =
match glnumopt,ref_or_by_not with
| None,AN (Ident (_loc,id)) -> (* goal number not given, catch any failure *)
@@ -1639,8 +1613,8 @@ let print_about_hyp_globs ref_or_by_not glnumopt =
| Some n,AN (Ident (_loc,id)) -> (* goal number given, catch if wong *)
(try get_nth_goal n,id
with
- Failure _ -> user_err ~hdr:"print_about_hyp_globs"
- (str "No such goal: " ++ int n ++ str "."))
+ Failure _ -> user_err ~loc ~hdr:"print_about_hyp_globs"
+ (str "No such goal: " ++ int n ++ str "."))
| _ , _ -> raise NoHyp in
let hyps = pf_hyps gl in
let decl = Context.Named.lookup id hyps in
@@ -1653,7 +1627,7 @@ let print_about_hyp_globs ref_or_by_not glnumopt =
| NoHyp | Not_found -> print_about ref_or_by_not
-let vernac_print = let open Feedback in function
+let vernac_print ~loc = let open Feedback in function
| PrintTables -> msg_notice (print_tables ())
| PrintFullContext-> msg_notice (print_full_context_typ ())
| PrintSectionContext qid -> msg_notice (print_sec_context_typ qid)
@@ -1698,7 +1672,7 @@ let vernac_print = let open Feedback in function
| PrintVisibility s ->
msg_notice (Notation.pr_visibility (Constrextern.without_symbols pr_lglob_constr) s)
| PrintAbout (ref_or_by_not,glnumopt) ->
- msg_notice (print_about_hyp_globs ref_or_by_not glnumopt)
+ msg_notice (print_about_hyp_globs ~loc ref_or_by_not glnumopt)
| PrintImplicit qid ->
dump_global qid; msg_notice (print_impargs qid)
| PrintAssumptions (o,t,r) ->
@@ -1763,7 +1737,8 @@ let _ =
optread = (fun () -> !search_output_name_only);
optwrite = (:=) search_output_name_only }
-let vernac_search s gopt r =
+let vernac_search ~loc s gopt r =
+ let gopt = query_command_selector ~loc gopt in
let r = interp_search_restriction r in
let env,gopt =
match gopt with | None ->
@@ -1969,9 +1944,6 @@ let interp ?proof ~loc locality poly c =
| VernacBack _ -> anomaly (str "VernacBack not handled by Stm")
| VernacBackTo _ -> anomaly (str "VernacBackTo not handled by Stm")
- (* Horrible Hack that should die. *)
- | VernacError e -> raise e
-
(* This one is possible to handle here *)
| VernacAbort id -> CErrors.user_err (str "Abort cannot be used through the Load command")
@@ -2073,17 +2045,17 @@ let interp ?proof ~loc locality poly c =
| VernacAddOption (key,v) -> vernac_add_option key v
| VernacMemOption (key,v) -> vernac_mem_option key v
| VernacPrintOption key -> vernac_print_option key
- | VernacCheckMayEval (r,g,c) -> vernac_check_may_eval r g c
+ | VernacCheckMayEval (r,g,c) -> vernac_check_may_eval ~loc r g c
| VernacDeclareReduction (s,r) -> vernac_declare_reduction locality s r
| VernacGlobalCheck c -> vernac_global_check c
- | VernacPrint p -> vernac_print p
- | VernacSearch (s,g,r) -> vernac_search s g r
+ | VernacPrint p -> vernac_print ~loc p
+ | VernacSearch (s,g,r) -> vernac_search ~loc s g r
| VernacLocate l -> vernac_locate l
| VernacRegister (id, r) -> vernac_register id r
| VernacComments l -> if_verbose Feedback.msg_info (str "Comments ok\n")
(* Proof management *)
- | VernacGoal t -> vernac_start_proof locality poly Theorem [None,([],t,None)] false
+ | VernacGoal t -> vernac_start_proof locality poly Theorem [None,([],t)] false
| VernacFocus n -> vernac_focus n
| VernacUnfocus -> vernac_unfocus ()
| VernacUnfocused -> vernac_unfocused ()
@@ -2207,7 +2179,7 @@ let with_fail b f =
| HasNotFailed ->
user_err ~hdr:"Fail" (str "The command has not failed!")
| HasFailed msg ->
- if is_verbose () || !test_mode || !ide_slave then Feedback.msg_info
+ if not !Flags.quiet || !test_mode || !ide_slave then Feedback.msg_info
(str "The command has indeed failed with message:" ++ fnl () ++ msg)
| _ -> assert false
end
@@ -2234,7 +2206,7 @@ let interp ?(verbosely=true) ?proof (loc,c) =
current_timeout := Some n;
aux ?locality ?polymorphism isprogcmd v
| VernacRedirect (s, (_,v)) ->
- Topfmt.with_output_to_file s (aux false) v
+ Topfmt.with_output_to_file s (aux ?locality ?polymorphism isprogcmd) v
| VernacTime (_,v) ->
System.with_time !Flags.time
(aux ?locality ?polymorphism isprogcmd) v;
diff --git a/vernac/vernacentries.mli b/vernac/vernacentries.mli
index 7cdc8dd064..fb2899515f 100644
--- a/vernac/vernacentries.mli
+++ b/vernac/vernacentries.mli
@@ -11,42 +11,15 @@ open Misctypes
val dump_global : Libnames.reference or_by_notation -> unit
(** Vernacular entries *)
-
-val show_prooftree : unit -> unit
-
-val show_node : unit -> unit
-
val vernac_require :
Libnames.reference option -> bool option -> Libnames.reference list -> unit
-(** This function can be used by any command that want to observe terms
- in the context of the current goal *)
-val get_current_context_of_args : int option -> Evd.evar_map * Environ.env
-
(** The main interpretation function of vernacular expressions *)
-val interp :
+val interp :
?verbosely:bool ->
?proof:Proof_global.closed_proof ->
Loc.t * Vernacexpr.vernac_expr -> unit
-(** Print subgoals when the verbose flag is on.
- Meant to be used inside vernac commands from plugins. *)
-
-val print_subgoals : unit -> unit
-val try_print_subgoals : unit -> unit
-
-(** The printing of goals via [print_subgoals] or during
- [interp] can be controlled by the following flag.
- Used for instance by coqide, since it has its own
- goal-fetching mechanism. *)
-
-val enable_goal_printing : bool ref
-
-(** Should Qed try to display the proof script ?
- True by default, but false in ProofGeneral and coqIDE *)
-
-val qed_display_script : bool ref
-
(** Prepare a "match" template for a given inductive type.
For each branch of the match, we list the constructor name
followed by enough pattern variables.
@@ -55,9 +28,6 @@ val qed_display_script : bool ref
val make_cases : string -> string list list
-val vernac_end_proof :
- ?proof:Proof_global.closed_proof -> Vernacexpr.proof_end -> unit
-
val with_fail : bool -> (unit -> unit) -> unit
val command_focus : unit Proof.focus_kind
diff --git a/vernac/vernacprop.ml b/vernac/vernacprop.ml
new file mode 100644
index 0000000000..ec78d6012f
--- /dev/null
+++ b/vernac/vernacprop.ml
@@ -0,0 +1,53 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(************************************************************************)
+
+(* We define some high-level properties of vernacular commands, used
+ mainly by the UI components *)
+
+open Vernacexpr
+
+(* Navigation commands are allowed in a coqtop session but not in a .v file *)
+let rec is_navigation_vernac = function
+ | VernacResetInitial
+ | VernacResetName _
+ | VernacBacktrack _
+ | VernacBackTo _
+ | VernacBack _
+ | VernacStm _ -> true
+ | VernacRedirect (_, (_,c))
+ | VernacTime (_,c) ->
+ is_navigation_vernac c (* Time Back* is harmless *)
+ | c -> is_deep_navigation_vernac c
+
+and is_deep_navigation_vernac = function
+ | VernacTimeout (_,c) | VernacFail c -> is_navigation_vernac c
+ | _ -> false
+
+(* NB: Reset is now allowed again as asked by A. Chlipala *)
+let is_reset = function
+ | VernacResetInitial | VernacResetName _ -> true
+ | _ -> false
+
+let is_debug cmd = match cmd with
+ | VernacSetOption (["Ltac";"Debug"], _) -> true
+ | _ -> false
+
+let is_query cmd = match cmd with
+ | VernacChdir None
+ | VernacMemOption _
+ | VernacPrintOption _
+ | VernacCheckMayEval _
+ | VernacGlobalCheck _
+ | VernacPrint _
+ | VernacSearch _
+ | VernacLocate _ -> true
+ | _ -> false
+
+let is_undo cmd = match cmd with
+ | VernacUndo _ | VernacUndoTo _ -> true
+ | _ -> false
diff --git a/vernac/vernacprop.mli b/vernac/vernacprop.mli
new file mode 100644
index 0000000000..c235ecfb57
--- /dev/null
+++ b/vernac/vernacprop.mli
@@ -0,0 +1,19 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* <O___,, * INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016 *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(************************************************************************)
+
+(* We define some high-level properties of vernacular commands, used
+ mainly by the UI components *)
+
+open Vernacexpr
+
+val is_navigation_vernac : vernac_expr -> bool
+val is_deep_navigation_vernac : vernac_expr -> bool
+val is_reset : vernac_expr -> bool
+val is_query : vernac_expr -> bool
+val is_debug : vernac_expr -> bool
+val is_undo : vernac_expr -> bool