diff options
161 files changed, 2912 insertions, 2920 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 267da478d7..51fc2b035c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -346,7 +346,9 @@ /dev/tools/pre-commit @SkySkimmer -/dev/tools/sudo-apt-get-update @JasonGross - /dev/tools/check-owners*.sh @SkySkimmer # Secondary maintainer @maximedenes + +/dev/tools/update-compat.py @JasonGross +/test-suite/tools/update-compat/ @JasonGross +# Secondary maintainer @Zimmi48 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a6b17fd148..dae412923b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ stages: variables: # Format: $IMAGE-V$DATE [Cache is not used as of today but kept here # for reference] - CACHEKEY: "bionic_coq-V2018-09-24-V01" + CACHEKEY: "bionic_coq-V2018-09-25-V1" IMAGE: "$CI_REGISTRY_IMAGE:$CACHEKEY" # By default, jobs run in the base switch; override to select another switch OPAM_SWITCH: "base" @@ -419,6 +419,9 @@ ci-mtac2: ci-pidetop: <<: *ci-template +ci-plugin-tutorial: + <<: *ci-template + ci-quickchick: <<: *ci-template-flambda diff --git a/.travis.yml b/.travis.yml index 1a2c909c7d..6f625b1c75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,88 +9,26 @@ sudo: required language: c cache: - apt: true directories: - $HOME/.opam before_cache: - rm -rf ~/.opam/log/ -addons: - apt: - sources: - - avsm -## Due to issues like -## https://github.com/travis-ci/travis-ci/issues/8507 , -## https://github.com/travis-ci/travis-ci/issues/9000 , -## https://github.com/travis-ci/travis-ci/issues/9081 , and -## https://github.com/travis-ci/travis-ci/issues/9126 , we get frequent -## failures with using `packages`. Therefore, for most targets, we -## instead invoke `apt-get update` manually with `travis_retry` before -## invoking `apt-get install`, manually, below in the `install:` -## target. -# packages: -# - opam -# - aspcud -# - gcc-multilib - env: global: - NJOBS=2 - # system is == 4.02.3 - - COMPILER="system" - - COMPILER_BE="4.07.0" - - DUNE_VER=".1.1.1" - - CAMLP5_VER=".6.14" - - CAMLP5_VER_BE=".7.06" - - FINDLIB_VER=".1.4.1" - - FINDLIB_VER_BE=".1.8.0" - - LABLGTK="lablgtk.2.18.3 conf-gtksourceview.2" - - LABLGTK_BE="lablgtk.2.18.6 conf-gtksourceview.2" + - COMPILER="4.07.0" + - DUNE_VER=".1.2.1" + - CAMLP5_VER=".7.06" + - FINDLIB_VER=".1.8.0" + - LABLGTK="lablgtk.2.18.6 conf-gtksourceview.2" - NATIVE_COMP="yes" - COQ_DEST="-local" - MAIN_TARGET="world" matrix: - include: - - if: NOT (type = pull_request) - env: - - TEST_TARGET="test-suite" COMPILER="4.02.3+32bit" EXTRA_OPAM="ounit" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="validate" TW="travis_wait" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="validate" COMPILER="4.02.3+32bit" TW="travis_wait" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="validate" COMPILER="${COMPILER_BE}+flambda" CAMLP5_VER="${CAMLP5_VER_BE}" EXTRA_CONF="-flambda-opts -O3" FINDLIB_VER="${FINDLIB_VER_BE}" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-coq-dpdgraph" EXTRA_OPAM="ocamlgraph" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-coquelicot" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-equations" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-flocq" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-hott" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-ltac2" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-mtac2" - - if: NOT (type = pull_request) - env: - - TEST_TARGET="ci-pidetop" - - env: - TEST_TARGET="lint" install: [] @@ -102,64 +40,9 @@ matrix: script: - dev/lint-repository.sh - # Full Coq test-suite with two compilers - - if: NOT (type = pull_request) - env: - - TEST_TARGET="doc-html test-suite" - - EXTRA_CONF="-coqide opt" - - EXTRA_OPAM="${LABLGTK} ounit" - before_install: &sphinx-install - - sudo pip3 install bs4 sphinx sphinx_rtd_theme pexpect antlr4-python3-runtime sphinxcontrib-bibtex - addons: - apt: - sources: - - avsm - packages: &extra-packages - - opam - - aspcud - - libgtk2.0-dev - - libgtksourceview2.0-dev - - python3 - - python3-pip - - python3-setuptools - - - if: NOT (type = pull_request) - env: - - TEST_TARGET="doc-html test-suite" - - COMPILER="${COMPILER_BE}" - - FINDLIB_VER="${FINDLIB_VER_BE}" - - CAMLP5_VER="${CAMLP5_VER_BE}" - - EXTRA_CONF="-coqide opt" - - EXTRA_OPAM="${LABLGTK_BE} ounit" - before_install: *sphinx-install - addons: - apt: - sources: - - avsm - packages: *extra-packages - - # Full test-suite with flambda - - if: NOT (type = pull_request) - env: - - TEST_TARGET="doc-html test-suite" - - COMPILER="${COMPILER_BE}+flambda" - - FINDLIB_VER="${FINDLIB_VER_BE}" - - CAMLP5_VER="${CAMLP5_VER_BE}" - - EXTRA_CONF="-coqide opt -flambda-opts -O3" - - EXTRA_OPAM="${LABLGTK_BE} ounit" - before_install: *sphinx-install - addons: - apt: - sources: - - avsm - packages: *extra-packages - - os: osx env: - TEST_TARGET="test-suite" - - COMPILER="${COMPILER_BE}" - - FINDLIB_VER="${FINDLIB_VER_BE}" - - CAMLP5_VER="${CAMLP5_VER_BE}" - NATIVE_COMP="no" - COQ_DEST="-local" - EXTRA_OPAM="ounit" @@ -169,19 +52,22 @@ matrix: - brew install gnu-time # only way to continue using OPAM 1.2 - brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d156edeeed7291f4bc1e08620b331bbd05d52b78/Formula/opam.rb + - opam init -j "$NJOBS" --compiler="$COMPILER" -n -y + - opam switch "$COMPILER" && opam update + - eval $(opam config env) + - opam config list + - opam install -j "$NJOBS" -y num ocamlfind${FINDLIB_VER} dune${DUNE_VER} camlp5${CAMLP5_VER} ${EXTRA_OPAM} + - opam list - if: NOT (type = pull_request) os: osx osx_image: xcode7.3 env: - TEST_TARGET="" - - COMPILER="${COMPILER_BE}" - - FINDLIB_VER="${FINDLIB_VER_BE}" - - CAMLP5_VER="${CAMLP5_VER_BE}" - NATIVE_COMP="no" - - COQ_DEST="-prefix ${PWD}/_install" + - COQ_DEST="-prefix $PWD/_install_ci" - EXTRA_CONF="-coqide opt -warn-error yes" - - EXTRA_OPAM="${LABLGTK_BE}" + - EXTRA_OPAM="$LABLGTK" before_install: - brew update - brew unlink python @@ -191,6 +77,12 @@ matrix: - brew unlink python@2 - brew install python3 - pip3 install macpack + - opam init -j "$NJOBS" --compiler="$COMPILER" -n -y + - opam switch "$COMPILER" && opam update + - eval $(opam config env) + - opam config list + - opam install -j "$NJOBS" -y num ocamlfind${FINDLIB_VER} dune${DUNE_VER} camlp5${CAMLP5_VER} ${EXTRA_OPAM} + - opam list before_deploy: - dev/build/osx/make-macos-dmg.sh deploy: @@ -204,17 +96,7 @@ matrix: all_branches: true before_install: -- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then echo "Tested commit (followed by parent commits):"; git log -1; for commit in `git log -1 --format="%P"`; do echo; git log -1 $commit; done; fi - -install: -- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then travis_retry ./dev/tools/sudo-apt-get-update.sh -q; fi -- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then sudo apt-get install -y opam aspcud gcc-multilib --allow-unauthenticated; fi -- opam init -j ${NJOBS} --compiler=${COMPILER} -n -y -- opam switch "$COMPILER" && opam update -- eval $(opam config env) -- opam config list -- opam install -j ${NJOBS} -y num ocamlfind${FINDLIB_VER} dune${DUNE_VER} camlp5${CAMLP5_VER} ${EXTRA_OPAM} -- opam list +- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then echo "Tested commit (followed by parent commits):"; git log -1; for commit in `git log -1 --format="%P"`; do echo; git log -1 $commit; done; fi script: @@ -224,15 +106,15 @@ script: - echo -en 'travis_fold:end:coq.clean\\r' - echo 'Configuring Coq...' && echo -en 'travis_fold:start:coq.config\\r' -- ./configure ${COQ_DEST} -warn-error yes -native-compiler ${NATIVE_COMP} ${EXTRA_CONF} +- ./configure $COQ_DEST -warn-error yes -native-compiler $NATIVE_COMP $EXTRA_CONF - echo -en 'travis_fold:end:coq.config\\r' - echo 'Building Coq...' && echo -en 'travis_fold:start:coq.build\\r' -- make -j ${NJOBS} ${MAIN_TARGET} +- make -j $NJOBS $MAIN_TARGET - echo -en 'travis_fold:end:coq.build\\r' - echo 'Running tests...' && echo -en 'travis_fold:start:coq.test\\r' -- if [ -n "${TEST_TARGET}" ]; then ${TW} make -j ${NJOBS} ${TEST_TARGET}; fi +- if [ -n "$TEST_TARGET" ]; then $TW make -j $NJOBS $TEST_TARGET; fi - echo -en 'travis_fold:end:coq.test\\r' - set +e @@ -1,5 +1,10 @@ -Changes beyond 8.9 -================== +Changes from 8.9 to 8.10 +======================== + +OCaml + +- Coq 8.10 requires OCaml >= 4.05.0, bumped from 4.02.3 See the + INSTALL file for more information on dependencies. Plugins @@ -180,6 +185,8 @@ Vernacular Commands scope. If you want the previous behavior, use `Global Set SsrHave NoTCResolution`. - Multiple sections with the same name are allowed. +- Combined Scheme can now work when inductive schemes are generated in sort + Type. It used to be limited to sort Prop. Coq binaries and process model @@ -29,7 +29,7 @@ WHAT DO YOU NEED ? To compile Coq yourself, you need: - - OCaml (version >= 4.02.3) + - OCaml (version >= 4.05.0) (available at https://ocaml.org/) (This version of Coq has been tested up to OCaml 4.07.0) @@ -39,7 +39,7 @@ WHAT DO YOU NEED ? - Findlib (version >= 1.4.1) (available at http://projects.camlcity.org/projects/findlib.html) - - Camlp5 (version >= 6.14) + - Camlp5 (version >= 7.01) (available at https://camlp5.github.io/) - GNU Make version 3.81 or later @@ -88,7 +88,7 @@ INSTALLATION PROCEDURE IN DETAILS (NORMAL USERS). computer and that "ocamlc" (or, better, its native code version "ocamlc.opt") lies in a directory which is present in your $PATH environment variable. At the time of writing this sentence, all - versions of Objective Caml later or equal to 4.02.3 are + versions of Objective Caml later or equal to 4.05.0 are supported. To get Coq in native-code, (it runs 4 to 10 times faster than diff --git a/Makefile.ci b/Makefile.ci index e86504b76d..fb4f275e9e 100644 --- a/Makefile.ci +++ b/Makefile.ci @@ -34,6 +34,7 @@ CI_TARGETS=ci-bedrock2 \ ci-math-comp \ ci-mtac2 \ ci-pidetop \ + ci-plugin-tutorial \ ci-quickchick \ ci-sf \ ci-simple-io \ @@ -59,7 +60,7 @@ ci-quickchick: ci-ext-lib ci-simple-io ci-formal-topology: ci-corn -# Generic rule, we use make to ease travis integration with mixed rules +# Generic rule, we use make to ease CI integration $(CI_TARGETS): ci-%: +./dev/ci/ci-wrapper.sh $* diff --git a/Makefile.dune b/Makefile.dune index 1e401a57b9..ac5f584b90 100644 --- a/Makefile.dune +++ b/Makefile.dune @@ -1,7 +1,7 @@ # -*- mode: makefile -*- # Dune Makefile for Coq -.PHONY: help voboot states world apidoc +.PHONY: help voboot states world watch release apidoc clean # use DUNEOPT=--display=short for a more verbose build # DUNEOPT=--display=short @@ -15,6 +15,7 @@ help: @echo " - watch: build all binaries and libraries [continuous build]" @echo " - release: build Coq in release mode" @echo " - apidoc: build ML API documentation" + @echo " - ocheck: build for all supported OCaml versions [requires OPAM]" @echo " - clean: remove build directory and autogenerated files" @echo " - help: show this message" @@ -28,6 +29,9 @@ states: voboot world: voboot dune build $(DUNEOPT) @install +ocheck: voboot + dune build $(DUNEOPT) @install --workspace=dev/dune-workspace.all + watch: voboot dune build $(DUNEOPT) @install -w diff --git a/checker/checker.ml b/checker/checker.ml index fd2725c859..d3d114d7d7 100644 --- a/checker/checker.ml +++ b/checker/checker.ml @@ -321,8 +321,7 @@ let parse_args argv = | "-coqlib" :: s :: rem -> if not (exists_dir s) then fatal_error (str "Directory '" ++ str s ++ str "' does not exist") false; - Flags.coqlib := s; - Flags.coqlib_spec := true; + Envars.set_user_coqlib s; parse rem | ("-I"|"-include") :: d :: "-as" :: p :: rem -> deprecated "-I"; set_include d p; parse rem diff --git a/config/coq_config.mli b/config/coq_config.mli index 29065d3ef8..22d8c49fd1 100644 --- a/config/coq_config.mli +++ b/config/coq_config.mli @@ -23,26 +23,17 @@ val configdirsuffix : string (* config files relative to installation prefix *) val datadirsuffix : string (* data files relative to installation prefix *) val docdirsuffix : string (* doc directory relative to installation prefix *) -val ocaml : string (* names of ocaml binaries *) val ocamlfind : string -val ocamllex : string - -val camlbin : string (* base directory of OCaml binaries *) -val camllib : string (* for Dynlink *) val camlp5o : string (* name of the camlp5o executable *) val camlp5bin : string (* base directory for camlp5 binaries *) val camlp5lib : string (* where is the library of camlp5 *) val camlp5compat : string (* compatibility argument to camlp5 *) -val coqideincl : string (* arguments for building coqide (e.g. lablgtk) *) -val cflags : string (* arguments passed to gcc *) val caml_flags : string (* arguments passed to ocamlc (ie. CAMLFLAGS) *) -val best : string (* byte/opt *) val arch : string (* architecture *) val arch_is_win32 : bool -val vmbyteflags : string list (* -custom/-dllib -lcoqrun *) val version : string (* version number of Coq *) val caml_version : string (* OCaml version used to compile Coq *) @@ -52,8 +43,6 @@ val compile_date : string (* compile date *) val vo_magic_number : int val state_magic_number : int -val core_src_dirs : string list -val plugins_dirs : string list val all_src_dirs : string list val exec_extension : string (* "" under Unix, ".exe" under MS-windows *) @@ -62,13 +51,9 @@ val browser : string (** default web browser to use, may be overridden by environment variable COQREMOTEBROWSER *) -val has_coqide : string val gtk_platform : [`QUARTZ | `WIN32 | `X11] val has_natdynlink : bool -val natdynlinkflag : string (* special cases of natdynlink (e.g. MacOS 10.5) *) - -val flambda_flags : string list val wwwcoq : string val wwwrefman : string diff --git a/configure.ml b/configure.ml index da6a6f8cbf..a508ac6071 100644 --- a/configure.ml +++ b/configure.ml @@ -609,14 +609,14 @@ let caml_version_nums = "Is it installed properly?") let check_caml_version () = - if caml_version_nums >= [4;2;3] then + if caml_version_nums >= [4;5;0] then cprintf "You have OCaml %s. Good!" caml_version else let () = cprintf "Your version of OCaml is %s." caml_version in if !prefs.force_caml_version then warn "Your version of OCaml is outdated." else - die "You need OCaml 4.02.3 or later." + die "You need OCaml 4.05.0 or later." let _ = check_caml_version () @@ -656,16 +656,12 @@ let camltag = match caml_version_list with 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 58: "no cmx file was found in path": See https://github.com/ocaml/num/issues/9 *) let coq_warnings = "-w +a-4-9-27-41-42-44-45-48-50-58" let coq_warn_error = if !prefs.warn_error then "-warn-error +a" - ^ (if caml_version_nums > [4;2;3] - then "-56" - else "") else "" (* Flags used to compile Coq and plugins (via coq_makefile) *) @@ -1054,7 +1050,7 @@ let do_one_instdir (var,msg,uservalue,selfcontainedlayout,unixlayout,locallayout try Some (Sys.getenv "COQ_CONFIGURE_PREFIX") with | Not_found when !prefs.interactive -> None - | Not_found -> Some "_build/default/install" + | Not_found -> Some "_build/install/default" end | p -> p in match uservalue, env_prefix with @@ -1187,13 +1183,11 @@ let write_configml f = let pr_i = pr "let %s = %d\n" in let pr_p s o = pr "let %s = %S\n" s (match o with Relative s -> s | Absolute s -> s) in - let pr_l n l = pr "let %s = [%s]\n" n (String.concat ";" (List.map (fun s -> "\"" ^ s ^ "\"") l)) in let pr_li n l = pr "let %s = [%s]\n" n (String.concat ";" (List.map string_of_int l)) in pr "(* DO NOT EDIT THIS FILE: automatically generated by ../configure *)\n"; pr "(* Exact command that generated this file: *)\n"; pr "(* %s *)\n\n" (String.concat " " (Array.to_list Sys.argv)); pr_b "local" !prefs.local; - pr "let vmbyteflags = ["; List.iter (pr "%S;") vmbyteflags; pr "]\n"; pr_s "coqlib" coqlib; pr_s "configdir" configdir; pr_s "datadir" datadir; @@ -1202,18 +1196,12 @@ let write_configml f = pr_p "configdirsuffix" configdirsuffix; pr_p "datadirsuffix" datadirsuffix; pr_p "docdirsuffix" docdirsuffix; - pr_s "ocaml" camlexec.top; pr_s "ocamlfind" camlexec.find; - pr_s "ocamllex" camlexec.lex; - pr_s "camlbin" camlbin; - pr_s "camllib" camllib; pr_s "camlp5o" camlp5o; pr_s "camlp5bin" camlp5bindir; pr_s "camlp5lib" camlp5libdir; pr_s "camlp5compat" camlp5compat; - pr_s "cflags" cflags; pr_s "caml_flags" caml_flags; - pr_s "best" best_compiler; pr_s "version" coq_version; pr_s "caml_version" caml_version; pr_li "caml_version_nums" caml_version_nums; @@ -1222,12 +1210,8 @@ let write_configml f = pr_s "arch" arch; pr_b "arch_is_win32" arch_is_win32; pr_s "exec_extension" exe; - pr_s "coqideincl" !lablgtkincludes; - pr_s "has_coqide" coqide; pr "let gtk_platform = `%s\n" !idearchdef; pr_b "has_natdynlink" hasnatdynlink; - pr_s "natdynlinkflag" natdynlinkflag; - pr_l "flambda_flags" !prefs.flambda_flags; pr_i "vo_magic_number" vo_magic; pr_i "state_magic_number" state_magic; pr_s "browser" browser; diff --git a/coqpp/coqpp_ast.mli b/coqpp/coqpp_ast.mli index 181c43615b..956a916792 100644 --- a/coqpp/coqpp_ast.mli +++ b/coqpp/coqpp_ast.mli @@ -11,7 +11,7 @@ type loc = { loc_end : Lexing.position; } -type code = { code : string } +type code = { code : string; loc : loc; } type user_symbol = | Ulist1 of user_symbol diff --git a/coqpp/coqpp_lex.mll b/coqpp/coqpp_lex.mll index bfa4e2b57b..81a53e887b 100644 --- a/coqpp/coqpp_lex.mll +++ b/coqpp/coqpp_lex.mll @@ -29,6 +29,7 @@ let newline lexbuf = let num_comments = ref 0 let num_braces = ref 0 +let ocaml_start_pos = ref Lexing.dummy_pos let mode () = if !num_braces = 0 then Extend else OCaml @@ -57,10 +58,10 @@ let end_comment lexbuf = else None -let start_ocaml _ = +let start_ocaml lexbuf = let () = match mode () with | OCaml -> Buffer.add_string ocaml_buf "{" - | Extend -> () + | Extend -> ocaml_start_pos := lexeme_start_p lexbuf in incr num_braces @@ -70,7 +71,11 @@ let end_ocaml lexbuf = else if !num_braces = 0 then let s = Buffer.contents ocaml_buf in let () = Buffer.reset ocaml_buf in - Some (CODE { Coqpp_ast.code = s }) + let loc = { + Coqpp_ast.loc_start = !ocaml_start_pos; + Coqpp_ast.loc_end = lexeme_end_p lexbuf + } in + Some (CODE { Coqpp_ast.code = s; loc }) else let () = Buffer.add_string ocaml_buf "}" in None @@ -87,7 +92,7 @@ let number = [ '0'-'9' ] rule extend = parse | "(*" { start_comment (); comment lexbuf } -| "{" { start_ocaml (); ocaml lexbuf } +| "{" { start_ocaml lexbuf; ocaml lexbuf } | "GRAMMAR" { GRAMMAR } | "VERNAC" { VERNAC } | "TACTIC" { TACTIC } @@ -127,7 +132,7 @@ rule extend = parse | eof { EOF } and ocaml = parse -| "{" { start_ocaml (); ocaml lexbuf } +| "{" { start_ocaml lexbuf; ocaml lexbuf } | "}" { match end_ocaml lexbuf with Some tk -> tk | None -> ocaml lexbuf } | '\n' { newline lexbuf; Buffer.add_char ocaml_buf '\n'; ocaml lexbuf } | '\"' { Buffer.add_char ocaml_buf '\"'; ocaml_string lexbuf } diff --git a/coqpp/coqpp_main.ml b/coqpp/coqpp_main.ml index a8ed95f5ba..d9fff46d88 100644 --- a/coqpp/coqpp_main.ml +++ b/coqpp/coqpp_main.ml @@ -21,6 +21,13 @@ let pr_loc loc = let epos = loc.loc_end.pos_cnum - loc.loc_start.pos_bol in Printf.sprintf "File \"%s\", line %d, characters %d-%d:" file line bpos epos +let print_code fmt c = + let loc = c.loc.loc_start in + (** Print the line location as a source annotation *) + let padding = String.make (loc.pos_cnum - loc.pos_bol + 1) ' ' in + let code_insert = asprintf "\n# %i \"%s\"\n%s%s" loc.pos_lnum loc.pos_fname padding c.code in + fprintf fmt "@[@<0>%s@]@\n" code_insert + let parse_file f = let chan = open_in f in let lexbuf = Lexing.from_channel chan in @@ -181,8 +188,7 @@ let print_fun fmt (vars, body) = in let () = fprintf fmt "fun@ " in let () = List.iter iter vars in - (* FIXME: use Coq locations in the macros *) - let () = fprintf fmt "loc ->@ @[%s@]" body.code in + let () = fprintf fmt "loc ->@ @[%a@]" print_code body in () (** Meta-program instead of calling Tok.of_pattern here because otherwise @@ -304,8 +310,8 @@ let rec print_binders fmt = function fprintf fmt "%s@ %a" id print_binders rem let print_rule fmt r = - fprintf fmt "@[TyML (%a, @[fun %a -> %s@])@]" - print_clause r.tac_toks print_binders r.tac_toks r.tac_body.code + fprintf fmt "@[TyML (%a, @[fun %a -> %a@])@]" + print_clause r.tac_toks print_binders r.tac_toks print_code r.tac_body let rec print_rules fmt = function | [] -> () @@ -338,7 +344,7 @@ let declare_plugin fmt name = fprintf fmt "let _ = Mltop.add_known_module %s@\n" plugin_name let pr_ast fmt = function -| Code s -> fprintf fmt "%s@\n" s.code +| Code s -> fprintf fmt "%a@\n" print_code s | Comment s -> fprintf fmt "%s@\n" s | DeclarePlugin name -> declare_plugin fmt name | GramExt gram -> fprintf fmt "%a@\n" GramExt.print_ast gram diff --git a/default.nix b/default.nix index 29c0c68174..1faaafae03 100644 --- a/default.nix +++ b/default.nix @@ -23,8 +23,8 @@ { pkgs ? (import (fetchTarball { - url = "https://github.com/NixOS/nixpkgs/archive/52a1179b6c20e923beddde1dd1e0034aa19176d2.tar.gz"; - sha256 = "040xrsgnip6gqljfyy1ad0l7q41h659h5hqbcn96bzhdiakcr4yc"; + url = "https://github.com/NixOS/nixpkgs/archive/4c95508641fe780efe41885366e03339b95d04fb.tar.gz"; + sha256 = "1wjspwhzdb6d1kz4khd9l0fivxdk2nq3qvj93pql235sb7909ygx"; }) {}) , ocamlPackages ? pkgs.ocaml-ng.ocamlPackages_4_06 , buildIde ? true @@ -55,6 +55,7 @@ stdenv.mkDerivation rec { (ps: [ ps.sphinx ps.sphinx_rtd_theme ps.pexpect ps.beautifulsoup4 ps.antlr4-python3-runtime ps.sphinxcontrib-bibtex ])) antlr4 + ocamlPackages.odoc ] ++ optionals doInstallCheck ( # Test-suite dependencies diff --git a/dev/build/windows/MakeCoq_MinGW.bat b/dev/build/windows/MakeCoq_MinGW.bat index 61cf6bc4cc..33feeed45c 100755 --- a/dev/build/windows/MakeCoq_MinGW.bat +++ b/dev/build/windows/MakeCoq_MinGW.bat @@ -1,488 +1,488 @@ -@ECHO OFF - -REM ========== COPYRIGHT/COPYLEFT ========== - -REM (C) 2016 Intel Deutschland GmbH -REM Author: Michael Soegtrop - -REM Released to the public by Intel under the -REM GNU Lesser General Public License Version 2.1 or later -REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html - -REM ========== NOTES ========== - -REM For Cygwin setup command line options -REM see https://cygwin.com/faq/faq.html#faq.setup.cli - -REM ========== DEFAULT VALUES FOR PARAMETERS ========== - -REM For a description of all parameters, see ReadMe.txt - -SET BATCHFILE=%~0 -SET BATCHDIR=%~dp0 - -REM see -arch in ReadMe.txt, but values are x86_64 or i686 (not 64 or 32) -SET ARCH=x86_64 - -REM see -mode in ReadMe.txt -SET INSTALLMODE=absolute - -REM see -installer in ReadMe.txt -SET MAKEINSTALLER=N - -REM see -ocaml in ReadMe.txt -SET INSTALLOCAML=N - -REM see -make in ReadMe.txt -SET INSTALLMAKE=N - -REM see -destcyg in ReadMe.txt -SET DESTCYG=C:\bin\cygwin_coq - -REM see -destcoq in ReadMe.txt -SET DESTCOQ=C:\bin\coq - -REM see -setup in ReadMe.txt -SET SETUP=setup-x86_64.exe - -REM see -proxy in ReadMe.txt -IF DEFINED HTTP_PROXY ( - SET PROXY=%HTTP_PROXY:http://=% -) else ( - REM One can't set a variable to empty in DOS, but you can set it to a space this way. - REM The quotes are just there to make the space visible and to protect from "remove trailing spaces". - SET "PROXY= " -) - -REM see -cygrepo in ReadMe.txt -SET CYGWIN_REPOSITORY=http://ftp.inf.tu-dresden.de/software/windows/cygwin32 - -REM see -cygcache in ReadMe.txt -SET CYGWIN_LOCAL_CACHE_WFMT=%BATCHDIR%cygwin_cache - -REM see -cyglocal in ReadMe.txt -SET CYGWIN_FROM_CACHE=N - -REM see -cygquiet in ReadMe.txt -SET CYGWIN_QUIET=Y - -REM see -srccache in ReadMe.txt -SET SOURCE_LOCAL_CACHE_WFMT=%BATCHDIR%source_cache - -REM see -coqver in ReadMe.txt -SET COQ_VERSION=8.5pl3 - -REM see -gtksrc in ReadMe.txt -SET GTK_FROM_SOURCES=N - -REM see -threads in ReadMe.txt -SET MAKE_THREADS=8 - -REM see -addon in ReadMe.txt -SET "COQ_ADDONS= " - -REM ========== PARSE COMMAND LINE PARAMETERS ========== - -SHIFT - -:Parse - -IF "%~0" == "-arch" ( - IF "%~1" == "32" ( - SET ARCH=i686 - SET SETUP=setup-x86.exe - ) ELSE ( - IF "%~1" == "64" ( - SET ARCH=x86_64 - SET SETUP=setup-x86_64.exe - ) ELSE ( - ECHO "Invalid -arch, valid are 32 and 64" - GOTO :EOF - ) - ) - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-mode" ( - IF "%~1" == "mingwincygwin" ( - SET INSTALLMODE=%~1 - ) ELSE ( - IF "%~1" == "absolute" ( - SET INSTALLMODE=%~1 - ) ELSE ( - IF "%~1" == "relocatable" ( - SET INSTALLMODE=%~1 - ) ELSE ( - ECHO "Invalid -mode, valid are mingwincygwin, absolute and relocatable" - GOTO :EOF - ) - ) - ) - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-installer" ( - SET MAKEINSTALLER=%~1 - CALL :CheckYN -installer %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-ocaml" ( - SET INSTALLOCAML=%~1 - CALL :CheckYN -installer %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-make" ( - SET INSTALLMAKE=%~1 - CALL :CheckYN -installer %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-destcyg" ( - SET DESTCYG=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-destcoq" ( - SET DESTCOQ=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-setup" ( - SET SETUP=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-proxy" ( - SET PROXY=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-cygrepo" ( - SET CYGWIN_REPOSITORY=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-cygcache" ( - SET CYGWIN_LOCAL_CACHE_WFMT=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-cyglocal" ( - SET CYGWIN_FROM_CACHE=%~1 - CALL :CheckYN -cyglocal %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-cygquiet" ( - SET CYGWIN_QUIET=%~1 - CALL :CheckYN -cygquiet %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-srccache" ( - SET SOURCE_LOCAL_CACHE_WFMT=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-coqver" ( - SET COQ_VERSION=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-gtksrc" ( - SET GTK_FROM_SOURCES=%~1 - CALL :CheckYN -gtksrc %~1 || GOTO ErrorExit - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-threads" ( - SET MAKE_THREADS=%~1 - SHIFT - SHIFT - GOTO Parse -) - -IF "%~0" == "-addon" ( - SET "COQ_ADDONS=%COQ_ADDONS% %~1" - SHIFT - SHIFT - GOTO Parse -) - - -IF NOT "%~0" == "" ( - ECHO Install cygwin and download, compile and install OCaml and Coq for MinGW - ECHO !!! Illegal parameter %~0 - ECHO Usage: - ECHO MakeCoq_MinGW - CALL :PrintPars - GOTO :EOF -) - -IF NOT EXIST %SETUP% ( - ECHO The cygwin setup program %SETUP% doesn't exist. You must download it from https://cygwin.com/install.html. - ECHO If the setup is in a different folder, set the full path to %SETUP% using the -setup option. - GOTO :EOF -) - -REM ========== ADJUST PARAMETERS ========== - -IF "%INSTALLMODE%" == "mingwincygwin" ( - SET DESTCOQ=%DESTCYG%\usr\%ARCH%-w64-mingw32\sys-root\mingw -) - -IF "%MAKEINSTALLER%" == "Y" ( - SET INSTALLMODE=relocatable -) - -REM ========== CONFIRM PARAMETERS ========== - -CALL :PrintPars -REM Note: DOS batch replaces variables on parsing, so one can't use a variable just set in an () block -IF "%COQREGTESTING%"=="Y" (GOTO DontAsk) - SET /p ANSWER="Is this correct? y/n " - IF NOT "%ANSWER%"=="y" (GOTO :EOF) -:DontAsk - -REM ========== DERIVED VARIABLES ========== - -SET CYGWIN_INSTALLDIR_WFMT=%DESTCYG% -SET RESULT_INSTALLDIR_WFMT=%DESTCOQ% -SET TARGET_ARCH=%ARCH%-w64-mingw32 -SET BASH=%CYGWIN_INSTALLDIR_WFMT%\bin\bash - -REM Convert pathes to various formats -REM WFMT = windows format (C:\..) Used in this batch file. -REM CFMT = cygwin format (\cygdrive\c\..) Used for Cygwin PATH varible, which is : separated, so C: doesn't work. -REM MFMT = MinGW format (C:/...) Used for the build, because \\ requires escaping. Mingw can handle \ and /. - -SET CYGWIN_INSTALLDIR_MFMT=%CYGWIN_INSTALLDIR_WFMT:\=/% -SET RESULT_INSTALLDIR_MFMT=%RESULT_INSTALLDIR_WFMT:\=/% -SET SOURCE_LOCAL_CACHE_MFMT=%SOURCE_LOCAL_CACHE_WFMT:\=/% - -SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_MFMT:C:/=/cygdrive/c/% -SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_MFMT:C:/=/cygdrive/c/% -SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_MFMT:C:/=/cygdrive/c/% - -SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_CFMT:D:/=/cygdrive/d/% -SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_CFMT:D:/=/cygdrive/d/% -SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_CFMT:D:/=/cygdrive/d/% - -SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_CFMT:E:/=/cygdrive/e/% -SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_CFMT:E:/=/cygdrive/e/% -SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_CFMT:E:/=/cygdrive/e/% - -ECHO CYGWIN INSTALL DIR (WIN) = %CYGWIN_INSTALLDIR_WFMT% -ECHO CYGWIN INSTALL DIR (MINGW) = %CYGWIN_INSTALLDIR_MFMT% -ECHO CYGWIN INSTALL DIR (CYGWIN) = %CYGWIN_INSTALLDIR_CFMT% -ECHO RESULT INSTALL DIR (WIN) = %RESULT_INSTALLDIR_WFMT% -ECHO RESULT INSTALL DIR (MINGW) = %RESULT_INSTALLDIR_MFMT% -ECHO RESULT INSTALL DIR (CYGWIN) = %RESULT_INSTALLDIR_CFMT% - -REM WARNING: Add a space after the = in case you want set this to empty, otherwise the variable will be unset -SET MAKE_OPT=-j %MAKE_THREADS% - -REM ========== DERIVED CYGWIN SETUP OPTIONS ========== - -REM One can't set a variable to empty in DOS, but you can set it to a space this way. -REM The quotes are just there to make the space visible and to protect from "remove trailing spaces". -SET "CYGWIN_OPT= " - -IF "%CYGWIN_FROM_CACHE%" == "Y" ( - SET CYGWIN_OPT= %CYGWIN_OPT% -L -) - -IF "%CYGWIN_QUIET%" == "Y" ( - SET CYGWIN_OPT= %CYGWIN_OPT% -q --no-admin -) - -IF "%GTK_FROM_SOURCES%"=="N" ( - SET CYGWIN_OPT= %CYGWIN_OPT% -P mingw64-%ARCH%-gtk2.0,mingw64-%ARCH%-gtksourceview2.0 -) - -REM Cygwin setup sets proper ACLs (permissions) for folders it CREATES. -REM Otherwise chmod won't work and e.g. the ocaml build will fail. -REM Cygwin setup does not touch the ACLs of existing folders. - -REM Run Cygwin Setup - -SET RUNSETUP=Y -IF EXIST "%CYGWIN_INSTALLDIR_WFMT%\etc\setup\installed.db" ( - SET RUNSETUP=N -) -IF NOT "%CYGWIN_QUIET%" == "Y" ( - SET RUNSETUP=Y -) - -IF "%COQREGTESTING%" == "Y" ( - ECHO "========== REMOVE EXISTING CYGWIN ==========" - DEL /S /F /Q "%CYGWIN_INSTALLDIR_WFMT%" > NUL - SET RUNSETUP=Y -) - -SET "EXTRAPACKAGES= " - -IF NOT "%APPVEYOR%" == "True" ( - SET EXTRAPACKAGES=-P wget,curl,git,gcc-core,gcc-g++,automake1.5 -) - -ECHO "========== INSTALL CYGWIN ==========" - -IF "%RUNSETUP%"=="Y" ( - %SETUP% ^ - --proxy "%PROXY%" ^ - --site "%CYGWIN_REPOSITORY%" ^ - --root "%CYGWIN_INSTALLDIR_WFMT%" ^ - --local-package-dir "%CYGWIN_LOCAL_CACHE_WFMT%" ^ - --no-shortcuts ^ - %CYGWIN_OPT% ^ - -P make,unzip ^ - -P gdb,liblzma5 ^ - -P patch,automake1.14 ^ - -P mingw64-%ARCH%-binutils,mingw64-%ARCH%-gcc-core,mingw64-%ARCH%-gcc-g++,mingw64-%ARCH%-pkg-config,mingw64-%ARCH%-windows_default_manifest ^ - -P mingw64-%ARCH%-headers,mingw64-%ARCH%-runtime,mingw64-%ARCH%-pthreads,mingw64-%ARCH%-zlib ^ - -P libiconv-devel,libunistring-devel,libncurses-devel ^ - -P gettext-devel,libgettextpo-devel ^ - -P libglib2.0-devel,libgdk_pixbuf2.0-devel ^ - -P libfontconfig1 ^ - -P gtk-update-icon-cache ^ - -P libtool,automake ^ - -P intltool ^ - %EXTRAPACKAGES% ^ - || GOTO ErrorExit - - MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build" - MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\buildlogs" -) - -IF NOT "%CYGWIN_QUIET%" == "Y" ( - REM Like most setup programs, cygwin setup starts the real setup as a separate process, so wait for it. - REM This is not required with the -cygquiet=Y and the resulting --no-admin option. - :waitsetup - tasklist /fi "imagename eq %SETUP%" | find ":" > NUL - IF ERRORLEVEL 1 GOTO waitsetup -) - -ECHO ========== CONFIGURE CYGWIN USER ACCOUNT ========== - -REM In case this batch file is called from a cygwin bash (e.g. a git repo) we need to clear -REM HOME (otherwise we get to the home directory of the other installation) -REM PROFILEREAD (this is set to true if the /etc/profile has been read, which creates user) -SET "HOME=" -SET "PROFILEREAD=" - -copy "%BATCHDIR%\configure_profile.sh" "%CYGWIN_INSTALLDIR_WFMT%\var\tmp" || GOTO ErrorExit -%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\var\tmp\configure_profile.sh" "%PROXY%" || GOTO ErrorExit - -ECHO ========== BUILD COQ ========== - -MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build" -MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\patches" - -COPY "%BATCHDIR%\makecoq_mingw.sh" "%CYGWIN_INSTALLDIR_WFMT%\build" || GOTO ErrorExit -COPY "%BATCHDIR%\patches_coq\*.*" "%CYGWIN_INSTALLDIR_WFMT%\build\patches" || GOTO ErrorExit - -%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\build\makecoq_mingw.sh" || GOTO ErrorExit - -ECHO ========== FINISHED ========== - -GOTO :EOF - -ECHO ========== BATCH FUNCTIONS ========== - -:PrintPars - REM 01234567890123456789012345678901234567890123456789012345678901234567890123456789 - ECHO -arch ^<i686 or x86_64^> Set cygwin, ocaml and coq to 32 or 64 bit - ECHO -mode ^<mingwincygwin = install coq in default cygwin mingw sysroot^> - ECHO ^<absoloute = install coq in -destcoq absulute path^> - ECHO ^<relocatable = install relocatable coq in -destcoq path^> - ECHO -installer^<Y or N^> create a windows installer (will be in /build/coq/dev/nsis) - ECHO -ocaml ^<Y or N^> install OCaml in Coq folder (Y) or just in cygwin folder (N) - ECHO -make ^<Y or N^> install GNU Make in Coq folder (Y) or not (N) - ECHO -destcyg ^<path to cygwin destination folder^> - ECHO -destcoq ^<path to coq destination folder (mode=absoloute/relocatable)^> - ECHO -setup ^<cygwin setup program name^> (auto adjusted to -arch) - ECHO -proxy ^<internet proxy^> - ECHO -cygrepo ^<cygwin download repository^> - ECHO -cygcache ^<local cygwin repository/cache^> - ECHO -cyglocal ^<Y or N^> install cygwin from cache - ECHO -cygquiet ^<Y or N^> install cygwin without user interaction - ECHO -srccache ^<local source code repository/cache^> - ECHO -coqver ^<Coq version to install^> - ECHO -gtksrc ^<Y or N^> build GTK ^(90 min^) or use cygwin version - ECHO -threads ^<1..N^> Number of make threads - ECHO -addon ^<name^> Enable building selected addon (can be repeated) - ECHO( - ECHO See ReadMe.txt for a detailed description of all parameters - ECHO( - ECHO Parameter values (default or currently set): - ECHO -arch = %ARCH% - ECHO -mode = %INSTALLMODE% - ECHO -ocaml = %INSTALLOCAML% - ECHO -installer= %MAKEINSTALLER% - ECHO -make = %INSTALLMAKE% - ECHO -destcyg = %DESTCYG% - ECHO -destcoq = %DESTCOQ% - ECHO -setup = %SETUP% - ECHO -proxy = %PROXY% - ECHO -cygrepo = %CYGWIN_REPOSITORY% - ECHO -cygcache = %CYGWIN_LOCAL_CACHE_WFMT% - ECHO -cyglocal = %CYGWIN_FROM_CACHE% - ECHO -cygquiet = %CYGWIN_QUIET% - ECHO -srccache = %SOURCE_LOCAL_CACHE_WFMT% - ECHO -coqver = %COQ_VERSION% - ECHO -gtksrc = %GTK_FROM_SOURCES% - ECHO -threads = %MAKE_THREADS% - ECHO -addon = %COQ_ADDONS% - GOTO :EOF - -:CheckYN - REM Reset errorlevel to 0 - CMD /c "EXIT /b 0" - IF "%2" == "Y" ( - REM OK Y - ) ELSE IF "%2" == "N" ( - REM OK N - ) ELSE ( - ECHO ERROR Parameter %1 must be Y or N, but is %2 - GOTO ErrorExit - ) - GOTO :EOF - -:ErrorExit - ECHO ERROR MakeCoq_MinGW.bat failed - EXIT /b 1 +@ECHO OFF
+
+REM ========== COPYRIGHT/COPYLEFT ==========
+
+REM (C) 2016 Intel Deutschland GmbH
+REM Author: Michael Soegtrop
+
+REM Released to the public by Intel under the
+REM GNU Lesser General Public License Version 2.1 or later
+REM See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
+
+REM ========== NOTES ==========
+
+REM For Cygwin setup command line options
+REM see https://cygwin.com/faq/faq.html#faq.setup.cli
+
+REM ========== DEFAULT VALUES FOR PARAMETERS ==========
+
+REM For a description of all parameters, see ReadMe.txt
+
+SET BATCHFILE=%~0
+SET BATCHDIR=%~dp0
+
+REM see -arch in ReadMe.txt, but values are x86_64 or i686 (not 64 or 32)
+SET ARCH=x86_64
+
+REM see -mode in ReadMe.txt
+SET INSTALLMODE=absolute
+
+REM see -installer in ReadMe.txt
+SET MAKEINSTALLER=N
+
+REM see -ocaml in ReadMe.txt
+SET INSTALLOCAML=N
+
+REM see -make in ReadMe.txt
+SET INSTALLMAKE=N
+
+REM see -destcyg in ReadMe.txt
+SET DESTCYG=C:\bin\cygwin_coq
+
+REM see -destcoq in ReadMe.txt
+SET DESTCOQ=C:\bin\coq
+
+REM see -setup in ReadMe.txt
+SET SETUP=setup-x86_64.exe
+
+REM see -proxy in ReadMe.txt
+IF DEFINED HTTP_PROXY (
+ SET PROXY=%HTTP_PROXY:http://=%
+) else (
+ REM One can't set a variable to empty in DOS, but you can set it to a space this way.
+ REM The quotes are just there to make the space visible and to protect from "remove trailing spaces".
+ SET "PROXY= "
+)
+
+REM see -cygrepo in ReadMe.txt
+SET CYGWIN_REPOSITORY=http://ftp.inf.tu-dresden.de/software/windows/cygwin32
+
+REM see -cygcache in ReadMe.txt
+SET CYGWIN_LOCAL_CACHE_WFMT=%BATCHDIR%cygwin_cache
+
+REM see -cyglocal in ReadMe.txt
+SET CYGWIN_FROM_CACHE=N
+
+REM see -cygquiet in ReadMe.txt
+SET CYGWIN_QUIET=Y
+
+REM see -srccache in ReadMe.txt
+SET SOURCE_LOCAL_CACHE_WFMT=%BATCHDIR%source_cache
+
+REM see -coqver in ReadMe.txt
+SET COQ_VERSION=8.5pl3
+
+REM see -gtksrc in ReadMe.txt
+SET GTK_FROM_SOURCES=N
+
+REM see -threads in ReadMe.txt
+SET MAKE_THREADS=8
+
+REM see -addon in ReadMe.txt
+SET "COQ_ADDONS= "
+
+REM ========== PARSE COMMAND LINE PARAMETERS ==========
+
+SHIFT
+
+:Parse
+
+IF "%~0" == "-arch" (
+ IF "%~1" == "32" (
+ SET ARCH=i686
+ SET SETUP=setup-x86.exe
+ ) ELSE (
+ IF "%~1" == "64" (
+ SET ARCH=x86_64
+ SET SETUP=setup-x86_64.exe
+ ) ELSE (
+ ECHO "Invalid -arch, valid are 32 and 64"
+ GOTO :EOF
+ )
+ )
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-mode" (
+ IF "%~1" == "mingwincygwin" (
+ SET INSTALLMODE=%~1
+ ) ELSE (
+ IF "%~1" == "absolute" (
+ SET INSTALLMODE=%~1
+ ) ELSE (
+ IF "%~1" == "relocatable" (
+ SET INSTALLMODE=%~1
+ ) ELSE (
+ ECHO "Invalid -mode, valid are mingwincygwin, absolute and relocatable"
+ GOTO :EOF
+ )
+ )
+ )
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-installer" (
+ SET MAKEINSTALLER=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-ocaml" (
+ SET INSTALLOCAML=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-make" (
+ SET INSTALLMAKE=%~1
+ CALL :CheckYN -installer %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-destcyg" (
+ SET DESTCYG=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-destcoq" (
+ SET DESTCOQ=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-setup" (
+ SET SETUP=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-proxy" (
+ SET PROXY=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-cygrepo" (
+ SET CYGWIN_REPOSITORY=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-cygcache" (
+ SET CYGWIN_LOCAL_CACHE_WFMT=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-cyglocal" (
+ SET CYGWIN_FROM_CACHE=%~1
+ CALL :CheckYN -cyglocal %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-cygquiet" (
+ SET CYGWIN_QUIET=%~1
+ CALL :CheckYN -cygquiet %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-srccache" (
+ SET SOURCE_LOCAL_CACHE_WFMT=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-coqver" (
+ SET COQ_VERSION=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-gtksrc" (
+ SET GTK_FROM_SOURCES=%~1
+ CALL :CheckYN -gtksrc %~1 || GOTO ErrorExit
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-threads" (
+ SET MAKE_THREADS=%~1
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+IF "%~0" == "-addon" (
+ SET "COQ_ADDONS=%COQ_ADDONS% %~1"
+ SHIFT
+ SHIFT
+ GOTO Parse
+)
+
+
+IF NOT "%~0" == "" (
+ ECHO Install cygwin and download, compile and install OCaml and Coq for MinGW
+ ECHO !!! Illegal parameter %~0
+ ECHO Usage:
+ ECHO MakeCoq_MinGW
+ CALL :PrintPars
+ GOTO :EOF
+)
+
+IF NOT EXIST %SETUP% (
+ ECHO The cygwin setup program %SETUP% doesn't exist. You must download it from https://cygwin.com/install.html.
+ ECHO If the setup is in a different folder, set the full path to %SETUP% using the -setup option.
+ GOTO :EOF
+)
+
+REM ========== ADJUST PARAMETERS ==========
+
+IF "%INSTALLMODE%" == "mingwincygwin" (
+ SET DESTCOQ=%DESTCYG%\usr\%ARCH%-w64-mingw32\sys-root\mingw
+)
+
+IF "%MAKEINSTALLER%" == "Y" (
+ SET INSTALLMODE=relocatable
+)
+
+REM ========== CONFIRM PARAMETERS ==========
+
+CALL :PrintPars
+REM Note: DOS batch replaces variables on parsing, so one can't use a variable just set in an () block
+IF "%COQREGTESTING%"=="Y" (GOTO DontAsk)
+ SET /p ANSWER="Is this correct? y/n "
+ IF NOT "%ANSWER%"=="y" (GOTO :EOF)
+:DontAsk
+
+REM ========== DERIVED VARIABLES ==========
+
+SET CYGWIN_INSTALLDIR_WFMT=%DESTCYG%
+SET RESULT_INSTALLDIR_WFMT=%DESTCOQ%
+SET TARGET_ARCH=%ARCH%-w64-mingw32
+SET BASH=%CYGWIN_INSTALLDIR_WFMT%\bin\bash
+
+REM Convert pathes to various formats
+REM WFMT = windows format (C:\..) Used in this batch file.
+REM CFMT = cygwin format (\cygdrive\c\..) Used for Cygwin PATH varible, which is : separated, so C: doesn't work.
+REM MFMT = MinGW format (C:/...) Used for the build, because \\ requires escaping. Mingw can handle \ and /.
+
+SET CYGWIN_INSTALLDIR_MFMT=%CYGWIN_INSTALLDIR_WFMT:\=/%
+SET RESULT_INSTALLDIR_MFMT=%RESULT_INSTALLDIR_WFMT:\=/%
+SET SOURCE_LOCAL_CACHE_MFMT=%SOURCE_LOCAL_CACHE_WFMT:\=/%
+
+SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_MFMT:C:/=/cygdrive/c/%
+SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_MFMT:C:/=/cygdrive/c/%
+SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_MFMT:C:/=/cygdrive/c/%
+
+SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_CFMT:D:/=/cygdrive/d/%
+SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_CFMT:D:/=/cygdrive/d/%
+SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_CFMT:D:/=/cygdrive/d/%
+
+SET CYGWIN_INSTALLDIR_CFMT=%CYGWIN_INSTALLDIR_CFMT:E:/=/cygdrive/e/%
+SET RESULT_INSTALLDIR_CFMT=%RESULT_INSTALLDIR_CFMT:E:/=/cygdrive/e/%
+SET SOURCE_LOCAL_CACHE_CFMT=%SOURCE_LOCAL_CACHE_CFMT:E:/=/cygdrive/e/%
+
+ECHO CYGWIN INSTALL DIR (WIN) = %CYGWIN_INSTALLDIR_WFMT%
+ECHO CYGWIN INSTALL DIR (MINGW) = %CYGWIN_INSTALLDIR_MFMT%
+ECHO CYGWIN INSTALL DIR (CYGWIN) = %CYGWIN_INSTALLDIR_CFMT%
+ECHO RESULT INSTALL DIR (WIN) = %RESULT_INSTALLDIR_WFMT%
+ECHO RESULT INSTALL DIR (MINGW) = %RESULT_INSTALLDIR_MFMT%
+ECHO RESULT INSTALL DIR (CYGWIN) = %RESULT_INSTALLDIR_CFMT%
+
+REM WARNING: Add a space after the = in case you want set this to empty, otherwise the variable will be unset
+SET MAKE_OPT=-j %MAKE_THREADS%
+
+REM ========== DERIVED CYGWIN SETUP OPTIONS ==========
+
+REM One can't set a variable to empty in DOS, but you can set it to a space this way.
+REM The quotes are just there to make the space visible and to protect from "remove trailing spaces".
+SET "CYGWIN_OPT= "
+
+IF "%CYGWIN_FROM_CACHE%" == "Y" (
+ SET CYGWIN_OPT= %CYGWIN_OPT% -L
+)
+
+IF "%CYGWIN_QUIET%" == "Y" (
+ SET CYGWIN_OPT= %CYGWIN_OPT% -q --no-admin
+)
+
+IF "%GTK_FROM_SOURCES%"=="N" (
+ SET CYGWIN_OPT= %CYGWIN_OPT% -P mingw64-%ARCH%-gtk2.0,mingw64-%ARCH%-gtksourceview2.0
+)
+
+REM Cygwin setup sets proper ACLs (permissions) for folders it CREATES.
+REM Otherwise chmod won't work and e.g. the ocaml build will fail.
+REM Cygwin setup does not touch the ACLs of existing folders.
+
+REM Run Cygwin Setup
+
+SET RUNSETUP=Y
+IF EXIST "%CYGWIN_INSTALLDIR_WFMT%\etc\setup\installed.db" (
+ SET RUNSETUP=N
+)
+IF NOT "%CYGWIN_QUIET%" == "Y" (
+ SET RUNSETUP=Y
+)
+
+IF "%COQREGTESTING%" == "Y" (
+ ECHO "========== REMOVE EXISTING CYGWIN =========="
+ DEL /S /F /Q "%CYGWIN_INSTALLDIR_WFMT%" > NUL
+ SET RUNSETUP=Y
+)
+
+SET "EXTRAPACKAGES= "
+
+IF NOT "%APPVEYOR%" == "True" (
+ SET EXTRAPACKAGES=-P wget,curl,git,gcc-core,gcc-g++,automake1.5
+)
+
+ECHO "========== INSTALL CYGWIN =========="
+
+IF "%RUNSETUP%"=="Y" (
+ %SETUP% ^
+ --proxy "%PROXY%" ^
+ --site "%CYGWIN_REPOSITORY%" ^
+ --root "%CYGWIN_INSTALLDIR_WFMT%" ^
+ --local-package-dir "%CYGWIN_LOCAL_CACHE_WFMT%" ^
+ --no-shortcuts ^
+ %CYGWIN_OPT% ^
+ -P make,unzip ^
+ -P gdb,liblzma5 ^
+ -P patch,automake1.14 ^
+ -P mingw64-%ARCH%-binutils,mingw64-%ARCH%-gcc-core,mingw64-%ARCH%-gcc-g++,mingw64-%ARCH%-pkg-config,mingw64-%ARCH%-windows_default_manifest ^
+ -P mingw64-%ARCH%-headers,mingw64-%ARCH%-runtime,mingw64-%ARCH%-pthreads,mingw64-%ARCH%-zlib ^
+ -P libiconv-devel,libunistring-devel,libncurses-devel ^
+ -P gettext-devel,libgettextpo-devel ^
+ -P libglib2.0-devel,libgdk_pixbuf2.0-devel ^
+ -P libfontconfig1 ^
+ -P gtk-update-icon-cache ^
+ -P libtool,automake ^
+ -P intltool ^
+ %EXTRAPACKAGES% ^
+ || GOTO ErrorExit
+
+ MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build"
+ MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\buildlogs"
+)
+
+IF NOT "%CYGWIN_QUIET%" == "Y" (
+ REM Like most setup programs, cygwin setup starts the real setup as a separate process, so wait for it.
+ REM This is not required with the -cygquiet=Y and the resulting --no-admin option.
+ :waitsetup
+ tasklist /fi "imagename eq %SETUP%" | find ":" > NUL
+ IF ERRORLEVEL 1 GOTO waitsetup
+)
+
+ECHO ========== CONFIGURE CYGWIN USER ACCOUNT ==========
+
+REM In case this batch file is called from a cygwin bash (e.g. a git repo) we need to clear
+REM HOME (otherwise we get to the home directory of the other installation)
+REM PROFILEREAD (this is set to true if the /etc/profile has been read, which creates user)
+SET "HOME="
+SET "PROFILEREAD="
+
+copy "%BATCHDIR%\configure_profile.sh" "%CYGWIN_INSTALLDIR_WFMT%\var\tmp" || GOTO ErrorExit
+%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\var\tmp\configure_profile.sh" "%PROXY%" || GOTO ErrorExit
+
+ECHO ========== BUILD COQ ==========
+
+MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build"
+MKDIR "%CYGWIN_INSTALLDIR_WFMT%\build\patches"
+
+COPY "%BATCHDIR%\makecoq_mingw.sh" "%CYGWIN_INSTALLDIR_WFMT%\build" || GOTO ErrorExit
+COPY "%BATCHDIR%\patches_coq\*.*" "%CYGWIN_INSTALLDIR_WFMT%\build\patches" || GOTO ErrorExit
+
+%BASH% --login "%CYGWIN_INSTALLDIR_CFMT%\build\makecoq_mingw.sh" || GOTO ErrorExit
+
+ECHO ========== FINISHED ==========
+
+GOTO :EOF
+
+ECHO ========== BATCH FUNCTIONS ==========
+
+:PrintPars
+ REM 01234567890123456789012345678901234567890123456789012345678901234567890123456789
+ ECHO -arch ^<i686 or x86_64^> Set cygwin, ocaml and coq to 32 or 64 bit
+ ECHO -mode ^<mingwincygwin = install coq in default cygwin mingw sysroot^>
+ ECHO ^<absoloute = install coq in -destcoq absulute path^>
+ ECHO ^<relocatable = install relocatable coq in -destcoq path^>
+ ECHO -installer^<Y or N^> create a windows installer (will be in /build/coq/dev/nsis)
+ ECHO -ocaml ^<Y or N^> install OCaml in Coq folder (Y) or just in cygwin folder (N)
+ ECHO -make ^<Y or N^> install GNU Make in Coq folder (Y) or not (N)
+ ECHO -destcyg ^<path to cygwin destination folder^>
+ ECHO -destcoq ^<path to coq destination folder (mode=absoloute/relocatable)^>
+ ECHO -setup ^<cygwin setup program name^> (auto adjusted to -arch)
+ ECHO -proxy ^<internet proxy^>
+ ECHO -cygrepo ^<cygwin download repository^>
+ ECHO -cygcache ^<local cygwin repository/cache^>
+ ECHO -cyglocal ^<Y or N^> install cygwin from cache
+ ECHO -cygquiet ^<Y or N^> install cygwin without user interaction
+ ECHO -srccache ^<local source code repository/cache^>
+ ECHO -coqver ^<Coq version to install^>
+ ECHO -gtksrc ^<Y or N^> build GTK ^(90 min^) or use cygwin version
+ ECHO -threads ^<1..N^> Number of make threads
+ ECHO -addon ^<name^> Enable building selected addon (can be repeated)
+ ECHO(
+ ECHO See ReadMe.txt for a detailed description of all parameters
+ ECHO(
+ ECHO Parameter values (default or currently set):
+ ECHO -arch = %ARCH%
+ ECHO -mode = %INSTALLMODE%
+ ECHO -ocaml = %INSTALLOCAML%
+ ECHO -installer= %MAKEINSTALLER%
+ ECHO -make = %INSTALLMAKE%
+ ECHO -destcyg = %DESTCYG%
+ ECHO -destcoq = %DESTCOQ%
+ ECHO -setup = %SETUP%
+ ECHO -proxy = %PROXY%
+ ECHO -cygrepo = %CYGWIN_REPOSITORY%
+ ECHO -cygcache = %CYGWIN_LOCAL_CACHE_WFMT%
+ ECHO -cyglocal = %CYGWIN_FROM_CACHE%
+ ECHO -cygquiet = %CYGWIN_QUIET%
+ ECHO -srccache = %SOURCE_LOCAL_CACHE_WFMT%
+ ECHO -coqver = %COQ_VERSION%
+ ECHO -gtksrc = %GTK_FROM_SOURCES%
+ ECHO -threads = %MAKE_THREADS%
+ ECHO -addon = %COQ_ADDONS%
+ GOTO :EOF
+
+:CheckYN
+ REM Reset errorlevel to 0
+ CMD /c "EXIT /b 0"
+ IF "%2" == "Y" (
+ REM OK Y
+ ) ELSE IF "%2" == "N" (
+ REM OK N
+ ) ELSE (
+ ECHO ERROR Parameter %1 must be Y or N, but is %2
+ GOTO ErrorExit
+ )
+ GOTO :EOF
+
+:ErrorExit
+ ECHO ERROR MakeCoq_MinGW.bat failed
+ EXIT /b 1
diff --git a/dev/build/windows/makecoq_mingw.sh b/dev/build/windows/makecoq_mingw.sh index 23eb6fbc63..74dd4d41c1 100755 --- a/dev/build/windows/makecoq_mingw.sh +++ b/dev/build/windows/makecoq_mingw.sh @@ -159,19 +159,19 @@ if [ "${COQREGTESTING:-N}" == "Y" ] ; then # Log command output - take log target name from command name (like log1 make => log target is "<module>-make") log1() { { local -; set +x; } 2> /dev/null - "$@" >"$LOGS/$LOGTARGET-$1.log" 2>"$LOGS/$LOGTARGET-$1.err" + "$@" >"$LOGS/$LOGTARGET-$1_log.txt" 2>"$LOGS/$LOGTARGET-$1_err.txt" } # Log command output - take log target name from command name and first argument (like log2 make install => log target is "<module>-make-install") log2() { { local -; set +x; } 2> /dev/null - "$@" >"$LOGS/$LOGTARGET-$1-$2.log" 2>"$LOGS/$LOGTARGET-$1-$2.err" + "$@" >"$LOGS/$LOGTARGET-$1-$2_log.txt" 2>"$LOGS/$LOGTARGET-$1-$2_err.txt" } # Log command output - take log target name from command name and second argument (like log_1_3 ocaml setup.ml -configure => log target is "<module>-ocaml--configure") log_1_3() { { local -; set +x; } 2> /dev/null - "$@" >"$LOGS/$LOGTARGET-$1-$3.log" 2>"$LOGS/$LOGTARGET-$1-$3.err" + "$@" >"$LOGS/$LOGTARGET-$1-$3_log.txt" 2>"$LOGS/$LOGTARGET-$1-$3_err.txt" } # Log command output - log target name is first argument (like logn untar tar xvaf ... => log target is "<module>-untar") @@ -179,26 +179,26 @@ if [ "${COQREGTESTING:-N}" == "Y" ] ; then { local -; set +x; } 2> /dev/null LOGTARGETEX=$1 shift - "$@" >"$LOGS/$LOGTARGET-$LOGTARGETEX.log" 2>"$LOGS/$LOGTARGET-$LOGTARGETEX.err" + "$@" >"$LOGS/$LOGTARGET-${LOGTARGETEX}_log.txt" 2>"$LOGS/$LOGTARGET-${LOGTARGETEX}_err.txt" } else # If COQREGTESTING, log to log files and console # Log command output - take log target name from command name (like log1 make => log target is "<module>-make") log1() { { local -; set +x; } 2> /dev/null - "$@" > >(tee "$LOGS/$LOGTARGET-$1.log" | sed -e "s/^/$LOGTARGET-$1.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1.err" | sed -e "s/^/$LOGTARGET-$1.err: /" 1>&2) + "$@" > >(tee "$LOGS/$LOGTARGET-$1_log.txt" | sed -e "s/^/$LOGTARGET-$1_log.txt: /") 2> >(tee "$LOGS/$LOGTARGET-$1_err.txt" | sed -e "s/^/$LOGTARGET-$1_err.txt: /" 1>&2) } # Log command output - take log target name from command name and first argument (like log2 make install => log target is "<module>-make-install") log2() { { local -; set +x; } 2> /dev/null - "$@" > >(tee "$LOGS/$LOGTARGET-$1-$2.log" | sed -e "s/^/$LOGTARGET-$1-$2.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$2.err" | sed -e "s/^/$LOGTARGET-$1-$2.err: /" 1>&2) + "$@" > >(tee "$LOGS/$LOGTARGET-$1-$2_log.txt" | sed -e "s/^/$LOGTARGET-$1-$2_log.txt: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$2_err.txt" | sed -e "s/^/$LOGTARGET-$1-$2_err.txt: /" 1>&2) } # Log command output - take log target name from command name and second argument (like log_1_3 ocaml setup.ml -configure => log target is "<module>-ocaml--configure") log_1_3() { { local -; set +x; } 2> /dev/null - "$@" > >(tee "$LOGS/$LOGTARGET-$1-$3.log" | sed -e "s/^/$LOGTARGET-$1-$3.log: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$3.err" | sed -e "s/^/$LOGTARGET-$1-$3.err: /" 1>&2) + "$@" > >(tee "$LOGS/$LOGTARGET-$1-$3_log.txt" | sed -e "s/^/$LOGTARGET-$1-$3_log.txt: /") 2> >(tee "$LOGS/$LOGTARGET-$1-$3_err.txt" | sed -e "s/^/$LOGTARGET-$1-$3_err.txt: /" 1>&2) } # Log command output - log target name is first argument (like logn untar tar xvaf ... => log target is "<module>-untar") @@ -206,7 +206,7 @@ else { local -; set +x; } 2> /dev/null LOGTARGETEX=$1 shift - "$@" > >(tee "$LOGS/$LOGTARGET-$LOGTARGETEX.log" | sed -e "s/^/$LOGTARGET-$LOGTARGETEX.log: /") 2> >(tee "$LOGS/$LOGTARGET-$LOGTARGETEX.err" | sed -e "s/^/$LOGTARGET-$LOGTARGETEX.err: /" 1>&2) + "$@" > >(tee "$LOGS/$LOGTARGET-${LOGTARGETEX}_log.txt" | sed -e "s/^/$LOGTARGET-${LOGTARGETEX}_log.txt: /") 2> >(tee "$LOGS/$LOGTARGET-${LOGTARGETEX}_err.txt" | sed -e "s/^/$LOGTARGET-${LOGTARGETEX}_err.txt: /" 1>&2) } fi diff --git a/dev/ci/ci-basic-overlay.sh b/dev/ci/ci-basic-overlay.sh index 63d5541f48..8620b01b26 100755 --- a/dev/ci/ci-basic-overlay.sh +++ b/dev/ci/ci-basic-overlay.sh @@ -226,3 +226,10 @@ : "${quickchick_CI_REF:=master}" : "${quickchick_CI_GITURL:=https://github.com/QuickChick/QuickChick}" : "${quickchick_CI_ARCHIVEURL:=${quickchick_CI_GITURL}/archive}" + +######################################################################## +# quickchick +######################################################################## +: "${plugin_tutorial_CI_REF:=master}" +: "${plugin_tutorial_CI_GITURL:=https://github.com/ybertot/plugin_tutorials}" +: "${plugin_tutorial_CI_ARCHIVEURL:=${plugin_tutorial_CI_GITURL}/archive}" diff --git a/dev/ci/ci-common.sh b/dev/ci/ci-common.sh index 4acc0e86cf..7a450d0d48 100644 --- a/dev/ci/ci-common.sh +++ b/dev/ci/ci-common.sh @@ -16,13 +16,6 @@ then then export CI_PULL_REQUEST="${CI_BRANCH#pr-}" fi -elif [ -n "${TRAVIS}" ]; -then - # Travis build, `-local` passed to `configure` - export OCAMLPATH="$PWD:$OCAMLPATH" - export COQBIN="$PWD/bin" - export CI_PULL_REQUEST="$TRAVIS_PULL_REQUEST" - export CI_BRANCH="$TRAVIS_BRANCH" elif [ -d "$PWD/_build/install/default/" ]; then # Dune build diff --git a/dev/ci/ci-plugin-tutorial.sh b/dev/ci/ci-plugin-tutorial.sh new file mode 100755 index 0000000000..6c26a71a21 --- /dev/null +++ b/dev/ci/ci-plugin-tutorial.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +ci_dir="$(dirname "$0")" +. "${ci_dir}/ci-common.sh" + +git_download plugin_tutorial + +( cd "${CI_BUILD_DIR}/plugin_tutorial" && \ + pushd tuto0 && make && popd && \ + pushd tuto1 && make && popd && \ + pushd tuto2 && make && popd && \ + pushd tuto3 && make && popd ) diff --git a/dev/ci/docker/bionic_coq/Dockerfile b/dev/ci/docker/bionic_coq/Dockerfile index 8d0f69626e..fcfa591ce1 100644 --- a/dev/ci/docker/bionic_coq/Dockerfile +++ b/dev/ci/docker/bionic_coq/Dockerfile @@ -1,4 +1,4 @@ -# CACHEKEY: "bionic_coq-V2018-09-24-V01" +# CACHEKEY: "bionic_coq-V2018-09-25-V1" # ^^ Update when modifying this file. FROM ubuntu:bionic @@ -32,33 +32,31 @@ ENV NJOBS="2" \ OPAMYES="true" # Base opam is the set of base packages required by Coq -ENV COMPILER="4.02.3" +ENV COMPILER="4.05.0" # Common OPAM packages. # `num` does not have a version number as the right version to install varies # with the compiler version. -ENV BASE_OPAM="num ocamlfind.1.8.0 dune.1.2.1 ounit.2.0.8" \ +ENV BASE_OPAM="num ocamlfind.1.8.0 dune.1.2.1 ounit.2.0.8 odoc.1.2.0" \ CI_OPAM="menhir.20180530 elpi.1.1.0 ocamlgraph.1.8.8" # BASE switch; CI_OPAM contains Coq's CI dependencies. -ENV CAMLP5_VER="6.14" \ +ENV CAMLP5_VER="7.01" \ COQIDE_OPAM="lablgtk.2.18.5 conf-gtksourceview.2" -# The separate `opam install ocamlfind` workarounds an OPAM repository bug in 4.02.3 +# base switch RUN opam init -a --disable-sandboxing --compiler="$COMPILER" default https://opam.ocaml.org && eval $(opam env) && opam update && \ - opam install ocamlfind.1.8.0 && \ opam install $BASE_OPAM camlp5.$CAMLP5_VER $COQIDE_OPAM $CI_OPAM # base+32bit switch RUN opam switch create "${COMPILER}+32bit" && eval $(opam env) && \ - opam install ocamlfind.1.8.0 && \ opam install $BASE_OPAM camlp5.$CAMLP5_VER # EDGE switch ENV COMPILER_EDGE="4.07.0" \ CAMLP5_VER_EDGE="7.06" \ COQIDE_OPAM_EDGE="lablgtk.2.18.6 conf-gtksourceview.2" \ - BASE_OPAM_EDGE="odoc.1.2.0 dune-release.0.3.0" + BASE_OPAM_EDGE="dune-release.0.3.0" RUN opam switch create $COMPILER_EDGE && eval $(opam env) && \ opam install $BASE_OPAM $BASE_OPAM_EDGE camlp5.$CAMLP5_VER_EDGE $COQIDE_OPAM_EDGE diff --git a/dev/ci/gitlab.bat b/dev/ci/gitlab.bat index 31bd65af08..09e9762261 100755 --- a/dev/ci/gitlab.bat +++ b/dev/ci/gitlab.bat @@ -1,119 +1,120 @@ -@ECHO OFF - -REM This script builds and signs the Windows packages on Gitlab - -ECHO "Start Time" -TIME /T - -REM List currently used cygwin and target folders for debugging / maintenance purposes - -ECHO "Currently used cygwin folders" -DIR C:\cygwin* -ECHO "Currently used target folders" -DIR C:\coq* - -if %ARCH% == 32 ( - SET ARCHLONG=i686 - SET CYGROOT=C:\cygwin - SET SETUP=setup-x86.exe -) - -if %ARCH% == 64 ( - SET ARCHLONG=x86_64 - SET CYGROOT=C:\cygwin64 - SET SETUP=setup-x86_64.exe -) - -SET DESTCOQ=C:\coq%ARCH%_inst - -CALL :MakeUniqueFolder %CYGROOT% CYGROOT -CALL :MakeUniqueFolder %DESTCOQ% DESTCOQ - -powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.cygwin.com/%SETUP%', '%SETUP%')" -SET CYGCACHE=%CYGROOT%\var\cache\setup -SET CI_PROJECT_DIR_MFMT=%CI_PROJECT_DIR:\=/% -SET CI_PROJECT_DIR_CFMT=%CI_PROJECT_DIR_MFMT:C:/=/cygdrive/c/% -SET COQREGTESTING=Y -SET PATH=%PATH%;C:\Program Files\7-Zip\;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin - -if exist %CYGROOT%\build\ rd /s /q %CYGROOT%\build -if exist %DESTCOQ%\ rd /s /q %DESTCOQ% - -call %CI_PROJECT_DIR%\dev\build\windows\MakeCoq_MinGW.bat -threads=1 ^ - -arch=%ARCH% -installer=Y -coqver=%CI_PROJECT_DIR_CFMT% ^ - -destcyg=%CYGROOT% -destcoq=%DESTCOQ% -cygcache=%CYGCACHE% ^ - -addon="bignums ltac2 equations" -make=N ^ - -setup %CI_PROJECT_DIR%\%SETUP% || GOTO ErrorCopyLogFilesAndExit - - -ECHO "Start Artifact Creation" -TIME /T - -mkdir artifacts - -CALL :CopyLogFiles - -copy "%CYGROOT%\build\coq-local\dev\nsis\*.exe" artifacts || GOTO ErrorExit -REM The open source archive is only required for release builds -IF DEFINED WIN_CERTIFICATE_PATH ( - 7z a artifacts\coq-opensource-archive-windows-%ARCHLONG%.zip %CYGROOT%\build\tarballs\* || GOTO ErrorExit -) ELSE ( - REM In non release builds, create a dummy file - ECHO "This is not a release build - open source archive not created / uploaded" > artifacts\coq-opensource-info.txt -) - -REM DO NOT echo the signing command below, as this would leak secrets in the logs -IF DEFINED WIN_CERTIFICATE_PATH ( - IF DEFINED WIN_CERTIFICATE_PASSWORD ( - ECHO Signing package - @signtool sign /f %WIN_CERTIFICATE_PATH% /p %WIN_CERTIFICATE_PASSWORD% dev\nsis\*.exe - signtool verify /pa dev\nsis\*.exe - ) -) - -ECHO "Finished Artifact Creation" -TIME /T - -CALL :CleanupFolders - -ECHO "Finished Cleanup" -TIME /T - -GOTO :EOF - -:CopyLogFiles - ECHO Copy log files for artifact upload - MKDIR artifacts\buildlogs - COPY %CYGROOT%\build\buildlogs\* artifacts\buildlogs - MKDIR artifacts\filelists - COPY %CYGROOT%\build\filelists\* artifacts\filelists - MKDIR artifacts\flagfiles - COPY %CYGROOT%\build\flagfiles\* artifacts\flagfiles - GOTO :EOF - -:CleanupFolders - ECHO "Cleaning %CYGROOT%" - DEL /S /F /Q "%CYGROOT%" > NUL - ECHO "Cleaning %DESTCOQ%" - DEL /S /F /Q "%DESTCOQ%" > NUL - GOTO :EOF - -:MakeUniqueFolder - REM Create a uniquely named folder - REM This script is safe because folder creation is atomic - either we create it or fail - REM %1 = base path or directory (_%RANDOM%_%RANDOM% is appended to this) - REM %2 = name of the variable which receives the unique folder name - SET "UNIQUENAME=%1_%RANDOM%_%RANDOM%" - MKDIR "%UNIQUENAME%" - IF ERRORLEVEL 1 GOTO :MakeUniqueFolder - SET "%2=%UNIQUENAME%" - GOTO :EOF - -:ErrorCopyLogFilesAndExit - CALL :CopyLogFiles - REM fall through - -:ErrorExit - CALL :CleanupFolders - ECHO ERROR %0 failed - EXIT /b 1 +@ECHO OFF
+
+REM This script builds and signs the Windows packages on Gitlab
+
+ECHO "Start Time"
+TIME /T
+
+REM List currently used cygwin and target folders for debugging / maintenance purposes
+
+ECHO "Currently used cygwin folders"
+DIR C:\ci\cygwin*
+ECHO "Currently used target folders"
+DIR C:\ci\coq*
+ECHO "Root folders"
+DIR C:\
+
+if %ARCH% == 32 (
+ SET ARCHLONG=i686
+ SET SETUP=setup-x86.exe
+)
+
+if %ARCH% == 64 (
+ SET ARCHLONG=x86_64
+ SET SETUP=setup-x86_64.exe
+)
+
+SET CYGROOT=C:\ci\cygwin%ARCH%
+SET DESTCOQ=C:\ci\coq%ARCH%
+
+CALL :MakeUniqueFolder %CYGROOT% CYGROOT
+CALL :MakeUniqueFolder %DESTCOQ% DESTCOQ
+
+powershell -Command "(New-Object Net.WebClient).DownloadFile('http://www.cygwin.com/%SETUP%', '%SETUP%')"
+SET CYGCACHE=%CYGROOT%\var\cache\setup
+SET CI_PROJECT_DIR_MFMT=%CI_PROJECT_DIR:\=/%
+SET CI_PROJECT_DIR_CFMT=%CI_PROJECT_DIR_MFMT:C:/=/cygdrive/c/%
+SET COQREGTESTING=Y
+SET PATH=%PATH%;C:\Program Files\7-Zip\;C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin
+
+if exist %CYGROOT%\build\ rd /s /q %CYGROOT%\build
+if exist %DESTCOQ%\ rd /s /q %DESTCOQ%
+
+call %CI_PROJECT_DIR%\dev\build\windows\MakeCoq_MinGW.bat -threads=1 ^
+ -arch=%ARCH% -installer=Y -coqver=%CI_PROJECT_DIR_CFMT% ^
+ -destcyg=%CYGROOT% -destcoq=%DESTCOQ% -cygcache=%CYGCACHE% ^
+ -addon="bignums ltac2 equations" -make=N ^
+ -setup %CI_PROJECT_DIR%\%SETUP% || GOTO ErrorCopyLogFilesAndExit
+
+
+ECHO "Start Artifact Creation"
+TIME /T
+
+mkdir artifacts
+
+CALL :CopyLogFiles
+
+copy "%CYGROOT%\build\coq-local\dev\nsis\*.exe" artifacts || GOTO ErrorExit
+REM The open source archive is only required for release builds
+IF DEFINED WIN_CERTIFICATE_PATH (
+ 7z a artifacts\coq-opensource-archive-windows-%ARCHLONG%.zip %CYGROOT%\build\tarballs\* || GOTO ErrorExit
+) ELSE (
+ REM In non release builds, create a dummy file
+ ECHO "This is not a release build - open source archive not created / uploaded" > artifacts\coq-opensource-info.txt
+)
+
+REM DO NOT echo the signing command below, as this would leak secrets in the logs
+IF DEFINED WIN_CERTIFICATE_PATH (
+ IF DEFINED WIN_CERTIFICATE_PASSWORD (
+ ECHO Signing package
+ @signtool sign /f %WIN_CERTIFICATE_PATH% /p %WIN_CERTIFICATE_PASSWORD% dev\nsis\*.exe
+ signtool verify /pa dev\nsis\*.exe
+ )
+)
+
+ECHO "Finished Artifact Creation"
+TIME /T
+
+CALL :CleanupFolders
+
+ECHO "Finished Cleanup"
+TIME /T
+
+GOTO :EOF
+
+:CopyLogFiles
+ ECHO Copy log files for artifact upload
+ MKDIR artifacts\buildlogs
+ COPY %CYGROOT%\build\buildlogs\* artifacts\buildlogs
+ MKDIR artifacts\filelists
+ COPY %CYGROOT%\build\filelists\* artifacts\filelists
+ MKDIR artifacts\flagfiles
+ COPY %CYGROOT%\build\flagfiles\* artifacts\flagfiles
+ GOTO :EOF
+
+:CleanupFolders
+ ECHO "Cleaning %CYGROOT%"
+ RMDIR /S /Q "%CYGROOT%"
+ ECHO "Cleaning %DESTCOQ%"
+ RMDIR /S /Q "%DESTCOQ%"
+ GOTO :EOF
+
+:MakeUniqueFolder
+ REM Create a uniquely named folder
+ REM This script is safe because folder creation is atomic - either we create it or fail
+ REM %1 = base path or directory (_%RANDOM%_%RANDOM% is appended to this)
+ REM %2 = name of the variable which receives the unique folder name
+ SET "UNIQUENAME=%1_%RANDOM%_%RANDOM%"
+ MKDIR "%UNIQUENAME%"
+ IF ERRORLEVEL 1 GOTO :MakeUniqueFolder
+ SET "%2=%UNIQUENAME%"
+ GOTO :EOF
+
+:ErrorCopyLogFilesAndExit
+ CALL :CopyLogFiles
+ REM fall through
+
+:ErrorExit
+ CALL :CleanupFolders
+ ECHO ERROR %0 failed
+ EXIT /b 1
diff --git a/dev/ci/user-overlays/08456-fix-6764.sh b/dev/ci/user-overlays/08456-fix-6764.sh new file mode 100644 index 0000000000..3b951d9c07 --- /dev/null +++ b/dev/ci/user-overlays/08456-fix-6764.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "$CI_PULL_REQUEST" = "8456" ] || [ "$CI_BRANCH" = "fix-6764" ]; then + Elpi_CI_REF=overlay/8456 +fi diff --git a/dev/doc/build-system.dune.md b/dev/doc/build-system.dune.md index 85aaf317ef..7349360be8 100644 --- a/dev/doc/build-system.dune.md +++ b/dev/doc/build-system.dune.md @@ -3,29 +3,45 @@ Dune-based build system. If you want to enhance the build system itself (or are curious about its implementation details), see build-system.dev.txt, and in particular its initial HISTORY section. -Dune -==== +About Dune +========== -Coq can now be built using -[Dune](https://github.com/ocaml/dune). Contrary to other systems, -Dune, doesn't use a global`makefile` but local build files named -`dune` that are later composed to form a global build. +Coq can now be built using [Dune](https://github.com/ocaml/dune). + +## Quick Start + +You need Dune >= 1.2.1 ; just type `dune build` to build the base Coq +libraries. No call to `./configure` is needed. + +Dune will get confused if it finds leftovers of in-tree compilation, +so please be sure your tree is clean from objects files generated by +the make-based system. + +If you want to build the standard libraries and plugins you should +call `make -f Makefile.dune voboot`. It is usually enough to do that +once per-session. + +More helper targets are availabe in `Makefile.dune`, `make -f +Makefile.dune` will display some help. + +Dune places build artifacts in a separate directory `_build`; it will +also generate an `.install` file so files can be properly installed by +package managers. + +Contrary to other systems, Dune doesn't use a global `Makefile` but +local build files named `dune` that are later composed to form a +global build. As a developer, Dune should take care of all OCaml-related build tasks -including library management, merlin files, and link order. You are +including library management, merlin files, and linking order. You are are not supposed to modify the `dune` files unless you are adding a new binary, library, or plugin. -The current Dune setup also doesn't require a call to `configure`. The -auto-generated configuration files are properly included in the -dependency graph so it will be automatically generated by Dune with -reasonable developer defaults. You can still override the defaults by -manually calling `./configure`, but note that some configure options -such as install paths are not used by Dune. +## Per-User Custom Settings -Dune uses a separate directory `_build` to store build artifacts; it -will generate an `.install` file so artifacts in the build can be -properly installed by package managers. +Dune will read the file `~/.config/dune/config`; see `man +dune-config`. Among others, you can set in this file the custom number +of build threads `(jobs N)` and display options `(display _mode_)`. ## Targets @@ -36,8 +52,10 @@ project, creating an "install" overlay in `_build/install/default`. You can build some other target by doing `dune build $TARGET`. In order to build a single package, you can do `dune build -$PACKAGE.install`. Dune also provides targets for documentation and -testing, see below. +$PACKAGE.install`. + +Dune also provides targets for documentation, testing, and release +builds, please see below. ## Developer shell @@ -66,7 +84,8 @@ current Coq source tree contains two packages [Coq and CoqIDE], and in the OPAM CoqIDE package we don't want to build CoqIDE against the local copy of Coq. For this purpose, Dune supports the `-p` option, so `dune build -p coqide` will build CoqIDE against the system-installed -version of Coq libs. +version of Coq libs, and use a "release" profile that for example +enables stronger compiler optimizations. ## Stanzas diff --git a/dev/doc/profiling.txt b/dev/doc/profiling.txt index 45766293c7..29e87df6b8 100644 --- a/dev/doc/profiling.txt +++ b/dev/doc/profiling.txt @@ -7,7 +7,7 @@ want to profile time or memory consumption. AFAIK, this only works for Linux. In Coq source folder: -opam switch 4.02.3+fp +opam switch 4.05.0+trunk+fp ./configure -local -debug make perf record -g bin/coqtop -compile file.v diff --git a/dev/doc/release-process.md b/dev/doc/release-process.md index 1821a181f1..b33a1cbd73 100644 --- a/dev/doc/release-process.md +++ b/dev/doc/release-process.md @@ -6,6 +6,35 @@ the present checklist. - [ ] Change the version name to the next major version and the magic numbers (see [#7008](https://github.com/coq/coq/pull/7008/files)). +- [ ] Update the compatibility infrastructure, which consists of doing + the following steps. Note that all but the final step can be + performed automatically by + [`dev/tools/update-compat.py`](/dev/tools/update-compat.py) so + long as you have already updated `coq_version` in + [`configure.ml`](/configure.ml). + + [ ] Add a file `theories/Compat/CoqXX.v` which contains just the header + from [`dev/header.ml`](/dev/header.ml) + + [ ] Add the line `Require Export Coq.Compat.CoqXX.` at the top of + `theories/Compat/CoqYY.v`, where Y.Y is the version prior to X.X. + + [ ] Delete the file `theories/Compat/CoqWW.v`, where W.W is three versions + prior to X.X. + + [ ] Update + [`doc/stdlib/index-list.html.template`](/doc/stdlib/index-list.html.template) + with the deleted/added files. + + [ ] Remove any notations in the standard library which have `compat "W.W"`. + + [ ] Update the type `compat_version` in [`lib/flags.ml`](/lib/flags.ml) by + bumping all the version numbers by one, and update the interpretations + of those flags in [`toplevel/coqargs.ml`](/toplevel/coqargs.ml) and + [`vernac/g_vernac.mlg`](/vernac/g_vernac.mlg). + + [ ] Update the files + [`test-suite/success/CompatCurrentFlag.v`](/test-suite/success/CompatCurrentFlag.v), + [`test-suite/success/CompatPreviousFlag.v`](/test-suite/success/CompatPreviousFlag.v), + and + [`test-suite/success/CompatOldFlag.v`](/test-suite/success/CompatOldFlag.v) + by bumping all version numbers by 1. + + [ ] Decide what to do about all test-suite files which mention `-compat + W.W` or `Coq.Comapt.CoqWW` (which is no longer valid, since we only + keep compatibility against the two previous versions) - [ ] Put the corresponding alpha tag using `git tag -s`. The `VX.X+alpha` tag marks the first commit to be in `master` and not in the branch of the previous version. @@ -57,7 +86,6 @@ ## Before the beta release date ## - [ ] Ensure the Credits chapter has been updated. -- [ ] Ensure an empty `CompatXX.v` file has been created. - [ ] Ensure that an appropriate version of the plugins we will distribute with Coq has been tagged. - [ ] Have some people test the recently auto-generated Windows and MacOS diff --git a/dev/dune-workspace.all b/dev/dune-workspace.all new file mode 100644 index 0000000000..44857ed050 --- /dev/null +++ b/dev/dune-workspace.all @@ -0,0 +1,11 @@ +(lang dune 1.2) + +; Add custom flags here. Default developer profile is `dev` +(env + (dev (flags :standard -rectypes -w -9-27-50)) + (release (flags :standard -rectypes))) + +(context (opam (switch 4.05.0))) +(context (opam (switch 4.05.0+32bit))) +(context (opam (switch 4.07.0))) +(context (opam (switch 4.07.0+flambda))) diff --git a/dev/tools/sudo-apt-get-update.sh b/dev/tools/sudo-apt-get-update.sh deleted file mode 100755 index f8bf6bed41..0000000000 --- a/dev/tools/sudo-apt-get-update.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -(sudo apt-get update "$@" 2>&1 || echo 'E: update failed') | tee /tmp/apt.err -! grep -q '^\(E:\|W: Failed to fetch\)' /tmp/apt.err || exit $? diff --git a/dev/tools/update-compat.py b/dev/tools/update-compat.py new file mode 100755 index 0000000000..7c8b9f025c --- /dev/null +++ b/dev/tools/update-compat.py @@ -0,0 +1,341 @@ +#!/usr/bin/env python +from __future__ import with_statement +import os, re, sys + +# Obtain the absolute path of the script being run. By assuming that +# the script lives in dev/tools/, and basing all calls on the path of +# the script, rather than the current working directory, we can be +# robust to users who choose to run the script from any location. +SCRIPT_PATH = os.path.dirname(os.path.realpath(__file__)) +ROOT_PATH = os.path.realpath(os.path.join(SCRIPT_PATH, '..', '..')) +CONFIGURE_PATH = os.path.join(ROOT_PATH, 'configure.ml') +HEADER_PATH = os.path.join(ROOT_PATH, 'dev', 'header.ml') +DEFAULT_NUMBER_OF_OLD_VERSIONS = 2 +EXTRA_HEADER = '\n(** Compatibility file for making Coq act similar to Coq v%s *)\n' +FLAGS_MLI_PATH = os.path.join(ROOT_PATH, 'lib', 'flags.mli') +FLAGS_ML_PATH = os.path.join(ROOT_PATH, 'lib', 'flags.ml') +COQARGS_ML_PATH = os.path.join(ROOT_PATH, 'toplevel', 'coqargs.ml') +G_VERNAC_PATH = os.path.join(ROOT_PATH, 'vernac', 'g_vernac.mlg') +DOC_INDEX_PATH = os.path.join(ROOT_PATH, 'doc', 'stdlib', 'index-list.html.template') +BUG_4798_PATH = os.path.join(ROOT_PATH, 'test-suite', 'bugs', 'closed', '4798.v') +TEST_SUITE_PATHS = tuple(os.path.join(ROOT_PATH, 'test-suite', 'success', i) + for i in ('CompatOldOldFlag.v', 'CompatOldFlag.v', 'CompatPreviousFlag.v', 'CompatCurrentFlag.v')) +TEST_SUITE_DESCRIPTIONS = ('current-minus-three', 'current-minus-two', 'current-minus-one', 'current') +# sanity check that we are where we think we are +assert(os.path.normpath(os.path.realpath(SCRIPT_PATH)) == os.path.normpath(os.path.realpath(os.path.join(ROOT_PATH, 'dev', 'tools')))) +assert(os.path.exists(CONFIGURE_PATH)) + +def get_header(): + with open(HEADER_PATH, 'r') as f: return f.read() + +HEADER = get_header() + +def get_version(cur_version=None): + if cur_version is not None: return cur_version + with open(CONFIGURE_PATH, 'r') as f: + for line in f.readlines(): + found = re.findall(r'let coq_version = "([0-9]+\.[0-9]+)', line) + if len(found) > 0: + return found[0] + raise Exception("No line 'let coq_version = \"X.X' found in %s" % os.path.relpath(CONFIGURE_PATH, ROOT_PATH)) + +def compat_name_to_version_name(compat_file_name): + assert(compat_file_name.startswith('Coq') and compat_file_name.endswith('.v')) + v = compat_file_name[len('Coq'):][:-len('.v')] + assert(len(v) == 2 or (len(v) >= 2 and v[0] in ('8', '9'))) # we'll have to change this scheme when we hit Coq 10.* + return '%s.%s' % (v[0], v[1:]) + +def version_name_to_compat_name(v, ext='.v'): + return 'Coq%s%s%s' % tuple(v.split('.') + [ext]) + +# returns (lines of compat files, lines of not compat files +def get_doc_index_lines(): + with open(DOC_INDEX_PATH, 'r') as f: + lines = f.readlines() + return (tuple(line for line in lines if 'theories/Compat/Coq' in line), + tuple(line for line in lines if 'theories/Compat/Coq' not in line)) + +COMPAT_INDEX_LINES, DOC_INDEX_LINES = get_doc_index_lines() + +def version_to_int_pair(v): + return tuple(map(int, v.split('.'))) + +def get_known_versions(): + # We could either get the files from the doc index, or from the + # directory list. We assume that the doc index is more + # representative. If we wanted to use the directory list, we + # would do: + # compat_files = os.listdir(os.path.join(ROOT_PATH, 'theories', 'Compat')) + compat_files = re.findall(r'Coq[^\.]+\.v', '\n'.join(COMPAT_INDEX_LINES)) + return tuple(sorted((compat_name_to_version_name(i) for i in compat_files if i.startswith('Coq') and i.endswith('.v')), key=version_to_int_pair)) + +def get_new_versions(known_versions, **args): + if args['cur_version'] in known_versions: + assert(known_versions[-1] == args['cur_version']) + assert(len(known_versions) == args['number_of_compat_versions']) + return known_versions + assert(len(known_versions) >= args['number_of_old_versions']) + return tuple(list(known_versions[-args['number_of_old_versions']:]) + [args['cur_version']]) + +def update_compat_files(old_versions, new_versions, assert_unchanged=False, **args): + for v in old_versions: + if v not in new_versions: + compat_file = os.path.join('theories', 'Compat', version_name_to_compat_name(v)) + if not assert_unchanged: + print('Removing %s...' % compat_file) + compat_path = os.path.join(ROOT_PATH, compat_file) + os.rename(compat_path, compat_path + '.bak') + else: + raise Exception('%s exists!' % compat_file) + for v, next_v in zip(new_versions, list(new_versions[1:]) + [None]): + compat_file = os.path.join('theories', 'Compat', version_name_to_compat_name(v)) + compat_path = os.path.join(ROOT_PATH, compat_file) + if not os.path.exists(compat_path): + print('Creating %s...' % compat_file) + contents = HEADER + (EXTRA_HEADER % v) + if next_v is not None: + contents += '\nRequire Export Coq.Compat.%s.\n' % version_name_to_compat_name(next_v, ext='') + if not assert_unchanged: + with open(compat_path, 'w') as f: + f.write(contents) + print(r"Don't forget to 'git add %s'!" % compat_file) + else: + raise Exception('%s does not exist!' % compat_file) + else: + # print('Checking %s...' % compat_file) + with open(compat_path, 'r') as f: + contents = f.read() + header = HEADER + (EXTRA_HEADER % v) + if not contents.startswith(HEADER): + raise Exception("Invalid header in %s; does not match %s" % (compat_file, os.path.relpath(HEADER_PATH, ROOT_PATH))) + if not contents.startswith(header): + raise Exception("Invalid header in %s; missing line %s" % (compat_file, EXTRA_HEADER.strip('\n') % v)) + if next_v is not None: + line = 'Require Export Coq.Compat.%s.' % version_name_to_compat_name(next_v, ext='') + if ('\n%s\n' % line) not in contents: + if not contents.startswith(header + '\n'): + contents = contents.replace(header, header + '\n') + contents = contents.replace(header, '%s\n%s' % (header, line)) + if not assert_unchanged: + print('Updating %s...' % compat_file) + with open(compat_path, 'w') as f: + f.write(contents) + else: + raise Exception('Compat file %s is missing line %s' % (compat_file, line)) + +def update_compat_versions_type_line(new_versions, contents, relpath): + compat_version_string = ' | '.join(['V%s_%s' % tuple(v.split('.')) for v in new_versions[:-1]] + ['Current']) + new_compat_line = 'type compat_version = %s' % compat_version_string + new_contents = re.sub(r'^type compat_version = .*$', new_compat_line, contents, flags=re.MULTILINE) + if new_compat_line not in new_contents: + raise Exception("Could not find 'type compat_version =' in %s" % relpath) + return new_contents + +def update_version_compare(new_versions, contents, relpath): + first_line = 'let version_compare v1 v2 = match v1, v2 with' + new_lines = [first_line] + for v in new_versions[:-1]: + V = 'V%s_%s' % tuple(v.split('.')) + new_lines.append(' | %s, %s -> 0' % (V, V)) + new_lines.append(' | %s, _ -> -1' % V) + new_lines.append(' | _, %s -> 1' % V) + new_lines.append(' | Current, Current -> 0') + new_lines = '\n'.join(new_lines) + new_contents = re.sub(first_line + '.*' + 'Current, Current -> 0', new_lines, contents, flags=re.DOTALL|re.MULTILINE) + if new_lines not in new_contents: + raise Exception('Could not find version_compare in %s' % relpath) + return new_contents + +def update_pr_version(new_versions, contents, relpath): + first_line = 'let pr_version = function' + new_lines = [first_line] + for v in new_versions[:-1]: + V = 'V%s_%s' % tuple(v.split('.')) + new_lines.append(' | %s -> "%s"' % (V, v)) + new_lines.append(' | Current -> "current"') + new_lines = '\n'.join(new_lines) + new_contents = re.sub(first_line + '.*' + 'Current -> "current"', new_lines, contents, flags=re.DOTALL|re.MULTILINE) + if new_lines not in new_contents: + raise Exception('Could not find pr_version in %s' % relpath) + return new_contents + +def update_add_compat_require(new_versions, contents, relpath): + first_line = 'let add_compat_require opts v =' + new_lines = [first_line, ' match v with'] + for v in new_versions[:-1]: + V = 'V%s_%s' % tuple(v.split('.')) + new_lines.append(' | Flags.%s -> add_vo_require opts "Coq.Compat.%s" None (Some false)' % (V, version_name_to_compat_name(v, ext=''))) + new_lines.append(' | Flags.Current -> add_vo_require opts "Coq.Compat.%s" None (Some false)' % version_name_to_compat_name(new_versions[-1], ext='')) + new_lines = '\n'.join(new_lines) + new_contents = re.sub(first_line + '.*' + 'Flags.Current -> add_vo_require opts "Coq.Compat.[^"]+" None .Some false.', new_lines, contents, flags=re.DOTALL|re.MULTILINE) + if new_lines not in new_contents: + raise Exception('Could not find add_compat_require in %s' % relpath) + return new_contents + +def update_parse_compat_version(new_versions, contents, relpath, **args): + line_count = args['number_of_compat_versions']+2 # 1 for the first line, 1 for the invalid flags + first_line = 'let parse_compat_version = let open Flags in function' + old_function_lines = contents[contents.index(first_line):].split('\n')[:line_count] + if re.match(r'^ \| \([0-9 "\.\|]*\) as s ->$', old_function_lines[-1]) is None: + raise Exception('Could not recognize line %d of parse_compat_version in %s as a list of invalid versions' % (line_count, relpath)) + all_versions = re.findall(r'"([0-9\.]+)"', ''.join(old_function_lines)) + invalid_versions = tuple(i for i in all_versions if i not in new_versions) + new_function_lines = [first_line] + for v, V in reversed(list(zip(new_versions, ['V%s_%s' % tuple(v.split('.')) for v in new_versions[:-1]] + ['Current']))): + new_function_lines.append(' | "%s" -> %s' % (v, V)) + new_function_lines.append(' | (%s) as s ->' % ' | '.join('"%s"' % v for v in invalid_versions)) + new_lines = '\n'.join(new_function_lines) + new_contents = contents.replace('\n'.join(old_function_lines), new_lines) + if new_lines not in new_contents: + raise Exception('Could not find parse_compat_version in %s' % relpath) + return new_contents + +def check_no_old_versions(old_versions, new_versions, contents, relpath): + for v in old_versions: + if v not in new_versions: + V = 'V%s_%s' % tuple(v.split('.')) + if V in contents: + raise Exception('Unreplaced usage of %s remaining in %s' % (V, relpath)) + +def update_if_changed(contents, new_contents, path, assert_unchanged=False, **args): + if contents != new_contents: + if not assert_unchanged: + print('Updating %s...' % os.path.relpath(path, ROOT_PATH)) + with open(path, 'w') as f: + f.write(new_contents) + else: + raise Exception('%s changed!' % os.path.relpath(path, ROOT_PATH)) + +def update_flags_mli(old_versions, new_versions, **args): + with open(FLAGS_MLI_PATH, 'r') as f: contents = f.read() + new_contents = update_compat_versions_type_line(new_versions, contents, os.path.relpath(FLAGS_MLI_PATH, ROOT_PATH)) + check_no_old_versions(old_versions, new_versions, new_contents, os.path.relpath(FLAGS_MLI_PATH, ROOT_PATH)) + update_if_changed(contents, new_contents, FLAGS_MLI_PATH, **args) + +def update_flags_ml(old_versions, new_versions, **args): + with open(FLAGS_ML_PATH, 'r') as f: contents = f.read() + new_contents = update_compat_versions_type_line(new_versions, contents, os.path.relpath(FLAGS_ML_PATH, ROOT_PATH)) + new_contents = update_version_compare(new_versions, new_contents, os.path.relpath(FLAGS_ML_PATH, ROOT_PATH)) + new_contents = update_pr_version(new_versions, new_contents, os.path.relpath(FLAGS_ML_PATH, ROOT_PATH)) + check_no_old_versions(old_versions, new_versions, new_contents, os.path.relpath(FLAGS_ML_PATH, ROOT_PATH)) + update_if_changed(contents, new_contents, FLAGS_ML_PATH, **args) + +def update_coqargs_ml(old_versions, new_versions, **args): + with open(COQARGS_ML_PATH, 'r') as f: contents = f.read() + new_contents = update_add_compat_require(new_versions, contents, os.path.relpath(COQARGS_ML_PATH, ROOT_PATH)) + check_no_old_versions(old_versions, new_versions, new_contents, os.path.relpath(COQARGS_ML_PATH, ROOT_PATH)) + update_if_changed(contents, new_contents, COQARGS_ML_PATH, **args) + +def update_g_vernac(old_versions, new_versions, **args): + with open(G_VERNAC_PATH, 'r') as f: contents = f.read() + new_contents = update_parse_compat_version(new_versions, contents, os.path.relpath(G_VERNAC_PATH, ROOT_PATH), **args) + check_no_old_versions(old_versions, new_versions, new_contents, os.path.relpath(G_VERNAC_PATH, ROOT_PATH)) + update_if_changed(contents, new_contents, G_VERNAC_PATH, **args) + +def update_flags(old_versions, new_versions, **args): + update_flags_mli(old_versions, new_versions, **args) + update_flags_ml(old_versions, new_versions, **args) + update_coqargs_ml(old_versions, new_versions, **args) + update_g_vernac(old_versions, new_versions, **args) + +def update_test_suite(new_versions, assert_unchanged=False, test_suite_paths=TEST_SUITE_PATHS, test_suite_descriptions=TEST_SUITE_DESCRIPTIONS, **args): + assert(len(new_versions) == len(test_suite_paths)) + assert(len(new_versions) == len(test_suite_descriptions)) + for i, (v, path, descr) in enumerate(zip(new_versions, test_suite_paths, test_suite_descriptions)): + if not os.path.exists(path): + raise Exception('Could not find existing file %s' % os.path.relpath(path, ROOT_PATH)) + if '%s' in descr: descr = descr % v + with open(path, 'r') as f: contents = f.read() + lines = ['(* -*- coq-prog-args: ("-compat" "%s") -*- *)' % v, + '(** Check that the %s compatibility flag actually requires the relevant modules. *)' % descr] + for imp_v in reversed(new_versions[i:]): + lines.append('Import Coq.Compat.%s.' % version_name_to_compat_name(imp_v, ext='')) + lines.append('') + new_contents = '\n'.join(lines) + update_if_changed(contents, new_contents, path, **args) + +def update_doc_index(new_versions, **args): + with open(DOC_INDEX_PATH, 'r') as f: contents = f.read() + firstline = ' theories/Compat/AdmitAxiom.v' + new_contents = ''.join(DOC_INDEX_LINES) + if firstline not in new_contents: + raise Exception("Could not find line '%s' in %s" % (firstline, os.path.relpath(DOC_INDEX_PATH, ROOT_PATH))) + extra_lines = [' theories/Compat/%s' % version_name_to_compat_name(v) for v in new_versions] + new_contents = new_contents.replace(firstline, '\n'.join([firstline] + extra_lines)) + update_if_changed(contents, new_contents, DOC_INDEX_PATH, **args) + +def update_bug_4789(new_versions, **args): + # we always update this compat notation to oldest + # currently-supported compat version, which should never be the + # current version + with open(BUG_4798_PATH, 'r') as f: contents = f.read() + new_contents = r"""Check match 2 with 0 => 0 | S n => n end. +Notation "|" := 1 (compat "%s"). +Check match 2 with 0 => 0 | S n => n end. (* fails *) +""" % new_versions[0] + update_if_changed(contents, new_contents, BUG_4798_PATH, **args) + +def update_compat_notations_in(old_versions, new_versions, contents): + for v in old_versions: + if v not in new_versions: + reg = re.compile(r'^[ \t]*(?:Notation|Infix)[^\n]*?compat "%s"[^\n]*?\n' % v, flags=re.MULTILINE) + contents = re.sub(r'^[ \t]*(?:Notation|Infix)[^\n]*?compat "%s"[^\n]*?\n' % v, '', contents, flags=re.MULTILINE) + return contents + +def update_compat_notations(old_versions, new_versions, **args): + for root, dirs, files in os.walk(os.path.join(ROOT_PATH, 'theories')): + for fname in files: + if not fname.endswith('.v'): continue + with open(os.path.join(root, fname), 'r') as f: contents = f.read() + new_contents = update_compat_notations_in(old_versions, new_versions, contents) + update_if_changed(contents, new_contents, os.path.join(root, fname), **args) + +def display_git_grep(old_versions, new_versions): + Vs = ['V%s_%s' % tuple(v.split('.')) for v in old_versions if v not in new_versions] + compat_vs = ['compat "%s"' % v for v in old_versions if v not in new_versions] + all_options = tuple(Vs + compat_vs) + options = (['"-compat" "%s"' % v for v in old_versions if v not in new_versions] + + [version_name_to_compat_name(v, ext='') for v in old_versions if v not in new_versions]) + if len(options) > 0 or len(all_options) > 0: + print('To discover what files require manual updating, run:') + if len(options) > 0: print("git grep -- '%s' test-suite/" % r'\|'.join(options)) + if len(all_options) > 0: print("git grep -- '%s'" % r'\|'.join(all_options)) + +def parse_args(argv): + args = { + 'assert_unchanged': False, + 'cur_version': None, + 'number_of_old_versions': DEFAULT_NUMBER_OF_OLD_VERSIONS + } + for arg in argv[1:]: + if arg == '--assert-unchanged': + args['assert_unchanged'] = True + elif arg.startswith('--cur-version='): + args['cur_version'] = arg[len('--cur-version='):] + assert(len(args['cur_version'].split('.')) == 2) + assert(all(map(str.isdigit, args['cur_version'].split('.')))) + elif arg.startswith('--number-of-old-versions='): + args['number_of_old_versions'] = int(arg[len('--number-of-old-versions='):]) + else: + print('USAGE: %s [--assert-unchanged] [--cur-version=NN.NN] [--number-of-old-versions=NN]' % argv[0]) + print('') + print('ERROR: Unrecognized argument: %s' % arg) + sys.exit(1) + return args + +if __name__ == '__main__': + args = parse_args(sys.argv) + args['cur_version'] = get_version(args['cur_version']) + args['number_of_compat_versions'] = args['number_of_old_versions'] + 1 + known_versions = get_known_versions() + new_versions = get_new_versions(known_versions, **args) + assert(len(TEST_SUITE_PATHS) >= args['number_of_compat_versions']) + args['test_suite_paths'] = tuple(TEST_SUITE_PATHS[-args['number_of_compat_versions']:]) + args['test_suite_descriptions'] = tuple(TEST_SUITE_DESCRIPTIONS[-args['number_of_compat_versions']:]) + update_compat_files(known_versions, new_versions, **args) + update_flags(known_versions, new_versions, **args) + update_test_suite(new_versions, **args) + update_doc_index(new_versions, **args) + update_bug_4789(new_versions, **args) + update_compat_notations(known_versions, new_versions, **args) + display_git_grep(known_versions, new_versions) diff --git a/dev/top_printers.ml b/dev/top_printers.ml index ced6ea2614..e15fd776b2 100644 --- a/dev/top_printers.ml +++ b/dev/top_printers.ml @@ -139,7 +139,7 @@ let safe_pr_global = function | ConstRef kn -> pp (str "CONSTREF(" ++ Constant.debug_print kn ++ str ")") | IndRef (kn,i) -> pp (str "INDREF(" ++ MutInd.debug_print kn ++ str "," ++ int i ++ str ")") - | ConstructRef ((kn,i),j) -> pp (str "INDREF(" ++ MutInd.debug_print kn ++ str "," ++ + | ConstructRef ((kn,i),j) -> pp (str "CONSTRUCTREF(" ++ MutInd.debug_print kn ++ str "," ++ int i ++ str "," ++ int j ++ str ")") | VarRef id -> pp (str "VARREF(" ++ Id.print id ++ str ")") diff --git a/doc/sphinx/README.rst b/doc/sphinx/README.rst index 4ad952bdfb..01240a062c 100644 --- a/doc/sphinx/README.rst +++ b/doc/sphinx/README.rst @@ -219,6 +219,9 @@ In addition to the objects above, the ``coqrst`` Sphinx plugin defines the follo Print nat. Definition a := 1. + The blank line after the directive is required. If you begin a proof, + include an ``Abort`` afterwards to reset coqtop for the next example. + Here is a list of permissible options: - Display options diff --git a/doc/sphinx/_static/diffs-coqide-compacted.png b/doc/sphinx/_static/diffs-coqide-compacted.png Binary files differnew file mode 100644 index 0000000000..b64ffeb269 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqide-compacted.png diff --git a/doc/sphinx/_static/diffs-coqide-multigoal.png b/doc/sphinx/_static/diffs-coqide-multigoal.png Binary files differnew file mode 100644 index 0000000000..4020279267 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqide-multigoal.png diff --git a/doc/sphinx/_static/diffs-coqide-on.png b/doc/sphinx/_static/diffs-coqide-on.png Binary files differnew file mode 100644 index 0000000000..f270397ea3 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqide-on.png diff --git a/doc/sphinx/_static/diffs-coqide-removed.png b/doc/sphinx/_static/diffs-coqide-removed.png Binary files differnew file mode 100644 index 0000000000..8f2e71fdc8 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqide-removed.png diff --git a/doc/sphinx/_static/diffs-coqtop-compacted.png b/doc/sphinx/_static/diffs-coqtop-compacted.png Binary files differnew file mode 100644 index 0000000000..b37f0a6771 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqtop-compacted.png diff --git a/doc/sphinx/_static/diffs-coqtop-multigoal.png b/doc/sphinx/_static/diffs-coqtop-multigoal.png Binary files differnew file mode 100644 index 0000000000..cfedde02ac --- /dev/null +++ b/doc/sphinx/_static/diffs-coqtop-multigoal.png diff --git a/doc/sphinx/_static/diffs-coqtop-on.png b/doc/sphinx/_static/diffs-coqtop-on.png Binary files differnew file mode 100644 index 0000000000..bdfcf0af1a --- /dev/null +++ b/doc/sphinx/_static/diffs-coqtop-on.png diff --git a/doc/sphinx/_static/diffs-coqtop-on3.png b/doc/sphinx/_static/diffs-coqtop-on3.png Binary files differnew file mode 100644 index 0000000000..63ff869432 --- /dev/null +++ b/doc/sphinx/_static/diffs-coqtop-on3.png diff --git a/doc/sphinx/biblio.bib b/doc/sphinx/biblio.bib index aa8537c92d..d9eaa2c6c6 100644 --- a/doc/sphinx/biblio.bib +++ b/doc/sphinx/biblio.bib @@ -294,6 +294,17 @@ s}, year = {1994} } +@Article{Myers, + author = {Eugene Myers}, + title = {An {O(ND)} difference algorithm and its variations}, + journal = {Algorithmica}, + volume = {1}, + number = {2}, + year = {1986}, + bibsource = {https://link.springer.com/article/10.1007\%2FBF01840446}, + url = {http://www.xmailserver.org/diff2.pdf} +} + @InProceedings{Parent95b, author = {C. Parent}, booktitle = {{Mathematics of Program Construction'95}}, diff --git a/doc/sphinx/language/gallina-extensions.rst b/doc/sphinx/language/gallina-extensions.rst index 636144e0c8..9dae7fd102 100644 --- a/doc/sphinx/language/gallina-extensions.rst +++ b/doc/sphinx/language/gallina-extensions.rst @@ -606,7 +606,7 @@ for several ways of defining a function *and other useful related objects*, namely: an induction principle that reflects the recursive structure of the function (see :tacn:`function induction`) and its fixpoint equality. The meaning of this declaration is to define a function ident, -similarly to ``Fixpoint`. Like in ``Fixpoint``, the decreasing argument must +similarly to ``Fixpoint``. Like in ``Fixpoint``, the decreasing argument must be given (unless the function is not recursive), but it might not necessarily be *structurally* decreasing. The point of the {} annotation is to name the decreasing argument *and* to describe which kind of diff --git a/doc/sphinx/practical-tools/coq-commands.rst b/doc/sphinx/practical-tools/coq-commands.rst index 343ca9ed7d..de9e327740 100644 --- a/doc/sphinx/practical-tools/coq-commands.rst +++ b/doc/sphinx/practical-tools/coq-commands.rst @@ -85,6 +85,8 @@ Some |Coq| commands call other |Coq| commands. In this case, they look for the commands in directory specified by ``$COQBIN``. If this variable is not set, they look for the commands in the executable path. +.. _COQ_COLORS: + The ``$COQ_COLORS`` environment variable can be used to specify the set of colors used by ``coqtop`` to highlight its output. It uses the same syntax as the ``$LS_COLORS`` variable from GNU’s ls, that is, a colon-separated @@ -93,6 +95,15 @@ list of assignments of the form :n:`name={*; attr}` where ANSI escape code. The list of highlight tags can be retrieved with the ``-list-tags`` command-line option of ``coqtop``. +The string uses ANSI escape codes to represent attributes. For example: + + ``export COQ_COLORS=”diff.added=4;48;2;0;0;240:diff.removed=41”`` + +sets the highlights for added text in diffs to underlined (the 4) with a background RGB +color (0, 0, 240) and for removed text in diffs to a red background. +Note that if you specify ``COQ_COLORS``, the predefined attributes are ignored. + + .. _command-line-options: By command line options @@ -164,9 +175,13 @@ and ``coqtop``, unless stated otherwise: :-w (all|none|w₁,…,wₙ): Configure the display of warnings. This option expects all, none or a comma-separated list of warning names or categories (see Section :ref:`controlling-display`). -:-color (on|off|auto): Enable or not the coloring of output of `coqtop`. - Default is auto, meaning that `coqtop` dynamically decides, depending on - whether the output channel supports ANSI escape sequences. +:-color (on|off|auto): *Coqtop only*. Enable or disable color output. + Default is auto, meaning color is shown only if + the output channel supports ANSI escape sequences. +:-diffs (on|off|removed): *Coqtop only*. Controls highlighting of differences + between proof steps. ``on`` highlights added tokens, ``removed`` highlights both added and + removed tokens. Requires that ``–color`` is enabled. (see Section + :ref:`showing_diffs`). :-beautify: Pretty-print each command to *file.beautified* when compiling *file.v*, in order to get old-fashioned syntax/definitions/notations. diff --git a/doc/sphinx/practical-tools/utilities.rst b/doc/sphinx/practical-tools/utilities.rst index 5d300c3d6d..19995520bb 100644 --- a/doc/sphinx/practical-tools/utilities.rst +++ b/doc/sphinx/practical-tools/utilities.rst @@ -21,16 +21,16 @@ The most basic custom toplevel is built using: % ocamlfind ocamlopt -thread -rectypes -linkall -linkpkg \ -package coq.toplevel \ - toplevel/coqtop\_bin.ml -o my\_toplevel.native + topbin/coqtop_bin.ml -o my_toplevel.native -For example, to statically link |L_tac|, you can just do: +For example, to statically link |Ltac|, you can just do: :: % ocamlfind ocamlopt -thread -rectypes -linkall -linkpkg \ - -package coq.toplevel -package coq.ltac \ - toplevel/coqtop\_bin.ml -o my\_toplevel.native + -package coq.toplevel,coq.plugins.ltac \ + topbin/coqtop_bin.ml -o my_toplevel.native and similarly for other plugins. diff --git a/doc/sphinx/proof-engine/proof-handling.rst b/doc/sphinx/proof-engine/proof-handling.rst index 4b1b7719c5..46851050ac 100644 --- a/doc/sphinx/proof-engine/proof-handling.rst +++ b/doc/sphinx/proof-engine/proof-handling.rst @@ -495,6 +495,10 @@ Requesting information eexists ?[n]. Show n. + .. coqtop:: none + + Abort. + .. cmdv:: Show Script :name: Show Script @@ -581,6 +585,164 @@ Requesting information fixpoint and cofixpoint is violated at some time of the construction of the proof without having to wait the completion of the proof. +.. _showing_diffs: + +Showing differences between proof steps +--------------------------------------- + + +Coq can automatically highlight the differences between successive proof steps. +For example, the following screenshots of CoqIDE and coqtop show the application +of the same :tacn:`intros` tactic. The tactic creates two new hypotheses, highlighted in green. +The conclusion is entirely in pale green because although it’s changed, no tokens were added +to it. The second screenshot uses the "removed" option, so it shows the conclusion a +second time with the old text, with deletions marked in red. Also, since the hypotheses are +new, no line of old text is shown for them. + +.. comment screenshot produced with: + Inductive ev : nat -> Prop := + | ev_0 : ev 0 + | ev_SS : forall n : nat, ev n -> ev (S (S n)). + + Fixpoint double (n:nat) := + match n with + | O => O + | S n' => S (S (double n')) + end. + + Goal forall n, ev n -> exists k, n = double k. + intros n E. + +.. + + .. image:: ../_static/diffs-coqide-on.png + :alt: |CoqIDE| with Set Diffs on + +.. + + .. image:: ../_static/diffs-coqide-removed.png + :alt: |CoqIDE| with Set Diffs removed + +.. + + .. image:: ../_static/diffs-coqtop-on3.png + :alt: coqtop with Set Diffs on + +How to enable diffs +``````````````````` + +.. opt:: Diffs %( "on" %| "off" %| "removed" %) + + .. This ref doesn't work: :opt:`Set Diffs %( "on" %| "off" %| "removed" %)` + + The “on” option highlights added tokens in green, while the “removed” option + additionally reprints items with removed tokens in red. Unchanged tokens in + modified items are shown with pale green or red. (Colors are user-configurable.) + +For coqtop, showing diffs can be enabled when starting coqtop with the +``-diffs on|off|removed`` command-line option or with the ``Set Diffs`` +command within Coq. You will need to provide the ``-color on|auto`` command-line option when +you start coqtop in either case. + +Colors for coqtop can be configured by setting the ``COQ_COLORS`` environment +variable. See section :ref:`customization-by-environment-variables`. Diffs +use the tags ``diff.added``, ``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg``. + +In CoqIDE, diffs should be enabled from the ``View`` menu. Don’t use the ``Set Diffs`` +command in CoqIDE. You can change the background colors shown for diffs from the +``Edit | Preferences | Tags`` panel by changing the settings for the ``diff.added``, +``diff.added.bg``, ``diff.removed`` and ``diff.removed.bg`` tags. This panel also +lets you control other attributes of the highlights, such as the foreground +color, bold, italic, underline and strikeout. + +Note: As of this writing (August 2018), Proof General will need minor changes +to be able to show diffs correctly. We hope it will support this feature soon. +See https://github.com/ProofGeneral/PG/issues/381 for the current status. + +How diffs are calculated +```````````````````````` + +Diffs are calculated as follows: + +1. Select the old proof state to compare to, which is the proof state before + the last tactic that changed the proof. Changes that only affect the view + of the proof, such as ``all: swap 1 2``, are ignored. + +2. For each goal in the new proof state, determine what old goal to compare + it to—the one it is derived from or is the same as. Match the hypotheses by + name (order is ignored), handling compacted items specially. + +3. For each hypothesis and conclusion (the “items”) in each goal, pass + them as strings to the lexer to break them into tokens. Then apply the + Myers diff algorithm :cite:`Myers` on the tokens and add appropriate highlighting. + +Notes: + +* Aside from the highlights, output for the "on" option should be identical + to the undiffed output. +* Goals completed in the last proof step will not be shown even with the + "removed" setting. + +.. comment The following screenshots show diffs working with multiple goals and with compacted + hypotheses. In the first one, notice that the goal ``P 1`` is not highlighted at + all after the split because it has not changed. + + .. todo: Use this script and remove the screenshots when COQ_COLORS + works for coqtop in sphinx + .. coqtop:: none + + Set Diffs "on". + Parameter P : nat -> Prop. + Goal P 1 /\ P 2 /\ P 3. + + .. coqtop:: out + + split. + + .. coqtop:: all + + 2: split. + + .. coqtop:: none + + Abort. + + .. + + .. coqtop:: none + + Set Diffs "on". + Goal forall n m : nat, n + m = m + n. + Set Diffs "on". + + .. coqtop:: out + + intros n. + + .. coqtop:: all + + intros m. + + .. coqtop:: none + + Abort. + +This screen shot shows the result of applying a :tacn:`split` tactic that replaces one goal +with 2 goals. Notice that the goal ``P 1`` is not highlighted at all after +the split because it has not changed. + +.. + + .. image:: ../_static/diffs-coqide-multigoal.png + :alt: coqide with Set Diffs on with multiple goals + +This is how diffs may appear after applying a :tacn:`intro` tactic that results +in compacted hypotheses: + +.. + + .. image:: ../_static/diffs-coqide-compacted.png + :alt: coqide with Set Diffs on with compacted hyptotheses Controlling the effect of proof editing commands ------------------------------------------------ diff --git a/doc/sphinx/proof-engine/tactics.rst b/doc/sphinx/proof-engine/tactics.rst index f99c539251..db9f04ba11 100644 --- a/doc/sphinx/proof-engine/tactics.rst +++ b/doc/sphinx/proof-engine/tactics.rst @@ -2214,6 +2214,7 @@ and an explanation of the underlying technique. ``simple inversion``. .. tacv:: inversion @ident using @ident + :name: inversion ... using ... Let :n:`@ident` have type :g:`(I t)` (:g:`I` an inductive predicate) in the local context, and :n:`@ident` be a (dependent) inversion lemma. Then, this diff --git a/doc/sphinx/user-extensions/proof-schemes.rst b/doc/sphinx/user-extensions/proof-schemes.rst index 59cad3bea2..eacd7b4676 100644 --- a/doc/sphinx/user-extensions/proof-schemes.rst +++ b/doc/sphinx/user-extensions/proof-schemes.rst @@ -12,13 +12,15 @@ The ``Scheme`` command is a high-level tool for generating automatically (possibly mutual) induction principles for given types and sorts. Its syntax follows the schema: -.. cmd:: Scheme @ident := Induction for @ident Sort sort {* with @ident := Induction for @ident Sort sort} +.. cmd:: Scheme @ident__1 := Induction for @ident__2 Sort sort {* with @ident__i := Induction for @ident__j Sort sort} -where each `ident'ᵢ` is a different inductive type identifier -belonging to the same package of mutual inductive definitions. This -command generates the `identᵢ`s to be mutually recursive -definitions. Each term `identᵢ` proves a general principle of mutual -induction for objects in type `identᵢ`. + This command is a high-level tool for generating automatically + (possibly mutual) induction principles for given types and sorts. + Each :n:`@ident__j` is a different inductive type identifier belonging to + the same package of mutual inductive definitions. + The command generates the :n:`@ident__i`\s to be mutually recursive + definitions. Each term :n:`@ident__i` proves a general principle of mutual + induction for objects in type :n:`@ident__j`. .. cmdv:: Scheme @ident := Minimality for @ident Sort sort {* with @ident := Minimality for @ident' Sort sort} @@ -44,9 +46,9 @@ induction for objects in type `identᵢ`. .. coqtop:: none - Axiom A : Set. - Axiom B : Set. - + Axiom A : Set. + Axiom B : Set. + .. coqtop:: all Inductive tree : Set := node : A -> forest -> tree @@ -79,7 +81,7 @@ induction for objects in type `identᵢ`. .. coqtop:: all Inductive odd : nat -> Prop := oddS : forall n:nat, even n -> odd (S n) - with even : nat -> Prop := + with even : nat -> Prop := | evenO : even 0 | evenS : forall n:nat, odd n -> even (S n). @@ -136,19 +138,20 @@ Automatic declaration of schemes Combined Scheme ~~~~~~~~~~~~~~~~~~~~~~ -The ``Combined Scheme`` command is a tool for combining induction -principles generated by the ``Scheme command``. Its syntax follows the -schema : - -.. cmd:: Combined Scheme @ident from {+, ident} +.. cmd:: Combined Scheme @ident from {+, @ident__i} -where each identᵢ after the ``from`` is a different inductive principle that must -belong to the same package of mutual inductive principle definitions. -This command generates the leftmost `ident` to be the conjunction of the -principles: it is built from the common premises of the principles and -concluded by the conjunction of their conclusions. + This command is a tool for combining induction principles generated + by the :cmd:`Scheme` command. + Each :n:`@ident__i` is a different inductive principle that must belong + to the same package of mutual inductive principle definitions. + This command generates :n:`@ident` to be the conjunction of the + principles: it is built from the common premises of the principles + and concluded by the conjunction of their conclusions. + In the case where all the inductive principles used are in sort + ``Prop``, the propositional conjunction ``and`` is used, otherwise + the simple product ``prod`` is used instead. -.. example:: +.. example:: We can define the induction principles for trees and forests using: @@ -170,6 +173,23 @@ concluded by the conjunction of their conclusions. Check tree_forest_mutind. +.. example:: + + We can also combine schemes at sort ``Type``: + + .. coqtop:: all + + Scheme tree_forest_rect := Induction for tree Sort Type + with forest_tree_rect := Induction for forest Sort Type. + + .. coqtop:: all + + Combined Scheme tree_forest_mutrect from tree_forest_rect, forest_tree_rect. + + .. coqtop:: all + + Check tree_forest_mutrect. + .. _functional-scheme: Generation of induction principles with ``Functional`` ``Scheme`` @@ -186,7 +206,7 @@ schema: where each `ident'ᵢ` is a different mutually defined function name (the names must be in the same order as when they were defined). This command generates the induction principle for each `identᵢ`, following -the recursive structure and case analyses of the corresponding function +the recursive structure and case analyses of the corresponding function identᵢ’. .. warning:: @@ -196,7 +216,7 @@ identᵢ’. :cmd:`Function` generally produces smaller principles that are closer to how a user would implement them. See :ref:`advanced-recursive-functions` for details. -.. example:: +.. example:: Induction scheme for div2. @@ -262,11 +282,11 @@ identᵢ’. We define trees by the following mutual inductive type: .. original LaTeX had "Variable" instead of "Axiom", which generates an ugly warning - + .. coqtop:: reset all Axiom A : Set. - + Inductive tree : Set := node : A -> forest -> tree with forest : Set := @@ -313,20 +333,21 @@ identᵢ’. Check tree_size_ind2. .. _derive-inversion: - + Generation of inversion principles with ``Derive`` ``Inversion`` ----------------------------------------------------------------- -The syntax of ``Derive`` ``Inversion`` follows the schema: - .. cmd:: Derive Inversion @ident with forall (x : T), I t Sort sort -This command generates an inversion principle for the `inversion … using` -tactic. Let `I` be an inductive predicate and `x` the variables occurring -in t. This command generates and stocks the inversion lemma for the -sort `sort` corresponding to the instance `∀ (x:T), I t` with the name -`ident` in the global environment. When applied, it is equivalent to -having inverted the instance with the tactic `inversion`. + This command generates an inversion principle for the + :tacn:`inversion ... using ...` tactic. Let :g:`I` be an inductive + predicate and :g:`x` the variables occurring in t. This command + generates and stocks the inversion lemma for the sort :g:`sort` + corresponding to the instance :g:`∀ (x:T), I t` with the name + :n:`@ident` in the global environment. When applied, it is + equivalent to having inverted the instance with the tactic + :g:`inversion`. + .. cmdv:: Derive Inversion_clear @ident with forall (x:T), I t Sort sort @@ -347,7 +368,7 @@ having inverted the instance with the tactic `inversion`. Consider the relation `Le` over natural numbers and the following parameter ``P``: - + .. coqtop:: all Inductive Le : nat -> nat -> Set := @@ -370,9 +391,9 @@ having inverted the instance with the tactic `inversion`. .. coqtop:: none - Goal forall (n m : nat) (H : Le (S n) m), P n m. + Goal forall (n m : nat) (H : Le (S n) m), P n m. intros. - + .. coqtop:: all Show. diff --git a/doc/stdlib/index-list.html.template b/doc/stdlib/index-list.html.template index 0fa42cadad..4cbf75b715 100644 --- a/doc/stdlib/index-list.html.template +++ b/doc/stdlib/index-list.html.template @@ -600,8 +600,8 @@ through the <tt>Require Import</tt> command.</p> </dt> <dd> theories/Compat/AdmitAxiom.v - theories/Compat/Coq86.v theories/Compat/Coq87.v theories/Compat/Coq88.v + theories/Compat/Coq89.v </dd> </dl> diff --git a/doc/tools/coqrst/coqdomain.py b/doc/tools/coqrst/coqdomain.py index edf4e6ec9d..2c69dcfe08 100644 --- a/doc/tools/coqrst/coqdomain.py +++ b/doc/tools/coqrst/coqdomain.py @@ -560,6 +560,9 @@ class CoqtopDirective(Directive): Print nat. Definition a := 1. + The blank line after the directive is required. If you begin a proof, + include an ``Abort`` afterwards to reset coqtop for the next example. + Here is a list of permissible options: - Display options diff --git a/dune-project b/dune-project index 6ce4ec4717..607e5a68a5 100644 --- a/dune-project +++ b/dune-project @@ -1,3 +1,3 @@ -(lang dune 1.1) +(lang dune 1.2) -(name coq-devel) +(name coq) diff --git a/dune-workspace b/dune-workspace index 682631e7dc..38875eac2c 100644 --- a/dune-workspace +++ b/dune-workspace @@ -1,6 +1,6 @@ -(lang dune 1.1) +(lang dune 1.2) ; Add custom flags here. Default developer profile is `dev` (env - (dev (flags :standard -rectypes -w -9-27-50)) + (dev (flags :standard -rectypes -w -9-27-50+60)) (release (flags :standard -rectypes))) diff --git a/engine/eConstr.ml b/engine/eConstr.ml index 678f7c6ce6..8ab3ce821e 100644 --- a/engine/eConstr.ml +++ b/engine/eConstr.ml @@ -14,7 +14,23 @@ open Names open Constr open Context -include Evd.MiniEConstr +module ESorts = struct + include Evd.MiniEConstr.ESorts + + let equal sigma s1 s2 = + Sorts.equal (kind sigma s1) (kind sigma s2) +end + +module EInstance = struct + include Evd.MiniEConstr.EInstance + + let equal sigma i1 i2 = + Univ.Instance.equal (kind sigma i1) (kind sigma i2) +end + +include (Evd.MiniEConstr : module type of Evd.MiniEConstr + with module ESorts := ESorts + and module EInstance := EInstance) type types = t type constr = t @@ -445,38 +461,28 @@ let fold sigma f acc c = match kind sigma c with let compare_gen k eq_inst eq_sort eq_constr nargs c1 c2 = (c1 == c2) || Constr.compare_head_gen_with k k eq_inst eq_sort eq_constr nargs c1 c2 -let eq_einstance sigma i1 i2 = - let i1 = EInstance.kind sigma (EInstance.make i1) in - let i2 = EInstance.kind sigma (EInstance.make i2) in - Univ.Instance.equal i1 i2 - -let eq_esorts sigma s1 s2 = - let s1 = ESorts.kind sigma (ESorts.make s1) in - let s2 = ESorts.kind sigma (ESorts.make s2) in - Sorts.equal s1 s2 - let eq_constr sigma c1 c2 = - let kind c = kind_upto sigma c in - let eq_inst _ _ i1 i2 = eq_einstance sigma i1 i2 in - let eq_sorts s1 s2 = eq_esorts sigma s1 s2 in + let kind c = kind sigma c in + let eq_inst _ _ i1 i2 = EInstance.equal sigma i1 i2 in + let eq_sorts s1 s2 = ESorts.equal sigma s1 s2 in let rec eq_constr nargs c1 c2 = compare_gen kind eq_inst eq_sorts eq_constr nargs c1 c2 in - eq_constr 0 (unsafe_to_constr c1) (unsafe_to_constr c2) + eq_constr 0 c1 c2 let eq_constr_nounivs sigma c1 c2 = - let kind c = kind_upto sigma c in + let kind c = kind sigma c in let rec eq_constr nargs c1 c2 = compare_gen kind (fun _ _ _ _ -> true) (fun _ _ -> true) eq_constr nargs c1 c2 in - eq_constr 0 (unsafe_to_constr c1) (unsafe_to_constr c2) + eq_constr 0 c1 c2 let compare_constr sigma cmp c1 c2 = - let kind c = kind_upto sigma c in - let eq_inst _ _ i1 i2 = eq_einstance sigma i1 i2 in - let eq_sorts s1 s2 = eq_esorts sigma s1 s2 in - let cmp nargs c1 c2 = cmp (of_constr c1) (of_constr c2) in - compare_gen kind eq_inst eq_sorts cmp 0 (unsafe_to_constr c1) (unsafe_to_constr c2) + let kind c = kind sigma c in + let eq_inst _ _ i1 i2 = EInstance.equal sigma i1 i2 in + let eq_sorts s1 s2 = ESorts.equal sigma s1 s2 in + let cmp nargs c1 c2 = cmp c1 c2 in + compare_gen kind eq_inst eq_sorts cmp 0 c1 c2 let compare_cumulative_instances cv_pb nargs_ok variances u u' cstrs = let open UnivProblem in @@ -528,10 +534,10 @@ let cmp_constructors (mind, ind, cns as spec) nargs u1 u2 cstrs = cstrs (Univ.Instance.to_array u1) (Univ.Instance.to_array u2) let eq_universes env sigma cstrs cv_pb ref nargs l l' = - if Univ.Instance.is_empty l then (assert (Univ.Instance.is_empty l'); true) + if EInstance.is_empty l then (assert (EInstance.is_empty l'); true) else - let l = Evd.normalize_universe_instance sigma l - and l' = Evd.normalize_universe_instance sigma l' in + let l = EInstance.kind sigma l + and l' = EInstance.kind sigma l' in let open GlobRef in let open UnivProblem in match ref with @@ -549,7 +555,7 @@ let eq_universes env sigma cstrs cv_pb ref nargs l l' = let test_constr_universes env sigma leq m n = let open UnivProblem in - let kind c = kind_upto sigma c in + let kind c = kind sigma c in if m == n then Some Set.empty else let cstrs = ref Set.empty in @@ -557,16 +563,16 @@ let test_constr_universes env sigma leq m n = let eq_universes ref nargs l l' = eq_universes env sigma cstrs Reduction.CONV ref nargs l l' and leq_universes ref nargs l l' = eq_universes env sigma cstrs cv_pb ref nargs l l' in let eq_sorts s1 s2 = - let s1 = ESorts.kind sigma (ESorts.make s1) in - let s2 = ESorts.kind sigma (ESorts.make s2) in + let s1 = ESorts.kind sigma s1 in + let s2 = ESorts.kind sigma s2 in if Sorts.equal s1 s2 then true else (cstrs := Set.add (UEq (Sorts.univ_of_sort s1,Sorts.univ_of_sort s2)) !cstrs; true) in let leq_sorts s1 s2 = - let s1 = ESorts.kind sigma (ESorts.make s1) in - let s2 = ESorts.kind sigma (ESorts.make s2) in + let s1 = ESorts.kind sigma s1 in + let s2 = ESorts.kind sigma s2 in if Sorts.equal s1 s2 then true else (cstrs := Set.add @@ -587,16 +593,16 @@ let test_constr_universes env sigma leq m n = if res then Some !cstrs else None let eq_constr_universes env sigma m n = - test_constr_universes env sigma false (unsafe_to_constr m) (unsafe_to_constr n) + test_constr_universes env sigma false m n let leq_constr_universes env sigma m n = - test_constr_universes env sigma true (unsafe_to_constr m) (unsafe_to_constr n) + test_constr_universes env sigma true m n let compare_head_gen_proj env sigma equ eqs eqc' nargs m n = - let kind c = kind_upto sigma c in - match kind_upto sigma m, kind_upto sigma n with + let kind c = kind sigma c in + match kind m, kind n with | Proj (p, c), App (f, args) | App (f, args), Proj (p, c) -> - (match kind_upto sigma f with + (match kind f with | Const (p', u) when Constant.equal (Projection.constant p) p' -> let npars = Projection.npars p in if Array.length args == npars + 1 then @@ -612,6 +618,8 @@ let eq_constr_universes_proj env sigma m n = let cstrs = ref Set.empty in let eq_universes ref l l' = eq_universes env sigma cstrs Reduction.CONV ref l l' in let eq_sorts s1 s2 = + let s1 = ESorts.kind sigma s1 in + let s2 = ESorts.kind sigma s2 in if Sorts.equal s1 s2 then true else (cstrs := Set.add @@ -621,7 +629,7 @@ let eq_constr_universes_proj env sigma m n = let rec eq_constr' nargs m n = m == n || compare_head_gen_proj env sigma eq_universes eq_sorts eq_constr' nargs m n in - let res = eq_constr' 0 (unsafe_to_constr m) (unsafe_to_constr n) in + let res = eq_constr' 0 m n in if res then Some !cstrs else None let universes_of_constr sigma c = diff --git a/ide/coq.ml b/ide/coq.ml index e948360191..88ffb4f0b7 100644 --- a/ide/coq.ml +++ b/ide/coq.ml @@ -42,14 +42,11 @@ let version () = "The Coq Proof Assistant, version %s (%s)\ \nArchitecture %s running %s operating system\ \nGtk version is %s\ - \nThis is %s (%s is the best one for this architecture and OS)\ - \n" + \nThis is %s \n" ver date Coq_config.arch Sys.os_type (let x,y,z = GMain.Main.version in Printf.sprintf "%d.%d.%d" x y z) (Filename.basename Sys.executable_name) - Coq_config.best - (** * Initial checks by launching test coqtop processes *) diff --git a/ide/preferences.ml b/ide/preferences.ml index 955ee87840..3f10af04c9 100644 --- a/ide/preferences.ml +++ b/ide/preferences.ml @@ -345,8 +345,15 @@ let _ = attach_modifiers modifier_for_queries "<Actions>/Queries/" let modifiers_valid = new preference ~name:["modifiers_valid"] ~init:"<Alt><Control><Shift>" ~repr:Repr.(string) +let browser_cmd_fmt = + try + let coq_netscape_remote_var = "COQREMOTEBROWSER" in + Sys.getenv coq_netscape_remote_var + with + Not_found -> Coq_config.browser + let cmd_browse = - new preference ~name:["cmd_browse"] ~init:Flags.browser_cmd_fmt ~repr:Repr.(string) + new preference ~name:["cmd_browse"] ~init:browser_cmd_fmt ~repr:Repr.(string) let cmd_editor = let init = if Sys.os_type = "Win32" then "NOTEPAD %s" else "emacs %s" in @@ -359,6 +366,14 @@ let text_font = in new preference ~name:["text_font"] ~init ~repr:Repr.(string) +let is_standard_doc_url url = + let wwwcompatprefix = "http://www.lix.polytechnique.fr/coq/" in + let n = String.length Coq_config.wwwcoq in + let n' = String.length Coq_config.wwwrefman in + url = Coq_config.localwwwrefman || + url = Coq_config.wwwrefman || + url = wwwcompatprefix ^ String.sub Coq_config.wwwrefman n (n'-n) + let doc_url = object inherit [string] preference @@ -366,7 +381,7 @@ object as super method! set v = - if not (Flags.is_standard_doc_url v) && + if not (is_standard_doc_url v) && v <> use_default_doc_url && (* Extra hack to support links to last released doc version *) v <> Coq_config.wwwcoq ^ "doc" && diff --git a/interp/constrexpr.ml b/interp/constrexpr.ml index d8dd4ef6dd..77d612cfd9 100644 --- a/interp/constrexpr.ml +++ b/interp/constrexpr.ml @@ -114,7 +114,6 @@ and constr_expr_r = | CGeneralization of binding_kind * abstraction_kind option * constr_expr | CPrim of prim_token | CDelimiters of string * constr_expr - | CProj of qualid * constr_expr and constr_expr = constr_expr_r CAst.t and case_expr = constr_expr (* expression that is being matched *) diff --git a/interp/constrexpr_ops.ml b/interp/constrexpr_ops.ml index 011c4a6e4e..23d0536df8 100644 --- a/interp/constrexpr_ops.ml +++ b/interp/constrexpr_ops.ml @@ -177,12 +177,10 @@ let rec constr_expr_eq e1 e2 = | CDelimiters(s1,e1), CDelimiters(s2,e2) -> String.equal s1 s2 && constr_expr_eq e1 e2 - | CProj(p1,c1), CProj(p2,c2) -> - qualid_eq p1 p2 && constr_expr_eq c1 c2 | (CRef _ | CFix _ | CCoFix _ | CProdN _ | CLambdaN _ | CLetIn _ | CAppExpl _ | CApp _ | CRecord _ | CCases _ | CLetTuple _ | CIf _ | CHole _ | CPatVar _ | CEvar _ | CSort _ | CCast _ | CNotation _ | CPrim _ - | CGeneralization _ | CDelimiters _ | CProj _), _ -> false + | CGeneralization _ | CDelimiters _ ), _ -> false and args_eq (a1,e1) (a2,e2) = Option.equal (eq_ast explicitation_eq) e1 e2 && @@ -359,8 +357,6 @@ let fold_constr_expr_with_binders g f n acc = CAst.with_val (function (fold_local_binders g f n acc t lb) c lb) l acc | CCoFix (_,_) -> Feedback.msg_warning (strbrk "Capture check in multiple binders not done"); acc - | CProj (_,c) -> - f n acc c ) let free_vars_of_constr_expr c = @@ -439,8 +435,6 @@ let map_constr_expr_with_binders g f e = CAst.map (function let e'' = List.fold_left (fun e ({ CAst.v = id },_,_,_) -> g id e) e' dl in let d' = f e'' d in (id,bl',t',d')) dl) - | CProj (p,c) -> - CProj (p, f e c) ) (* Used in constrintern *) diff --git a/interp/constrextern.ml b/interp/constrextern.ml index 3996a1756c..98e1f6dd36 100644 --- a/interp/constrextern.ml +++ b/interp/constrextern.ml @@ -958,9 +958,6 @@ let rec extern inctx scopes vars r = | GCast (c, c') -> CCast (sub_extern true scopes vars c, map_cast_type (extern_typ scopes vars) c') - | GProj (p, c) -> - let pr = extern_reference ?loc Id.Set.empty (ConstRef (Projection.constant p)) in - CProj (pr, sub_extern inctx scopes vars c) in insert_coercion coercion (CAst.make ?loc c) diff --git a/interp/constrintern.ml b/interp/constrintern.ml index 1c8d957014..d02f59414e 100644 --- a/interp/constrintern.ml +++ b/interp/constrintern.ml @@ -2062,13 +2062,6 @@ let internalize globalenv env pattern_mode (_, ntnvars as lvar) c = | CCast (c1, c2) -> DAst.make ?loc @@ GCast (intern env c1, map_cast_type (intern_type env) c2) - | CProj (pr, c) -> - match intern_reference pr with - | ConstRef p -> - let p = Option.get @@ Recordops.find_primitive_projection p in - DAst.make ?loc @@ GProj (Projection.make p false, intern env c) - | _ -> - raise (InternalizationError (loc,IllegalMetavariable)) (* FIXME *) ) and intern_type env = intern (set_type_scope env) diff --git a/interp/notation_ops.ml b/interp/notation_ops.ml index 06943ce7b9..ff5e2bb5f3 100644 --- a/interp/notation_ops.ml +++ b/interp/notation_ops.ml @@ -89,11 +89,9 @@ let rec eq_notation_constr (vars1,vars2 as vars) t1 t2 = match t1, t2 with glob_sort_eq s1 s2 | NCast (t1, c1), NCast (t2, c2) -> (eq_notation_constr vars) t1 t2 && cast_type_eq (eq_notation_constr vars) c1 c2 -| NProj (p1, c1), NProj (p2, c2) -> - Projection.equal p1 p2 && eq_notation_constr vars c1 c2 | (NRef _ | NVar _ | NApp _ | NHole _ | NList _ | NLambda _ | NProd _ | NBinderList _ | NLetIn _ | NCases _ | NLetTuple _ | NIf _ - | NRec _ | NSort _ | NCast _ | NProj _), _ -> false + | NRec _ | NSort _ | NCast _ ), _ -> false (**********************************************************************) (* Re-interpret a notation as a glob_constr, taking care of binders *) @@ -220,7 +218,6 @@ let glob_constr_of_notation_constr_with_binders ?loc g f e nc = | NSort x -> GSort x | NHole (x, naming, arg) -> GHole (x, naming, arg) | NRef x -> GRef (x,None) - | NProj (p,c) -> GProj (p, f e c) let glob_constr_of_notation_constr ?loc x = let rec aux () x = @@ -440,7 +437,6 @@ let notation_constr_and_vars_of_glob_constr recvars a = if arg != None then has_ltac := true; NHole (w, naming, arg) | GRef (r,_) -> NRef r - | GProj (p, c) -> NProj (p, aux c) | GEvar _ | GPatVar _ -> user_err Pp.(str "Existential variables not allowed in notations.") ) x @@ -640,12 +636,6 @@ let rec subst_notation_constr subst bound raw = let k' = smartmap_cast_type (subst_notation_constr subst bound) k in if r1' == r1 && k' == k then raw else NCast(r1',k') - | NProj (p, c) -> - let p' = subst_proj subst p in - let c' = subst_notation_constr subst bound c in - if p' == p && c' == c then raw else NProj(p', c') - - let subst_interpretation subst (metas,pat) = let bound = List.fold_left (fun accu (id, _) -> Id.Set.add id accu) Id.Set.empty metas in (metas,subst_notation_constr subst bound pat) @@ -1218,12 +1208,9 @@ let rec match_ inner u alp metas sigma a1 a2 = match_names metas (alp,sigma) (Name id') na in match_in u alp metas sigma (mkGApp a1 (DAst.make @@ GVar id')) b2 - | GProj(p1, t1), NProj(p2, t2) when Projection.equal p1 p2 -> - match_in u alp metas sigma t1 t2 - | (GRef _ | GVar _ | GEvar _ | GPatVar _ | GApp _ | GLambda _ | GProd _ | GLetIn _ | GCases _ | GLetTuple _ | GIf _ | GRec _ | GSort _ | GHole _ - | GCast _ | GProj _ ), _ -> raise No_match + | GCast _ ), _ -> raise No_match and match_in u = match_ true u diff --git a/interp/notation_term.ml b/interp/notation_term.ml index 942ea5ff3f..5fb0ca1b43 100644 --- a/interp/notation_term.ml +++ b/interp/notation_term.ml @@ -43,7 +43,6 @@ type notation_constr = notation_constr array * notation_constr array | NSort of glob_sort | NCast of notation_constr * notation_constr cast_type - | NProj of Projection.t * notation_constr (** Note concerning NList: first constr is iterator, second is terminator; first id is where each argument of the list has to be substituted diff --git a/kernel/.merlin.in b/kernel/.merlin.in new file mode 100644 index 0000000000..912ff61496 --- /dev/null +++ b/kernel/.merlin.in @@ -0,0 +1,8 @@ +FLG -rectypes -thread -safe-string -w +a-4-44-50 + +S ../clib +B ../clib +S ../config +B ../config +S ../lib +B ../lib diff --git a/kernel/cClosure.ml b/kernel/cClosure.ml index c4c96c9b55..003b49535f 100644 --- a/kernel/cClosure.ml +++ b/kernel/cClosure.ml @@ -551,45 +551,7 @@ let mk_clos_vect env v = match v with [|mk_clos env v0; mk_clos env v1; mk_clos env v2; mk_clos env v3|] | v -> Array.Fun1.map mk_clos env v -(* Translate the head constructor of t from constr to fconstr. This - function is parameterized by the function to apply on the direct - subterms. - Could be used insted of mk_clos. *) -let mk_clos_deep clos_fun env t = - match kind t with - | (Rel _|Ind _|Const _|Construct _|Var _|Meta _ | Sort _) -> - mk_clos env t - | Cast (a,k,b) -> - { norm = Red; - term = FCast (clos_fun env a, k, clos_fun env b)} - | App (f,v) -> - { norm = Red; - term = FApp (clos_fun env f, Array.Fun1.map clos_fun env v) } - | Proj (p,c) -> - { norm = Red; - term = FProj (p, clos_fun env c) } - | Case (ci,p,c,v) -> - { norm = Red; - term = FCaseT (ci, p, clos_fun env c, v, env) } - | Fix fx -> - { norm = Cstr; term = FFix (fx, env) } - | CoFix cfx -> - { norm = Cstr; term = FCoFix(cfx,env) } - | Lambda _ -> - { norm = Cstr; term = mk_lambda env t } - | Prod (n,t,c) -> - { norm = Whnf; - term = FProd (n, clos_fun env t, clos_fun (subs_lift env) c) } - | LetIn (n,b,t,c) -> - { norm = Red; - term = FLetIn (n, clos_fun env b, clos_fun env t, c, env) } - | Evar ev -> - { norm = Red; term = FEvar(ev,env) } - -(* A better mk_clos? *) -let mk_clos2 = mk_clos_deep mk_clos - -(* The inverse of mk_clos_deep: move back to constr *) +(* The inverse of mk_clos: move back to constr *) let rec to_constr lfts v = match v.term with | FRel i -> mkRel (reloc_rel i lfts) @@ -922,13 +884,18 @@ and knht info e t stk = knht info e a (append_stack (mk_clos_vect e b) stk) | Case(ci,p,t,br) -> knht info e t (ZcaseT(ci, p, br, e)::stk) - | Fix _ -> knh info (mk_clos2 e t) stk + | Fix fx -> knh info { norm = Cstr; term = FFix (fx, e) } stk | Cast(a,_,_) -> knht info e a stk | Rel n -> knh info (clos_rel e n) stk - | Proj (_p,_c) -> knh info (mk_clos2 e t) stk - | (Lambda _|Prod _|Construct _|CoFix _|Ind _| - LetIn _|Const _|Var _|Evar _|Meta _|Sort _) -> - (mk_clos2 e t, stk) + | Proj (p, c) -> knh info { norm = Red; term = FProj (p, mk_clos e c) } stk + | (Ind _|Const _|Construct _|Var _|Meta _ | Sort _) -> (mk_clos e t, stk) + | CoFix cfx -> { norm = Cstr; term = FCoFix (cfx,e) }, stk + | Lambda _ -> { norm = Cstr; term = mk_lambda e t }, stk + | Prod (n, t, c) -> + { norm = Whnf; term = FProd (n, mk_clos e t, mk_clos (subs_lift e) c) }, stk + | LetIn (n,b,t,c) -> + { norm = Red; term = FLetIn (n, mk_clos e b, mk_clos e t, c, e) }, stk + | Evar ev -> { norm = Red; term = FEvar (ev, e) }, stk (************************************************************************) diff --git a/kernel/constr.ml b/kernel/constr.ml index b25f38d630..c97969c0e0 100644 --- a/kernel/constr.ml +++ b/kernel/constr.ml @@ -237,6 +237,17 @@ let mkVar id = Var id let kind c = c +let rec kind_nocast_gen kind c = + match kind c with + | Cast (c, _, _) -> kind_nocast_gen kind c + | App (h, outer) as k -> + (match kind_nocast_gen kind h with + | App (h, inner) -> App (h, Array.append inner outer) + | _ -> k) + | k -> k + +let kind_nocast c = kind_nocast_gen kind c + (* The other way around. We treat specifically smart constructors *) let of_kind = function | App (f, a) -> mkApp (f, a) @@ -755,10 +766,10 @@ let map_with_binders g f l c0 = match kind c0 with let bl' = Array.Fun1.Smart.map f l' bl in mkCoFix (ln,(lna,tl',bl')) -type instance_compare_fn = GlobRef.t -> int -> - Univ.Instance.t -> Univ.Instance.t -> bool +type 'univs instance_compare_fn = GlobRef.t -> int -> + 'univs -> 'univs -> bool -type constr_compare_fn = int -> constr -> constr -> bool +type 'constr constr_compare_fn = int -> 'constr -> 'constr -> bool (* [compare_head_gen_evar k1 k2 u s e eq leq c1 c2] compare [c1] and [c2] (using [k1] to expose the structure of [c1] and [k2] to expose @@ -772,19 +783,16 @@ type constr_compare_fn = int -> constr -> constr -> bool calls to {!Array.equal_norefl}). *) let compare_head_gen_leq_with kind1 kind2 leq_universes leq_sorts eq leq nargs t1 t2 = - match kind1 t1, kind2 t2 with + match kind_nocast_gen kind1 t1, kind_nocast_gen kind2 t2 with + | Cast _, _ | _, Cast _ -> assert false (* kind_nocast *) | Rel n1, Rel n2 -> Int.equal n1 n2 | Meta m1, Meta m2 -> Int.equal m1 m2 | Var id1, Var id2 -> Id.equal id1 id2 | Sort s1, Sort s2 -> leq_sorts s1 s2 - | Cast (c1, _, _), _ -> leq nargs c1 t2 - | _, Cast (c2, _, _) -> leq nargs t1 c2 | Prod (_,t1,c1), Prod (_,t2,c2) -> eq 0 t1 t2 && leq 0 c1 c2 | Lambda (_,t1,c1), Lambda (_,t2,c2) -> eq 0 t1 t2 && eq 0 c1 c2 | LetIn (_,b1,t1,c1), LetIn (_,b2,t2,c2) -> eq 0 b1 b2 && eq 0 t1 t2 && leq nargs c1 c2 (* Why do we suddenly make a special case for Cast here? *) - | App (Cast (c1, _, _), l1), _ -> leq nargs (mkApp (c1, l1)) t2 - | _, App (Cast (c2, _, _), l2) -> leq nargs t1 (mkApp (c2, l2)) | App (c1, l1), App (c2, l2) -> let len = Array.length l1 in Int.equal len (Array.length l2) && diff --git a/kernel/constr.mli b/kernel/constr.mli index ea38dabd5c..2efdae007c 100644 --- a/kernel/constr.mli +++ b/kernel/constr.mli @@ -241,6 +241,11 @@ type ('constr, 'types, 'sort, 'univs) kind_of_term = val kind : constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term val of_kind : (constr, types, Sorts.t, Univ.Instance.t) kind_of_term -> constr +val kind_nocast_gen : ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) -> + ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) + +val kind_nocast : constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term + (** {6 Simple case analysis} *) val isRel : constr -> bool val isRelN : int -> constr -> bool @@ -518,50 +523,50 @@ val iter_with_binders : val fold_constr_with_binders : ('a -> 'a) -> ('a -> 'b -> constr -> 'b) -> 'a -> 'b -> constr -> 'b -type constr_compare_fn = int -> constr -> constr -> bool +type 'constr constr_compare_fn = int -> 'constr -> 'constr -> bool (** [compare_head f c1 c2] compare [c1] and [c2] using [f] to compare the immediate subterms of [c1] of [c2] if needed; Cast's, binders name and Cases annotations are not taken into account *) -val compare_head : constr_compare_fn -> constr_compare_fn +val compare_head : constr constr_compare_fn -> constr constr_compare_fn (** Convert a global reference applied to 2 instances. The int says how many arguments are given (as we can only use cumulativity for fully applied inductives/constructors) .*) -type instance_compare_fn = GlobRef.t -> int -> - Univ.Instance.t -> Univ.Instance.t -> bool +type 'univs instance_compare_fn = GlobRef.t -> int -> + 'univs -> 'univs -> bool (** [compare_head_gen u s f c1 c2] compare [c1] and [c2] using [f] to compare the immediate subterms of [c1] of [c2] if needed, [u] to compare universe instances, [s] to compare sorts; Cast's, binders name and Cases annotations are not taken into account *) -val compare_head_gen : instance_compare_fn -> +val compare_head_gen : Univ.Instance.t instance_compare_fn -> (Sorts.t -> Sorts.t -> bool) -> - constr_compare_fn -> - constr_compare_fn + constr constr_compare_fn -> + constr constr_compare_fn val compare_head_gen_leq_with : - (constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term) -> - (constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term) -> - instance_compare_fn -> - (Sorts.t -> Sorts.t -> bool) -> - constr_compare_fn -> - constr_compare_fn -> - constr_compare_fn + ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) -> + ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) -> + 'univs instance_compare_fn -> + ('sort -> 'sort -> bool) -> + 'v constr_compare_fn -> + 'v constr_compare_fn -> + 'v constr_compare_fn (** [compare_head_gen_with k1 k2 u s f c1 c2] compares [c1] and [c2] like [compare_head_gen u s f c1 c2], except that [k1] (resp. [k2]) is used,rather than {!kind}, to expose the immediate subterms of [c1] (resp. [c2]). *) val compare_head_gen_with : - (constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term) -> - (constr -> (constr, types, Sorts.t, Univ.Instance.t) kind_of_term) -> - instance_compare_fn -> - (Sorts.t -> Sorts.t -> bool) -> - constr_compare_fn -> - constr_compare_fn + ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) -> + ('v -> ('v, 'v, 'sort, 'univs) kind_of_term) -> + 'univs instance_compare_fn -> + ('sort -> 'sort -> bool) -> + 'v constr_compare_fn -> + 'v constr_compare_fn (** [compare_head_gen_leq u s f fle c1 c2] compare [c1] and [c2] using [f] to compare the immediate subterms of [c1] of [c2] for @@ -570,11 +575,11 @@ val compare_head_gen_with : [s] to compare sorts for for subtyping; Cast's, binders name and Cases annotations are not taken into account *) -val compare_head_gen_leq : instance_compare_fn -> +val compare_head_gen_leq : Univ.Instance.t instance_compare_fn -> (Sorts.t -> Sorts.t -> bool) -> - constr_compare_fn -> - constr_compare_fn -> - constr_compare_fn + constr constr_compare_fn -> + constr constr_compare_fn -> + constr constr_compare_fn (** {6 Hashconsing} *) diff --git a/kernel/nativelib.ml b/kernel/nativelib.ml index b4126dd68c..d294f2060e 100644 --- a/kernel/nativelib.ml +++ b/kernel/nativelib.ml @@ -11,7 +11,6 @@ open Util open Nativevalues open Nativecode open CErrors -open Envars (** This file provides facilities to access OCaml compiler and dynamic linker, used by the native compiler. *) @@ -37,7 +36,7 @@ let ( / ) = Filename.concat (* We have to delay evaluation of include_dirs because coqlib cannot be guessed until flags have been properly initialized *) let include_dirs () = - [Filename.get_temp_dir_name (); coqlib () / "kernel"; coqlib () / "library"] + [Filename.get_temp_dir_name (); Envars.coqlib () / "kernel"; Envars.coqlib () / "library"] (* Pointer to the function linking an ML object into coq's toplevel *) let load_obj = ref (fun _x -> () : string -> unit) @@ -89,16 +88,7 @@ let call_compiler ?profile:(profile=false) ml_filename = else [] in - let flambda_args = - if Coq_config.caml_version_nums >= [4;3;0] && Dynlink.is_native then - (* We play safe for now, and use the native compiler - with -Oclassic, however it is likely that `native_compute` - users can benefit from tweaking here. - *) - ["-Oclassic"] - else - [] - in + let flambda_args = if Sys.(backend_type = Native) then ["-Oclassic"] else [] in let args = initial_args @ profile_args @ @@ -108,9 +98,9 @@ let call_compiler ?profile:(profile=false) ml_filename = ::"-w"::"a" ::include_dirs) @ ["-impl"; ml_filename] in - if !Flags.debug then Feedback.msg_debug (Pp.str (ocamlfind () ^ " " ^ (String.concat " " args))); + if !Flags.debug then Feedback.msg_debug (Pp.str (Envars.ocamlfind () ^ " " ^ (String.concat " " args))); try - let res = CUnix.sys_command (ocamlfind ()) args in + let res = CUnix.sys_command (Envars.ocamlfind ()) args in let res = match res with | Unix.WEXITED 0 -> true | Unix.WEXITED _n | Unix.WSIGNALED _n | Unix.WSTOPPED _n -> diff --git a/kernel/safe_typing.ml b/kernel/safe_typing.ml index 9d302c69fb..b036aa6a67 100644 --- a/kernel/safe_typing.ml +++ b/kernel/safe_typing.ml @@ -273,7 +273,6 @@ let add_constraints_list cst senv = List.fold_left (fun acc c -> add_constraints c acc) senv cst let push_context_set poly ctx = add_constraints (Now (poly,ctx)) -let push_context poly ctx = add_constraints (Now (poly,Univ.ContextSet.of_context ctx)) let is_curmod_library senv = match senv.modvariant with LIBRARY -> true | _ -> false diff --git a/kernel/safe_typing.mli b/kernel/safe_typing.mli index 08b97b718e..6e0febaa3f 100644 --- a/kernel/safe_typing.mli +++ b/kernel/safe_typing.mli @@ -128,9 +128,6 @@ val add_modtype : val push_context_set : bool -> Univ.ContextSet.t -> safe_transformer0 -val push_context : - bool -> Univ.UContext.t -> safe_transformer0 - val add_constraints : Univ.Constraint.t -> safe_transformer0 diff --git a/lib/envars.ml b/lib/envars.ml index 3ee0c7106b..cf76b6ebc8 100644 --- a/lib/envars.ml +++ b/lib/envars.ml @@ -36,21 +36,6 @@ let path_to_list p = let sep = if String.equal Sys.os_type "Win32" then ';' else ':' in String.split sep p -let user_path () = - path_to_list (Sys.getenv "PATH") (* may raise Not_found *) - -(* Finding a name in path using the equality provided by the file system *) -(* whether it is case-sensitive or case-insensitive *) -let rec which l f = - match l with - | [] -> - raise Not_found - | p :: tl -> - if Sys.file_exists (p / f) then - p - else - which tl f - let expand_path_macros ~warn s = let rec expand_atom s i = let l = String.length s in @@ -120,14 +105,19 @@ let guess_coqlib fail = fail "cannot guess a path for Coq libraries; please use -coqlib option") ) +let coqlib : string option ref = ref None +let set_user_coqlib path = coqlib := Some path + (** coqlib is now computed once during coqtop initialization *) let set_coqlib ~fail = - if not !Flags.coqlib_spec then + match !coqlib with + | Some _ -> () + | None -> let lib = if !Flags.boot then coqroot else guess_coqlib fail in - Flags.coqlib := lib + coqlib := Some lib -let coqlib () = !Flags.coqlib +let coqlib () = Option.default "" !coqlib let docdir () = (* This assumes implicitly that the suffix is non-trivial *) @@ -155,29 +145,8 @@ let coqpath = (** {2 Caml paths} *) -let exe s = s ^ Coq_config.exec_extension - let ocamlfind () = Coq_config.ocamlfind -(** {2 Camlp5 paths} *) - -let guess_camlp5bin () = which (user_path ()) (exe "camlp5") - -let camlp5bin () = - if !Flags.boot then Coq_config.camlp5bin else - try guess_camlp5bin () - with Not_found -> - Coq_config.camlp5bin - -let camlp5lib () = - if !Flags.boot then - Coq_config.camlp5lib - else - let ex, res = CUnix.run_command (ocamlfind () ^ " query camlp5") in - match ex with - | Unix.WEXITED 0 -> String.strip res - | _ -> "/dev/null" - (** {1 XDG utilities} *) let xdg_data_home warn = @@ -209,8 +178,8 @@ let print_config ?(prefix_var_name="") f coq_src_subdirs = fprintf f "%sDOCDIR=%s/\n" prefix_var_name (docdir ()); fprintf f "%sOCAMLFIND=%s\n" prefix_var_name (ocamlfind ()); fprintf f "%sCAMLP5O=%s\n" prefix_var_name Coq_config.camlp5o; - fprintf f "%sCAMLP5BIN=%s/\n" prefix_var_name (camlp5bin ()); - fprintf f "%sCAMLP5LIB=%s\n" prefix_var_name (camlp5lib ()); + fprintf f "%sCAMLP5BIN=%s/\n" prefix_var_name Coq_config.camlp5bin; + fprintf f "%sCAMLP5LIB=%s\n" prefix_var_name Coq_config.camlp5lib; fprintf f "%sCAMLP5OPTIONS=%s\n" prefix_var_name Coq_config.camlp5compat; fprintf f "%sCAMLFLAGS=%s\n" prefix_var_name Coq_config.caml_flags; fprintf f "%sHASNATDYNLINK=%s\n" prefix_var_name diff --git a/lib/envars.mli b/lib/envars.mli index 66b86252c7..ebf86d0650 100644 --- a/lib/envars.mli +++ b/lib/envars.mli @@ -41,6 +41,9 @@ val configdir : unit -> string (** [set_coqlib] must be runned once before any access to [coqlib] *) val set_coqlib : fail:(string -> string) -> unit +(** [set_user_coqlib path] sets the coqlib directory explicitedly. *) +val set_user_coqlib : string -> unit + (** [coqbin] is the name of the current executable. *) val coqbin : string @@ -58,12 +61,6 @@ val coqpath : string list (** [camlfind ()] is the path to the ocamlfind binary. *) val ocamlfind : unit -> string -(** [camlp5bin ()] is the path to the camlp5 binary. *) -val camlp5bin : unit -> string - -(** [camlp5lib ()] is the path to the camlp5 library. *) -val camlp5lib : unit -> string - (** Coq tries to honor the XDG Base Directory Specification to access the user's configuration files. diff --git a/lib/flags.ml b/lib/flags.ml index 7e0065beba..c8f19f2f11 100644 --- a/lib/flags.ml +++ b/lib/flags.ml @@ -66,25 +66,25 @@ let we_are_parsing = ref false (* Current means no particular compatibility consideration. For correct comparisons, this constructor should remain the last one. *) -type compat_version = V8_6 | V8_7 | Current +type compat_version = V8_7 | V8_8 | Current let compat_version = ref Current let version_compare v1 v2 = match v1, v2 with - | V8_6, V8_6 -> 0 - | V8_6, _ -> -1 - | _, V8_6 -> 1 | V8_7, V8_7 -> 0 | V8_7, _ -> -1 | _, V8_7 -> 1 + | V8_8, V8_8 -> 0 + | V8_8, _ -> -1 + | _, V8_8 -> 1 | Current, Current -> 0 let version_strictly_greater v = version_compare !compat_version v > 0 let version_less_or_equal v = not (version_strictly_greater v) let pr_version = function - | V8_6 -> "8.6" | V8_7 -> "8.7" + | V8_8 -> "8.8" | Current -> "current" (* Translate *) @@ -121,27 +121,6 @@ let warn = ref true let make_warn flag = warn := flag; () let if_warn f x = if !warn then f x -(* Flags for external tools *) - -let browser_cmd_fmt = - try - let coq_netscape_remote_var = "COQREMOTEBROWSER" in - Sys.getenv coq_netscape_remote_var - with - Not_found -> Coq_config.browser - -let is_standard_doc_url url = - let wwwcompatprefix = "http://www.lix.polytechnique.fr/coq/" in - let n = String.length Coq_config.wwwcoq in - let n' = String.length Coq_config.wwwrefman in - url = Coq_config.localwwwrefman || - url = Coq_config.wwwrefman || - url = wwwcompatprefix ^ String.sub Coq_config.wwwrefman n (n'-n) - -(* Options for changing coqlib *) -let coqlib_spec = ref false -let coqlib = ref "(not initialized yet)" - (* Level of inlining during a functor application *) let default_inline_level = 100 diff --git a/lib/flags.mli b/lib/flags.mli index 02d8a3adc1..3d9eafde75 100644 --- a/lib/flags.mli +++ b/lib/flags.mli @@ -58,7 +58,7 @@ val we_are_parsing : bool ref (* Set Printing All flag. For some reason it is a global flag *) val raw_print : bool ref -type compat_version = V8_6 | V8_7 | Current +type compat_version = V8_7 | V8_8 | Current val compat_version : compat_version ref val version_compare : compat_version -> compat_version -> int val version_strictly_greater : compat_version -> bool @@ -118,17 +118,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 -(** Options for external tools *) - -(** Returns string format for default browser to use from Coq or CoqIDE *) -val browser_cmd_fmt : string - -val is_standard_doc_url : string -> bool - -(** Options for specifying where coq librairies reside *) -val coqlib_spec : bool ref -val coqlib : string ref - (** Level of inlining during a functor application *) val set_inline_level : int -> unit val get_inline_level : unit -> int diff --git a/library/coqlib.ml b/library/coqlib.ml index 36a9598f36..026b7aa316 100644 --- a/library/coqlib.ml +++ b/library/coqlib.ml @@ -349,6 +349,9 @@ let coq_iff = lazy_init_reference ["Logic"] "iff" let coq_iff_left_proj = lazy_init_reference ["Logic"] "proj1" let coq_iff_right_proj = lazy_init_reference ["Logic"] "proj2" +let coq_prod = lazy_init_reference ["Datatypes"] "prod" +let coq_pair = lazy_init_reference ["Datatypes"] "pair" + (* Runtime part *) let build_coq_True () = Lazy.force coq_True let build_coq_I () = Lazy.force coq_I @@ -364,6 +367,9 @@ let build_coq_iff () = Lazy.force coq_iff let build_coq_iff_left_proj () = Lazy.force coq_iff_left_proj let build_coq_iff_right_proj () = Lazy.force coq_iff_right_proj +let build_coq_prod () = Lazy.force coq_prod +let build_coq_pair () = Lazy.force coq_pair + (* The following is less readable but does not depend on parsing *) let coq_eq_ref = lazy (init_reference ["Logic"] "eq") diff --git a/library/coqlib.mli b/library/coqlib.mli index b4bd1b0e06..8844684957 100644 --- a/library/coqlib.mli +++ b/library/coqlib.mli @@ -101,7 +101,7 @@ val glob_jmeq : GlobRef.t at compile time. Therefore, we can only provide methods to build them at runtime. This is the purpose of the [constr delayed] and [constr_pattern delayed] types. Objects of this time needs to be - forced with [delayed_force] to get the actual constr or pattern + forced with [delayed_force] to get the actual constr or pattern at runtime. *) type coq_bool_data = { @@ -167,7 +167,7 @@ val build_coq_inversion_eq_true_data : coq_inversion_data delayed val build_coq_sumbool : GlobRef.t delayed (** {6 ... } *) -(** Connectives +(** Connectives The False proposition *) val build_coq_False : GlobRef.t delayed @@ -186,6 +186,10 @@ val build_coq_iff : GlobRef.t delayed val build_coq_iff_left_proj : GlobRef.t delayed val build_coq_iff_right_proj : GlobRef.t delayed +(** Pairs *) +val build_coq_prod : GlobRef.t delayed +val build_coq_pair : GlobRef.t delayed + (** Disjunction *) val build_coq_or : GlobRef.t delayed diff --git a/library/global.ml b/library/global.ml index 5872126a12..e872d081d6 100644 --- a/library/global.ml +++ b/library/global.ml @@ -86,7 +86,6 @@ let push_named_assum a = globalize0 (Safe_typing.push_named_assum a) let push_named_def d = globalize0 (Safe_typing.push_named_def d) let add_constraints c = globalize0 (Safe_typing.add_constraints c) let push_context_set b c = globalize0 (Safe_typing.push_context_set b c) -let push_context b c = globalize0 (Safe_typing.push_context b c) let set_engagement c = globalize0 (Safe_typing.set_engagement c) let set_typing_flags c = globalize0 (Safe_typing.set_typing_flags c) diff --git a/library/global.mli b/library/global.mli index 6aeae9fd02..5205968c7b 100644 --- a/library/global.mli +++ b/library/global.mli @@ -49,7 +49,6 @@ val add_mind : (** Extra universe constraints *) val add_constraints : Univ.Constraint.t -> unit -val push_context : bool -> Univ.UContext.t -> unit val push_context_set : bool -> Univ.ContextSet.t -> unit (** Non-interactive modules and module types *) diff --git a/plugins/funind/glob_term_to_relation.ml b/plugins/funind/glob_term_to_relation.ml index fd2d90e9cf..0c45de4dc4 100644 --- a/plugins/funind/glob_term_to_relation.ml +++ b/plugins/funind/glob_term_to_relation.ml @@ -590,7 +590,6 @@ let rec build_entry_lc env funnames avoid rt : glob_constr build_entry_return = *) build_entry_lc env funnames avoid (mkGApp(b,args)) | GRec _ -> user_err Pp.(str "Not handled GRec") - | GProj _ -> user_err Pp.(str "Funind does not support primitive projections") | GProd _ -> user_err Pp.(str "Cannot apply a type") end (* end of the application treatement *) @@ -696,7 +695,6 @@ let rec build_entry_lc env funnames avoid rt : glob_constr build_entry_return = | GRec _ -> user_err Pp.(str "Not handled GRec") | GCast(b,_) -> build_entry_lc env funnames avoid b - | GProj(_,_) -> user_err Pp.(str "Funind does not support primitive projections") and build_entry_lc_from_case env funname make_discr (el:tomatch_tuples) (brl:Glob_term.cases_clauses) avoid : @@ -1246,7 +1244,7 @@ let rec compute_cst_params relnames params gt = DAst.with_val (function discrimination ones *) | GSort _ -> params | GHole _ -> params - | GIf _ | GRec _ | GCast _ | GProj _ -> + | GIf _ | GRec _ | GCast _ -> raise (UserError(Some "compute_cst_params", str "Not handled case")) ) gt and compute_cst_params_from_app acc (params,rtl) = diff --git a/plugins/funind/glob_termops.ml b/plugins/funind/glob_termops.ml index 954fc3bab4..f81de82d5e 100644 --- a/plugins/funind/glob_termops.ml +++ b/plugins/funind/glob_termops.ml @@ -109,7 +109,6 @@ let change_vars = | GCast(b,c) -> GCast(change_vars mapping b, Glob_ops.map_cast_type (change_vars mapping) c) - | GProj(p,c) -> GProj(p, change_vars mapping c) ) rt and change_vars_br mapping ({CAst.loc;v=(idl,patl,res)} as br) = let new_mapping = List.fold_right Id.Map.remove idl mapping in @@ -294,7 +293,6 @@ let rec alpha_rt excluded rt = GApp(alpha_rt excluded f, List.map (alpha_rt excluded) args ) - | GProj(p,c) -> GProj(p, alpha_rt excluded c) in new_rt @@ -346,7 +344,6 @@ let is_free_in id = | GHole _ -> false | GCast (b,(CastConv t|CastVM t|CastNative t)) -> is_free_in b || is_free_in t | GCast (b,CastCoerce) -> is_free_in b - | GProj (_,c) -> is_free_in c ) x and is_free_in_br {CAst.v=(ids,_,rt)} = (not (Id.List.mem id ids)) && is_free_in rt @@ -440,8 +437,6 @@ let replace_var_by_term x_id term = | GCast(b,c) -> GCast(replace_var_by_pattern b, Glob_ops.map_cast_type replace_var_by_pattern c) - | GProj(p,c) -> - GProj(p,replace_var_by_pattern c) ) x and replace_var_by_pattern_br ({CAst.loc;v=(idl,patl,res)} as br) = if List.exists (fun id -> Id.compare id x_id == 0) idl @@ -545,7 +540,6 @@ let expand_as = | GCases(sty,po,el,brl) -> GCases(sty, Option.map (expand_as map) po, List.map (fun (rt,t) -> expand_as map rt,t) el, List.map (expand_as_br map) brl) - | GProj(p,c) -> GProj(p, expand_as map c) ) and expand_as_br map {CAst.loc; v=(idl,cpl,rt)} = CAst.make ?loc (idl,cpl, expand_as (List.fold_left add_as map cpl) rt) diff --git a/plugins/funind/indfun.ml b/plugins/funind/indfun.ml index e114a0119e..9eda19a86b 100644 --- a/plugins/funind/indfun.ml +++ b/plugins/funind/indfun.ml @@ -222,7 +222,6 @@ let is_rec names = | GCases(_,_,el,brl) -> List.exists (fun (e,_) -> lookup names e) el || List.exists (lookup_br names) brl - | GProj(_,c) -> lookup names c and lookup_br names {CAst.v=(idl,_,rt)} = let new_names = List.fold_right Id.Set.remove idl names in lookup new_names rt @@ -783,7 +782,6 @@ let rec add_args id new_args = CAst.map (function | CNotation _ -> anomaly ~label:"add_args " (Pp.str "CNotation.") | CGeneralization _ -> anomaly ~label:"add_args " (Pp.str "CGeneralization.") | CDelimiters _ -> anomaly ~label:"add_args " (Pp.str "CDelimiters.") - | CProj _ -> user_err Pp.(str "Funind does not support primitive projections") ) exception Stop of Constrexpr.constr_expr diff --git a/pretyping/detyping.ml b/pretyping/detyping.ml index 6a9a042f57..0dc5a9bad5 100644 --- a/pretyping/detyping.ml +++ b/pretyping/detyping.ml @@ -675,8 +675,12 @@ and detype_r d flags avoid env sigma t = (Array.map_to_list (detype d flags avoid env sigma) args) | Const (sp,u) -> GRef (ConstRef sp, detype_instance sigma u) | Proj (p,c) -> - let noparams () = - GProj (p, detype d flags avoid env sigma c) + let noparams () = + let pars = Projection.npars p in + let hole = DAst.make @@ GHole(Evar_kinds.InternalHole,Namegen.IntroAnonymous,None) in + let args = List.make pars hole in + GApp (DAst.make @@ GRef (ConstRef (Projection.constant p), None), + (args @ [detype d flags avoid env sigma c])) in if fst flags || !Flags.in_debugger || !Flags.in_toplevel then try noparams () @@ -1030,10 +1034,6 @@ let rec subst_glob_constr subst = DAst.map (function let k' = smartmap_cast_type (subst_glob_constr subst) k in if r1' == r1 && k' == k then raw else GCast (r1',k') - | GProj (p,c) as raw -> - let p' = subst_proj subst p in - let c' = subst_glob_constr subst c in - if p' == p && c' == c then raw else GProj(p', c') ) (* Utilities to transform kernel cases to simple pattern-matching problem *) diff --git a/pretyping/glob_ops.ml b/pretyping/glob_ops.ml index bd13f1d00a..9b2da0b084 100644 --- a/pretyping/glob_ops.ml +++ b/pretyping/glob_ops.ml @@ -152,10 +152,8 @@ let mk_glob_constr_eq f c1 c2 = match DAst.get c1, DAst.get c2 with Namegen.intro_pattern_naming_eq nam1 nam2 | GCast (c1, t1), GCast (c2, t2) -> f c1 c2 && cast_type_eq f t1 t2 - | GProj (p1, t1), GProj (p2, t2) -> - Projection.equal p1 p2 && f t1 t2 | (GRef _ | GVar _ | GEvar _ | GPatVar _ | GApp _ | GLambda _ | GProd _ | GLetIn _ | - GCases _ | GLetTuple _ | GIf _ | GRec _ | GSort _ | GHole _ | GCast _ | GProj _), _ -> false + GCases _ | GLetTuple _ | GIf _ | GRec _ | GSort _ | GHole _ | GCast _ ), _ -> false let rec glob_constr_eq c = mk_glob_constr_eq glob_constr_eq c @@ -216,8 +214,6 @@ let map_glob_constr_left_to_right f = DAst.map (function let comp1 = f c in let comp2 = map_cast_type f k in GCast (comp1,comp2) - | GProj (p,c) -> - GProj (p, f c) | (GVar _ | GSort _ | GHole _ | GRef _ | GEvar _ | GPatVar _) as x -> x ) @@ -250,8 +246,6 @@ let fold_glob_constr f acc = DAst.with_val (function let acc = match k with | CastConv t | CastVM t | CastNative t -> f acc t | CastCoerce -> acc in f acc c - | GProj(_,c) -> - f acc c | (GSort _ | GHole _ | GRef _ | GEvar _ | GPatVar _) -> acc ) @@ -295,8 +289,6 @@ let fold_glob_constr_with_binders g f v acc = DAst.(with_val (function let acc = match k with | CastConv t | CastVM t | CastNative t -> f v acc t | CastCoerce -> acc in f v acc c - | GProj(_,c) -> - f v acc c | (GSort _ | GHole _ | GRef _ | GEvar _ | GPatVar _) -> acc)) let iter_glob_constr f = fold_glob_constr (fun () -> f) () diff --git a/pretyping/glob_term.ml b/pretyping/glob_term.ml index 86245d4794..c6fdb0ec14 100644 --- a/pretyping/glob_term.ml +++ b/pretyping/glob_term.ml @@ -82,7 +82,6 @@ type 'a glob_constr_r = | GSort of glob_sort | GHole of Evar_kinds.t * Namegen.intro_pattern_naming_expr * Genarg.glob_generic_argument option | GCast of 'a glob_constr_g * 'a glob_constr_g cast_type - | GProj of Projection.t * 'a glob_constr_g and 'a glob_constr_g = ('a glob_constr_r, 'a) DAst.t and 'a glob_decl_g = Name.t * binding_kind * 'a glob_constr_g option * 'a glob_constr_g diff --git a/pretyping/indrec.ml b/pretyping/indrec.ml index dc900ab814..418fdf2a26 100644 --- a/pretyping/indrec.ml +++ b/pretyping/indrec.ml @@ -40,7 +40,7 @@ type recursion_scheme_error = | NotMutualInScheme of inductive * inductive | NotAllowedDependentAnalysis of (*isrec:*) bool * inductive -exception RecursionSchemeError of recursion_scheme_error +exception RecursionSchemeError of env * recursion_scheme_error let named_hd env t na = named_hd env (Evd.from_env env) (EConstr.of_constr t) na let name_assumption env = function @@ -86,7 +86,7 @@ let mis_make_case_com dep env sigma (ind, u as pind) (mib,mip as specif) kind = if not (Sorts.List.mem kind (elim_sorts specif)) then raise (RecursionSchemeError - (NotAllowedCaseAnalysis (false, fst (UnivGen.fresh_sort_in_family kind), pind))) + (env, NotAllowedCaseAnalysis (false, fst (UnivGen.fresh_sort_in_family kind), pind))) in let ndepar = mip.mind_nrealdecls + 1 in @@ -490,7 +490,7 @@ let mis_make_indrec env sigma ?(force_mutual=false) listdepkind mib u = let build_case_analysis_scheme env sigma pity dep kind = let (mib,mip) = lookup_mind_specif env (fst pity) in if dep && not (Inductiveops.has_dependent_elim mib) then - raise (RecursionSchemeError (NotAllowedDependentAnalysis (false, fst pity))); + raise (RecursionSchemeError (env, NotAllowedDependentAnalysis (false, fst pity))); mis_make_case_com dep env sigma pity (mib,mip) kind let is_in_prop mip = @@ -550,9 +550,9 @@ let check_arities env listdepkind = let kelim = elim_sorts (mibi,mipi) in if not (Sorts.List.mem kind kelim) then raise (RecursionSchemeError - (NotAllowedCaseAnalysis (true, fst (UnivGen.fresh_sort_in_family kind),(mind,u)))) + (env, NotAllowedCaseAnalysis (true, fst (UnivGen.fresh_sort_in_family kind),(mind,u)))) else if Int.List.mem ni ln then raise - (RecursionSchemeError (NotMutualInScheme (mind,mind))) + (RecursionSchemeError (env, NotMutualInScheme (mind,mind))) else ni::ln) [] listdepkind in true @@ -561,7 +561,7 @@ let build_mutual_induction_scheme env sigma ?(force_mutual=false) = function | ((mind,u),dep,s)::lrecspec -> let (mib,mip) = lookup_mind_specif env mind in if dep && not (Inductiveops.has_dependent_elim mib) then - raise (RecursionSchemeError (NotAllowedDependentAnalysis (true, mind))); + raise (RecursionSchemeError (env, NotAllowedDependentAnalysis (true, mind))); let (sp,tyi) = mind in let listdepkind = ((mind,u),mib,mip,dep,s):: @@ -572,7 +572,7 @@ let build_mutual_induction_scheme env sigma ?(force_mutual=false) = function let (mibi',mipi') = lookup_mind_specif env mind' in ((mind',u'),mibi',mipi',dep',s') else - raise (RecursionSchemeError (NotMutualInScheme (mind,mind')))) + raise (RecursionSchemeError (env, NotMutualInScheme (mind,mind')))) lrecspec) in let _ = check_arities env listdepkind in @@ -582,7 +582,7 @@ let build_mutual_induction_scheme env sigma ?(force_mutual=false) = function let build_induction_scheme env sigma pind dep kind = let (mib,mip) = lookup_mind_specif env (fst pind) in if dep && not (Inductiveops.has_dependent_elim mib) then - raise (RecursionSchemeError (NotAllowedDependentAnalysis (true, fst pind))); + raise (RecursionSchemeError (env, NotAllowedDependentAnalysis (true, fst pind))); let sigma, l = mis_make_indrec env sigma [(pind,mib,mip,dep,kind)] mib (snd pind) in sigma, List.hd l diff --git a/pretyping/indrec.mli b/pretyping/indrec.mli index de9d3a0abf..91a5651f7f 100644 --- a/pretyping/indrec.mli +++ b/pretyping/indrec.mli @@ -20,7 +20,7 @@ type recursion_scheme_error = | NotMutualInScheme of inductive * inductive | NotAllowedDependentAnalysis of (*isrec:*) bool * inductive -exception RecursionSchemeError of recursion_scheme_error +exception RecursionSchemeError of env * recursion_scheme_error (** Eliminations *) diff --git a/pretyping/patternops.ml b/pretyping/patternops.ml index f7fea22c0f..3c1c470053 100644 --- a/pretyping/patternops.ml +++ b/pretyping/patternops.ml @@ -464,9 +464,6 @@ let rec pat_of_raw metas vars = DAst.with_loc_val (fun ?loc -> function one non-trivial branch. These facts are used in [Constrextern]. *) PCase (info, pred, pat_of_raw metas vars c, brs) - | GProj(p,c) -> - PProj(p, pat_of_raw metas vars c) - | GRec (GFix (ln,n), ids, decls, tl, cl) -> if Array.exists (function (Some n, GStructRec) -> false | _ -> true) ln then err ?loc (Pp.str "\"struct\" annotation is expected.") diff --git a/pretyping/pretyping.ml b/pretyping/pretyping.ml index 162adf0626..1b7f32bcae 100644 --- a/pretyping/pretyping.ml +++ b/pretyping/pretyping.ml @@ -613,11 +613,6 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : GlobEnv.t) evdref let j = pretype_sort ?loc evdref s in inh_conv_coerce_to_tycon ?loc env evdref j tycon - | GProj (p, c) -> - (* TODO: once GProj is used as an input syntax, use bidirectional typing here *) - let cj = pretype empty_tycon env evdref c in - judge_of_projection !!env !evdref p cj - | GApp (f,args) -> let fj = pretype empty_tycon env evdref f in let floc = loc_of_glob_constr f in @@ -795,9 +790,7 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : GlobEnv.t) evdref | [], [] -> [] | _ -> assert false in aux 1 1 (List.rev nal) cs.cs_args, true in - let fsign = if Flags.version_strictly_greater Flags.V8_6 - then Context.Rel.map (whd_betaiota !evdref) fsign - else fsign (* beta-iota-normalization regression in 8.5 and 8.6 *) in + let fsign = Context.Rel.map (whd_betaiota !evdref) fsign in let fsign,env_f = push_rel_context !evdref fsign env in let obj ind p v f = if not record then @@ -896,10 +889,7 @@ let rec pretype k0 resolve_tc (tycon : type_constraint) (env : GlobEnv.t) evdref let pi = lift n pred in (* liftn n 2 pred ? *) let pi = beta_applist !evdref (pi, [EConstr.of_constr (build_dependent_constructor cs)]) in let cs_args = List.map (fun d -> map_rel_decl EConstr.of_constr d) cs.cs_args in - let cs_args = - if Flags.version_strictly_greater Flags.V8_6 - then Context.Rel.map (whd_betaiota !evdref) cs_args - else cs_args (* beta-iota-normalization regression in 8.5 and 8.6 *) in + let cs_args = Context.Rel.map (whd_betaiota !evdref) cs_args in let csgn = List.map (set_name Anonymous) cs_args in diff --git a/pretyping/unification.ml b/pretyping/unification.ml index e223674579..4665486fc0 100644 --- a/pretyping/unification.ml +++ b/pretyping/unification.ml @@ -193,10 +193,7 @@ let pose_all_metas_as_evars env evd t = | None -> let {rebus=ty;freemetas=mvs} = Evd.meta_ftype evd mv in let ty = if Evd.Metaset.is_empty mvs then ty else aux ty in - let ty = - if Flags.version_strictly_greater Flags.V8_6 - then nf_betaiota env evd ty (* How it was in Coq <= 8.4 (but done in logic.ml at this time) *) - else ty (* some beta-iota-normalization "regression" in 8.5 and 8.6 *) in + let ty = nf_betaiota env evd ty in let src = Evd.evar_source_of_meta mv !evdref in let evd, ev = Evarutil.new_evar env !evdref ~src ty in evdref := meta_assign mv (ev,(Conv,TypeNotProcessed)) evd; diff --git a/printing/ppconstr.ml b/printing/ppconstr.ml index 418e13759b..90d2b7abaf 100644 --- a/printing/ppconstr.ml +++ b/printing/ppconstr.ml @@ -675,9 +675,6 @@ let tag_var = tag Tag.variable return (pr_prim_token p, prec_of_prim_token p) | CDelimiters (sc,a) -> return (pr_delimiters sc (pr mt (ldelim,E) a), ldelim) - | CProj (p,c) -> - let p = pr_proj (pr mt) pr_app c (CAst.make (CRef (p,None))) [] in - return (p, lproj) in let loc = constr_loc a in pr_with_comments ?loc diff --git a/printing/printer.ml b/printing/printer.ml index 6cd4daa374..cfa3e8b6e9 100644 --- a/printing/printer.ml +++ b/printing/printer.ml @@ -87,7 +87,6 @@ let pr_leconstr_core = Proof_diffs.pr_leconstr_core let pr_constr_n_env env sigma n c = pr_econstr_n_core false env sigma n (EConstr.of_constr c) let pr_lconstr_env = Proof_diffs.pr_lconstr_env let pr_constr_env env sigma c = pr_econstr_core false env sigma (EConstr.of_constr c) -let _ = Hook.set Refine.pr_constr pr_constr_env let pr_lconstr_goal_style_env env sigma c = pr_leconstr_core true env sigma (EConstr.of_constr c) let pr_constr_goal_style_env env sigma c = pr_econstr_core true env sigma (EConstr.of_constr c) diff --git a/printing/proof_diffs.ml b/printing/proof_diffs.ml index 5bb1053645..0b630b39b5 100644 --- a/printing/proof_diffs.ml +++ b/printing/proof_diffs.ml @@ -523,8 +523,6 @@ let match_goals ot nt = | CPrim p, CPrim p2 -> () | CDelimiters (key,e), CDelimiters (key2,e2) -> constr_expr ogname e e2 - | CProj (pr,c), CProj (pr2,c2) -> - constr_expr ogname c c2 | _, _ -> raise (Diff_Failure "Unable to match goals betwen old and new proof states (5)") end in diff --git a/proofs/refine.ml b/proofs/refine.ml index 198e057ebc..05474d5f84 100644 --- a/proofs/refine.ml +++ b/proofs/refine.ml @@ -44,9 +44,6 @@ let typecheck_evar ev env sigma = let sigma, _ = Typing.sort_of env sigma (Evd.evar_concl info) in sigma -let (pr_constrv,pr_constr) = - Hook.make ~default:(fun _env _sigma _c -> Pp.str"<constr>") () - (* Get the side-effect's constant declarations to update the monad's * environmnent *) let add_if_undefined env eff = @@ -111,7 +108,7 @@ let generic_refine ~typecheck f gl = let sigma = CList.fold_left Proofview.Unsafe.mark_as_goal sigma comb in let comb = CList.map (fun x -> Proofview.goal_with_state x state) comb in let trace () = Pp.(hov 2 (str"simple refine"++spc()++ - Hook.get pr_constrv env sigma (EConstr.Unsafe.to_constr c))) in + Termops.Internal.print_constr_env env sigma c)) in Proofview.Trace.name_tactic trace (Proofview.tclUNIT v) >>= fun v -> Proofview.Unsafe.tclSETENV (Environ.reset_context env) <*> Proofview.Unsafe.tclEVARS sigma <*> diff --git a/proofs/refine.mli b/proofs/refine.mli index 70a23a9fba..1af6463a02 100644 --- a/proofs/refine.mli +++ b/proofs/refine.mli @@ -17,10 +17,6 @@ open Proofview (** {6 The refine tactic} *) -(** Printer used to print the constr which refine refines. *) -val pr_constr : - (Environ.env -> Evd.evar_map -> Constr.constr -> Pp.t) Hook.t - (** {7 Refinement primitives} *) val refine : typecheck:bool -> (Evd.evar_map -> Evd.evar_map * EConstr.t) -> unit tactic diff --git a/proofs/tacmach.ml b/proofs/tacmach.ml index 182b38d350..9e42a71ea8 100644 --- a/proofs/tacmach.ml +++ b/proofs/tacmach.ml @@ -227,4 +227,9 @@ module New = struct let pf_nf_evar gl t = nf_evar (project gl) t + let pf_undefined_evars gl = + let sigma = Proofview.Goal.sigma gl in + let ev = Proofview.Goal.goal gl in + let evi = Evd.find sigma ev in + Evarutil.filtered_undefined_evars_of_evar_info sigma evi end diff --git a/proofs/tacmach.mli b/proofs/tacmach.mli index 31496fb3d5..b4cb2be2b8 100644 --- a/proofs/tacmach.mli +++ b/proofs/tacmach.mli @@ -95,7 +95,7 @@ val refine : constr -> tactic val pr_gls : goal sigma -> Pp.t val pr_glls : goal list sigma -> Pp.t -(* Variants of [Tacmach] functions built with the new proof engine *) +(** Variants of [Tacmach] functions built with the new proof engine *) module New : sig val pf_apply : (env -> evar_map -> 'a) -> Proofview.Goal.t -> 'a val pf_global : Id.t -> Proofview.Goal.t -> GlobRef.t @@ -139,4 +139,6 @@ module New : sig val pf_nf_evar : Proofview.Goal.t -> constr -> constr + (** Gathers the undefined evars of the given goal. *) + val pf_undefined_evars : Proofview.Goal.t -> Evar.Set.t end @@ -1,4 +1,3 @@ -# Some developers don't want a pinned nix-shell by default. -# If you want to use the pin nix-shell or a more sophisticated set of arguments: +# If you want to use a more sophisticated set of arguments: # $ nix-shell default.nix --arg shell true -import ./default.nix { pkgs = import <nixpkgs> {}; shell = true; } +import ./default.nix { shell = true; } diff --git a/tactics/auto.ml b/tactics/auto.ml index d7de6c4fb5..65b2615b6b 100644 --- a/tactics/auto.ml +++ b/tactics/auto.ml @@ -416,6 +416,7 @@ and trivial_resolve sigma dbg mod_delta db_list local_db secvars cl = "nocore" amongst the databases. *) let trivial ?(debug=Off) lems dbnames = + Hints.wrap_hint_warning @@ Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Tacmach.New.project gl in @@ -427,6 +428,7 @@ let trivial ?(debug=Off) lems dbnames = end let full_trivial ?(debug=Off) lems = + Hints.wrap_hint_warning @@ Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Tacmach.New.project gl in @@ -501,6 +503,7 @@ let search d n mod_delta db_list local_db = let default_search_depth = ref 5 let delta_auto debug mod_delta n lems dbnames = + Hints.wrap_hint_warning @@ Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Tacmach.New.project gl in @@ -524,6 +527,7 @@ let new_auto ?(debug=Off) n = delta_auto debug true n let default_auto = auto !default_search_depth [] [] let delta_full_auto ?(debug=Off) mod_delta n lems = + Hints.wrap_hint_warning @@ Proofview.Goal.enter begin fun gl -> let env = Proofview.Goal.env gl in let sigma = Tacmach.New.project gl in diff --git a/tactics/class_tactics.ml b/tactics/class_tactics.ml index f3581f17dd..9bd406e14d 100644 --- a/tactics/class_tactics.ml +++ b/tactics/class_tactics.ml @@ -935,6 +935,9 @@ module Search = struct | Some i -> str ", with depth limit " ++ int i)); tac + let eauto_tac ?st ?unique ~only_classes ?strategy ~depth ~dep hints = + Hints.wrap_hint_warning @@ eauto_tac ?st ?unique ~only_classes ?strategy ~depth ~dep hints + let run_on_evars env evm p tac = match evars_to_goals p evm with | None -> None (* This happens only because there's no evar having p *) @@ -1144,15 +1147,19 @@ let resolve_typeclass_evars debug depth unique env evd filter split fail = (initial_select_evars filter) evd split fail let solve_inst env evd filter unique split fail = - resolve_typeclass_evars + let ((), sigma) = Hints.wrap_hint_warning_fun env evd begin fun evd -> + (), resolve_typeclass_evars (get_typeclasses_debug ()) (get_typeclasses_depth ()) unique env evd filter split fail + end in + sigma let _ = Hook.set Typeclasses.solve_all_instances_hook solve_inst let resolve_one_typeclass env ?(sigma=Evd.from_env env) gl unique = + let (term, sigma) = Hints.wrap_hint_warning_fun env sigma begin fun sigma -> let nc, gl, subst, _ = Evarutil.push_rel_context_to_named_context env sigma gl in let (gl,t,sigma) = Goal.V82.mk_goal sigma nc gl Store.empty in @@ -1170,7 +1177,9 @@ let resolve_one_typeclass env ?(sigma=Evd.from_env env) gl unique = let evd = sig_sig gls' in let t' = mkEvar (ev, Array.of_list subst) in let term = Evarutil.nf_evar evd t' in - evd, term + term, evd + end in + (sigma, term) let _ = Hook.set Typeclasses.solve_one_instance_hook @@ -1206,6 +1215,7 @@ let is_ground c = let autoapply c i = let open Proofview.Notations in + Hints.wrap_hint_warning @@ Proofview.Goal.enter begin fun gl -> let hintdb = try Hints.searchtable_map i with Not_found -> CErrors.user_err (Pp.str ("Unknown hint database " ^ i ^ ".")) diff --git a/tactics/eauto.ml b/tactics/eauto.ml index 80d07c5c03..5067315d08 100644 --- a/tactics/eauto.ml +++ b/tactics/eauto.ml @@ -409,7 +409,7 @@ let e_search_auto debug (in_depth,p) lems db_list gl = (* let e_search_auto = CProfile.profile5 e_search_auto_key e_search_auto *) let eauto_with_bases ?(debug=Off) np lems db_list = - tclTRY (e_search_auto debug np lems db_list) + Proofview.V82.of_tactic (Hints.wrap_hint_warning (Proofview.V82.tactic (tclTRY (e_search_auto debug np lems db_list)))) let eauto ?(debug=Off) np lems dbnames = let db_list = make_db_list dbnames in @@ -420,8 +420,8 @@ let full_eauto ?(debug=Off) n lems gl = tclTRY (e_search_auto debug n lems db_list) gl let gen_eauto ?(debug=Off) np lems = function - | None -> Proofview.V82.tactic (full_eauto ~debug np lems) - | Some l -> Proofview.V82.tactic (eauto ~debug np lems l) + | None -> Hints.wrap_hint_warning (Proofview.V82.tactic (full_eauto ~debug np lems)) + | Some l -> Hints.wrap_hint_warning (Proofview.V82.tactic (eauto ~debug np lems l)) let make_depth = function | None -> !default_search_depth diff --git a/tactics/hints.ml b/tactics/hints.ml index 3835dee299..c0ba363360 100644 --- a/tactics/hints.ml +++ b/tactics/hints.ml @@ -1579,25 +1579,76 @@ let print_mp mp = let is_imported h = try KNmap.find h.uid !statustable with Not_found -> true +let hint_trace = Evd.Store.field () + +let log_hint h = + let open Proofview.Notations in + Proofview.tclEVARMAP >>= fun sigma -> + let store = get_extra_data sigma in + match Store.get store hint_trace with + | None -> + (** All calls to hint logging should be well-scoped *) + assert false + | Some trace -> + let trace = KNmap.add h.uid h trace in + let store = Store.set store hint_trace trace in + Proofview.Unsafe.tclEVARS (set_extra_data store sigma) + let warn_non_imported_hint = CWarnings.create ~name:"non-imported-hint" ~category:"automation" (fun (hint,mp) -> strbrk "Hint used but not imported: " ++ hint ++ print_mp mp) -let warn h x = - let open Proofview in - tclBIND tclENV (fun env -> - tclBIND tclEVARMAP (fun sigma -> - let hint = pr_hint env sigma h in - let (mp, _, _) = KerName.repr h.uid in - warn_non_imported_hint (hint,mp); - Proofview.tclUNIT x)) +let warn env sigma h = + let hint = pr_hint env sigma h in + let (mp, _, _) = KerName.repr h.uid in + warn_non_imported_hint (hint,mp) + +let wrap_hint_warning t = + let open Proofview.Notations in + Proofview.tclEVARMAP >>= fun sigma -> + let store = get_extra_data sigma in + let old = Store.get store hint_trace in + let store = Store.set store hint_trace KNmap.empty in + Proofview.Unsafe.tclEVARS (set_extra_data store sigma) >>= fun () -> + t >>= fun ans -> + Proofview.tclENV >>= fun env -> + Proofview.tclEVARMAP >>= fun sigma -> + let store = get_extra_data sigma in + let hints = match Store.get store hint_trace with + | None -> assert false + | Some hints -> hints + in + let () = KNmap.iter (fun _ h -> warn env sigma h) hints in + let store = match old with + | None -> Store.remove store hint_trace + | Some v -> Store.set store hint_trace v + in + Proofview.Unsafe.tclEVARS (set_extra_data store sigma) >>= fun () -> + Proofview.tclUNIT ans + +let wrap_hint_warning_fun env sigma t = + let store = get_extra_data sigma in + let old = Store.get store hint_trace in + let store = Store.set store hint_trace KNmap.empty in + let (ans, sigma) = t (set_extra_data store sigma) in + let store = get_extra_data sigma in + let hints = match Store.get store hint_trace with + | None -> assert false + | Some hints -> hints + in + let () = KNmap.iter (fun _ h -> warn env sigma h) hints in + let store = match old with + | None -> Store.remove store hint_trace + | Some v -> Store.set store hint_trace v + in + (ans, set_extra_data store sigma) let run_hint tac k = match !warn_hint with | `LAX -> k tac.obj | `WARN -> if is_imported tac then k tac.obj - else Proofview.tclBIND (k tac.obj) (fun x -> warn tac x) + else Proofview.tclTHEN (log_hint tac) (k tac.obj) | `STRICT -> if is_imported tac then k tac.obj else Proofview.tclZERO (UserError (None, (str "Tactic failure."))) diff --git a/tactics/hints.mli b/tactics/hints.mli index c49ca2094a..d63efea27d 100644 --- a/tactics/hints.mli +++ b/tactics/hints.mli @@ -282,6 +282,15 @@ val make_db_list : hint_db_name list -> hint_db list val typeclasses_db : hint_db_name val rewrite_db : hint_db_name +val wrap_hint_warning : 'a Proofview.tactic -> 'a Proofview.tactic +(** Use around toplevel calls to hint-using tactics, to enable the tracking of + non-imported hints. Any tactic calling [run_hint] must be wrapped this + way. *) + +val wrap_hint_warning_fun : env -> evar_map -> + (evar_map -> 'a * evar_map) -> 'a * evar_map +(** Variant of the above for non-tactics *) + (** Printing hints *) val pr_searchtable : env -> evar_map -> Pp.t diff --git a/tactics/inv.ml b/tactics/inv.ml index 43786c8e19..f718b13a63 100644 --- a/tactics/inv.ml +++ b/tactics/inv.ml @@ -495,7 +495,7 @@ let raw_inversion inv_kind id status names = (* Error messages of the inversion tactics *) let wrap_inv_error id = function (e, info) -> match e with | Indrec.RecursionSchemeError - (Indrec.NotAllowedCaseAnalysis (_,(Type _ | Set as k),i)) -> + (_, Indrec.NotAllowedCaseAnalysis (_,(Type _ | Set as k),i)) -> Proofview.tclENV >>= fun env -> Proofview.tclEVARMAP >>= fun sigma -> tclZEROMSG ( diff --git a/test-suite/Makefile b/test-suite/Makefile index 93ce519350..bde0bfc91f 100644 --- a/test-suite/Makefile +++ b/test-suite/Makefile @@ -102,7 +102,7 @@ VSUBSYSTEMS := prerequisite success failure $(BUGS) output \ coqdoc ssr # All subsystems -SUBSYSTEMS := $(VSUBSYSTEMS) misc bugs ide vio coqchk coqwc coq-makefile unit-tests +SUBSYSTEMS := $(VSUBSYSTEMS) misc bugs ide vio coqchk coqwc coq-makefile tools unit-tests PREREQUISITELOG = prerequisite/admit.v.log \ prerequisite/make_local.v.log prerequisite/make_notation.v.log \ @@ -174,6 +174,7 @@ summary: $(call summary_dir, "Coqwc tests", coqwc); \ $(call summary_dir, "Coq makefile", coq-makefile); \ $(call summary_dir, "Coqdoc tests", coqdoc); \ + $(call summary_dir, "tools/ tests", tools); \ $(call summary_dir, "Unit tests", unit-tests); \ nb_success=`find . -name '*.log' -exec tail -n2 '{}' \; | grep -e $(log_success) | wc -l`; \ nb_failure=`find . -name '*.log' -exec tail -n2 '{}' \; | grep -e $(log_failure) | wc -l`; \ @@ -652,3 +653,23 @@ $(addsuffix .log,$(wildcard coqdoc/*.v)): %.v.log: %.v %.html.out %.tex.out $(PR $(FAIL); \ fi; \ } > "$@" + +# tools/ + +tools: $(patsubst %/run.sh,%.log,$(wildcard tools/*/run.sh)) + +tools/%.log : tools/%/run.sh + @echo "TEST tools/$*" + $(HIDE)(\ + export COQBIN=$(BIN);\ + cd tools/$* && \ + bash run.sh 2>&1; \ + if [ $$? = 0 ]; then \ + echo $(log_success); \ + echo " $<...Ok"; \ + else \ + echo $(log_failure); \ + echo " $<...Error!"; \ + $(FAIL); \ + fi; \ + ) > "$@" diff --git a/test-suite/bugs/closed/2378.v b/test-suite/bugs/closed/2378.v index 6d73d58d4e..b9dd654057 100644 --- a/test-suite/bugs/closed/2378.v +++ b/test-suite/bugs/closed/2378.v @@ -73,7 +73,7 @@ Fixpoint LPTransfo Pred1 Pred2 p2lp (f: LP Pred1): LP Pred2 := end. Arguments LPTransfo : default implicits. -Definition addIndex (Ind:Type) (Pred: Ind -> Type) (i: Ind) f := +Definition addIndex (Ind:Type) (Pred: Ind -> Type) (i: Ind) f := LPTransfo (fun p => LPPred _ (existT (fun i => Pred i) i p)) f. Section TTS. @@ -121,8 +121,8 @@ Record simu (Pred: Type) (a: TTS StateA) (c: TTS StateC) (tra: Pred -> LP (Predi Delay _ a (mabs m ex1 st1) d (mabs m (mDelay m ex1 st1 d) st2); simuNext: forall ex1 st1 st2, Next _ c st1 st2 -> inv ex1 st1 -> Next _ a (mabs m ex1 st1) (mabs m (mNext m ex1 st1) st2); - simuPred: forall ext st, inv ext st -> - (forall p, lpSat (Satisfy _ c) st (trc p) <-> lpSat (Satisfy _ a) (mabs m ext st) (tra p)) + simuPred: forall ext st, inv ext st -> + (forall p, lpSat (Satisfy _ c) st (trc p) <-> lpSat (Satisfy _ a) (mabs m ext st) (tra p)) }. Theorem satProd: forall State Ind Pred (Sat: forall i, State -> Pred i -> Prop) (st:State) i (f: LP (Pred i)), @@ -137,15 +137,15 @@ Qed. Definition trProd (State: Type) Ind (Pred: Ind -> Type) (tts: Ind -> TTS State) (tr: forall i, (Pred i) -> LP (Predicate _ (tts i))): {i:Ind & Pred i} -> LP (Predicate _ (TTSIndexedProduct _ Ind tts)) := - fun p => addIndex Ind _ (projS1 p) (tr (projS1 p) (projS2 p)). + fun p => addIndex Ind _ (projT1 p) (tr (projT1 p) (projT2 p)). Arguments trProd : default implicits. Require Import Setoid. Theorem satTrProd: - forall State Ind Pred (tts: Ind -> TTS State) + forall State Ind Pred (tts: Ind -> TTS State) (tr: forall i, (Pred i) -> LP (Predicate _ (tts i))) (st:State) (p: {i:Ind & (Pred i)}), - lpSat (Satisfy _ (tts (projS1 p))) st (tr (projS1 p) (projS2 p)) + lpSat (Satisfy _ (tts (projT1 p))) st (tr (projT1 p) (projT2 p)) <-> lpSat (Satisfy _ (TTSIndexedProduct _ _ tts)) st (trProd _ tts tr p). Proof. @@ -154,11 +154,11 @@ Proof. (fun i => Satisfy _ (tts i))); tauto. Qed. -Theorem simuProd: - forall Ind (Pred: Ind -> Type) (tta: Ind -> TTS StateA) (ttc: Ind -> TTS StateC) +Theorem simuProd: + forall Ind (Pred: Ind -> Type) (tta: Ind -> TTS StateA) (ttc: Ind -> TTS StateC) (tra: forall i, (Pred i) -> LP (Predicate _ (tta i))) (trc: forall i, (Pred i) -> LP (Predicate _ (ttc i))), - (forall i, simu _ (tta i) (ttc i) (tra i) (trc i)) -> + (forall i, simu _ (tta i) (ttc i) (tra i) (trc i)) -> simu _ (TTSIndexedProduct _ Ind tta) (TTSIndexedProduct _ Ind ttc) (trProd Pred tta tra) (trProd Pred ttc trc). Proof. @@ -171,11 +171,11 @@ Proof. eapply simuDelay; eauto. eapply simuNext; eauto. split; simpl; intros. - generalize (proj1 (simuPred _ _ _ _ _ (X (projS1 p)) ext st (H (projS1 p)) (projS2 p))); simpl; intro. + generalize (proj1 (simuPred _ _ _ _ _ (X (projT1 p)) ext st (H (projT1 p)) (projT2 p))); simpl; intro. rewrite <- (satTrProd StateA Ind Pred tta tra); apply H1. rewrite (satTrProd StateC Ind Pred ttc trc); apply H0. - generalize (proj2 (simuPred _ _ _ _ _ (X (projS1 p)) ext st (H (projS1 p)) (projS2 p))); simpl; intro. + generalize (proj2 (simuPred _ _ _ _ _ (X (projT1 p)) ext st (H (projT1 p)) (projT2 p))); simpl; intro. rewrite <- (satTrProd StateC Ind Pred ttc trc); apply H1. rewrite (satTrProd StateA Ind Pred tta tra); apply H0. Qed. @@ -189,11 +189,11 @@ Record simu_equiv StateA StateC m1 m2 Pred (a: TTS StateA) (c: TTS StateC) (tra: simuRL: simu StateC StateA m2 Pred c a trc tra }. -Theorem simu_equivProd: - forall StateA StateC m1 m2 Ind (Pred: Ind -> Type) (tta: Ind -> TTS StateA) (ttc: Ind -> TTS StateC) +Theorem simu_equivProd: + forall StateA StateC m1 m2 Ind (Pred: Ind -> Type) (tta: Ind -> TTS StateA) (ttc: Ind -> TTS StateC) (tra: forall i, (Pred i) -> LP (Predicate _ (tta i))) (trc: forall i, (Pred i) -> LP (Predicate _ (ttc i))), - (forall i, simu_equiv StateA StateC m1 m2 _ (tta i) (ttc i) (tra i) (trc i)) -> + (forall i, simu_equiv StateA StateC m1 m2 _ (tta i) (ttc i) (tra i) (trc i)) -> simu_equiv StateA StateC m1 m2 _ (TTSIndexedProduct _ Ind tta) (TTSIndexedProduct _ Ind ttc) (trProd _ _ Pred tta tra) (trProd _ _ Pred ttc trc). Proof. @@ -237,7 +237,7 @@ Definition pPredicate (L: RTLanguage) (sys: PSyntax L) := { i : pIndex L sys & M (* product with shared state *) -Definition PLanguage (L: RTLanguage): RTLanguage := +Definition PLanguage (L: RTLanguage): RTLanguage := mkRTLanguage (PSyntax L) (pState L) @@ -246,7 +246,7 @@ Definition PLanguage (L: RTLanguage): RTLanguage := eq_refl => Semantic L (pComponents L mdl i) end)) (pPredicate L) - (fun mdl => trProd _ _ _ _ + (fun mdl => trProd _ _ _ _ (fun i pi => match pIsShared L mdl i as e in (_ = y) return (LP (Predicate y match e in (_ = y0) return (TTS y0) with @@ -259,22 +259,22 @@ Definition PLanguage (L: RTLanguage): RTLanguage := Inductive Empty: Type :=. Record isSharedTransfo l1 l2 tr: Prop := isSharedTransfoPrf { -sameState: forall mdl i j, +sameState: forall mdl i j, DynamicState l2 (Tmodel l1 l2 tr (pComponents l1 mdl i)) = DynamicState l2 (Tmodel l1 l2 tr (pComponents l1 mdl j)); -sameMState: forall mdl i j, +sameMState: forall mdl i j, mState _ _ (Tl1l2 _ _ tr (pComponents l1 mdl i)) = mState _ _ (Tl1l2 _ _ tr (pComponents l1 mdl j)); -sameM12: forall mdl i j, +sameM12: forall mdl i j, Tl1l2 _ _ tr (pComponents l1 mdl i) = match sym_eq (sameState mdl i j) in _=y return mapping _ y with eq_refl => match sym_eq (pIsShared l1 mdl i) in _=x return mapping x _ with eq_refl => match pIsShared l1 mdl j in _=x return mapping x _ with eq_refl => Tl1l2 _ _ tr (pComponents l1 mdl j) end - end + end end; -sameM21: forall mdl i j, +sameM21: forall mdl i j, Tl2l1 l1 l2 tr (pComponents l1 mdl i) = match sym_eq (sameState mdl i j) in (_ = y) @@ -301,7 +301,7 @@ end Definition PTransfoSyntax l1 l2 tr (h: isSharedTransfo l1 l2 tr) mdl := mkPSyntax l2 (pIndex l1 mdl) (pIsEmpty l1 mdl) - (match pIsEmpty l1 mdl return Type with + (match pIsEmpty l1 mdl return Type with inleft i => DynamicState l2 (Tmodel l1 l2 tr (pComponents l1 mdl i)) |inright h => pState l1 mdl end) @@ -314,7 +314,7 @@ Definition PTransfoSyntax l1 l2 tr (h: isSharedTransfo l1 l2 tr) mdl := | inright _ => pState l1 mdl end) with - inleft j => sameState l1 l2 tr h mdl i j + inleft j => sameState l1 l2 tr h mdl i j | inright h => match h i with end end). @@ -388,12 +388,12 @@ match pIsEmpty l1 mdl with addIndex (pIndex l1 mdl) (fun i => MdlPredicate l2 (Tmodel l1 l2 tr (pComponents l1 mdl i))) x (LPTransfo (Tpred l1 l2 tr (pComponents l1 mdl x)) (LPPred (MdlPredicate l1 (pComponents l1 mdl x)) p)) -| inright f => match f (projS1 pp) with end +| inright f => match f (projT1 pp) with end end. -Lemma simu_eqA: +Lemma simu_eqA: forall A1 A2 C m P sa sc tta ttc (h: A2=A1), - simu A1 C (match h in (_=y) return mapping _ C with eq_refl => m end) + simu A1 C (match h in (_=y) return mapping _ C with eq_refl => m end) P (match h in (_=y) return TTS y with eq_refl => sa end) sc (fun p => match h in (_=y) return LP (Predicate y _) with eq_refl => tta p end) ttc -> @@ -401,9 +401,9 @@ Lemma simu_eqA: admit. Qed. -Lemma simu_eqC: +Lemma simu_eqC: forall A C1 C2 m P sa sc tta ttc (h: C2=C1), - simu A C1 (match h in (_=y) return mapping A _ with eq_refl => m end) + simu A C1 (match h in (_=y) return mapping A _ with eq_refl => m end) P sa (match h in (_=y) return TTS y with eq_refl => sc end) tta (fun p => match h in (_=y) return LP (Predicate y _) with eq_refl => ttc p end) -> @@ -411,10 +411,10 @@ Lemma simu_eqC: admit. Qed. -Lemma simu_eqA1: +Lemma simu_eqA1: forall A1 A2 C m P sa sc tta ttc (h: A1=A2), - simu A1 C m - P + simu A1 C m + P (match (sym_eq h) in (_=y) return TTS y with eq_refl => sa end) sc (fun p => match (sym_eq h) as e in (_=y) return LP (Predicate y (match e in (_=z) return TTS z with eq_refl => sa end)) with eq_refl => tta p end) ttc -> @@ -422,32 +422,32 @@ Lemma simu_eqA1: admit. Qed. -Lemma simu_eqA2: +Lemma simu_eqA2: forall A1 A2 C m P sa sc tta ttc (h: A1=A2), simu A1 C (match (sym_eq h) in (_=y) return mapping _ C with eq_refl => m end) - P + P sa sc tta ttc -> simu A2 C m P - (match h in (_=y) return TTS y with eq_refl => sa end) sc + (match h in (_=y) return TTS y with eq_refl => sa end) sc (fun p => match h as e in (_=y) return LP (Predicate y match e in (_=y0) return TTS y0 with eq_refl => sa end) with eq_refl => tta p end) ttc. admit. Qed. -Lemma simu_eqC2: +Lemma simu_eqC2: forall A C1 C2 m P sa sc tta ttc (h: C1=C2), simu A C1 (match (sym_eq h) in (_=y) return mapping A _ with eq_refl => m end) - P + P sa sc tta ttc -> simu A C2 m P - sa (match h in (_=y) return TTS y with eq_refl => sc end) + sa (match h in (_=y) return TTS y with eq_refl => sc end) tta (fun p => match h as e in (_=y) return LP (Predicate y match e in (_=y0) return TTS y0 with eq_refl => sc end) with eq_refl => ttc p end). admit. Qed. -Lemma simu_eqM: +Lemma simu_eqM: forall A C m1 m2 P sa sc tta ttc (h: m1=m2), simu A C m1 P sa sc tta ttc -> @@ -470,7 +470,7 @@ Lemma LPTransfo_addIndex: addIndex Ind tr1 (projT1 p0) (tr2 (projT1 p0) (projT2 p0))) (addIndex Ind Pred x p). Proof. - unfold addIndex; intros. + unfold addIndex; intros. rewrite LPTransfo_trans. rewrite LPTransfo_trans. simpl. @@ -491,7 +491,7 @@ Lemma LPTransfo_addIndex_tr: addIndex Ind tr1 (projT1 p0) (tr3 (projT1 p0) (tr2 (projT1 p0) (projT2 p0)))) (addIndex Ind Pred x p). Proof. - unfold addIndex; simpl; intros. + unfold addIndex; simpl; intros. rewrite LPTransfo_trans; simpl. rewrite <- LPTransfo_trans. f_equal. @@ -505,19 +505,19 @@ Qed. Require Export Coq.Logic.FunctionalExtensionality. Print PLanguage. -Program Definition PTransfo l1 l2 (tr: Transformation l1 l2) (h: isSharedTransfo l1 l2 tr): +Program Definition PTransfo l1 l2 (tr: Transformation l1 l2) (h: isSharedTransfo l1 l2 tr): Transformation (PLanguage l1) (PLanguage l2) := mkTransformation (PLanguage l1) (PLanguage l2) (PTransfoSyntax l1 l2 tr h) (Pmap12 l1 l2 tr h) (Pmap21 l1 l2 tr h) (PTpred l1 l2 tr h) - (fun mdl => simu_equivProd - (pState l1 mdl) - (pState l2 (PTransfoSyntax l1 l2 tr h mdl)) + (fun mdl => simu_equivProd + (pState l1 mdl) + (pState l2 (PTransfoSyntax l1 l2 tr h mdl)) (Pmap12 l1 l2 tr h mdl) (Pmap21 l1 l2 tr h mdl) - (pIndex l1 mdl) + (pIndex l1 mdl) (fun i => MdlPredicate l1 (pComponents l1 mdl i)) (compSemantic l1 mdl) (compSemantic l2 (PTransfoSyntax l1 l2 tr h mdl)) diff --git a/test-suite/bugs/closed/4306.v b/test-suite/bugs/closed/4306.v index 28f028ad89..80c348d207 100644 --- a/test-suite/bugs/closed/4306.v +++ b/test-suite/bugs/closed/4306.v @@ -1,13 +1,13 @@ Require Import List. Require Import Arith. -Require Import Recdef. +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 + | (x :: xs', y :: ys') => match Nat.compare x y with | Lt => x :: foo (xs', y :: ys') | Eq => x :: foo (xs', ys') | Gt => y :: foo (x :: xs', ys') @@ -24,7 +24,7 @@ Function bar (xys : (list nat * list nat)) {measure (fun xys => length (fst xys) match (xs, ys) with | (nil, _) => ys | (_, nil) => xs - | (x :: xs', y :: ys') => match Compare_dec.nat_compare x y with + | (x :: xs', y :: ys') => match Nat.compare x y with | Lt => x :: foo (xs', ys) | Eq => x :: foo (xs', ys') | Gt => y :: foo (xs, ys') diff --git a/test-suite/bugs/closed/4798.v b/test-suite/bugs/closed/4798.v index 6f2bcb9685..41a1251ca5 100644 --- a/test-suite/bugs/closed/4798.v +++ b/test-suite/bugs/closed/4798.v @@ -1,3 +1,3 @@ Check match 2 with 0 => 0 | S n => n end. -Notation "|" := 1 (compat "8.6"). +Notation "|" := 1 (compat "8.7"). Check match 2 with 0 => 0 | S n => n end. (* fails *) diff --git a/test-suite/coqchk/cumulativity.v b/test-suite/coqchk/cumulativity.v index 034684054d..c3f6bebcbe 100644 --- a/test-suite/coqchk/cumulativity.v +++ b/test-suite/coqchk/cumulativity.v @@ -27,41 +27,35 @@ End ListLower. Lemma LowerL_Lem@{i j|j<i+} (A : Type@{j}) (l : List@{i} A) : l = LowerL@{j i} l. Proof. reflexivity. Qed. -(* -I disable these tests because cqochk can't process them when compiled with - ocaml-4.02.3+32bit and camlp5-4.16 which is the case for Travis! - I have added this file (including the commented parts below) in - test-suite/success/cumulativity.v which doesn't run coqchk on them. -*) -(* Inductive Tp := tp : Type -> Tp. *) +Inductive Tp := tp : Type -> Tp. -(* Section TpLift. *) -(* Universe i j. *) +Section TpLift. -(* Constraint i < j. *) + Universe i j. -(* Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x. *) + Constraint i < j. -(* End TpLift. *) + Definition LiftTp : Tp@{i} -> Tp@{j} := fun x => x. -(* Lemma LiftC_Lem (t : Tp) : LiftTp t = t. *) -(* Proof. reflexivity. Qed. *) +End TpLift. -(* Section TpLower. *) -(* Universe i j. *) +Lemma LiftC_Lem (t : Tp) : LiftTp t = t. +Proof. reflexivity. Qed. -(* Constraint i < j. *) +Section TpLower. + Universe i j. -(* Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x. *) + Constraint i < j. -(* End TpLower. *) + Fail Definition LowerTp : Tp@{j} -> Tp@{i} := fun x => x. +End TpLower. -(* Section subtyping_test. *) -(* Universe i j. *) -(* Constraint i < j. *) +Section subtyping_test. + Universe i j. + Constraint i < j. -(* Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2. *) + Inductive TP2 := tp2 : Type@{i} -> Type@{j} -> TP2. -(* End subtyping_test. *) +End subtyping_test. diff --git a/test-suite/output/PrintInfos.out b/test-suite/output/PrintInfos.out index 1307a8f26d..975b2ef7ff 100644 --- a/test-suite/output/PrintInfos.out +++ b/test-suite/output/PrintInfos.out @@ -85,8 +85,8 @@ bar : forall x : nat, x = 0 Argument x is implicit and maximally inserted Module Coq.Init.Peano -Notation existS2 := existT2 -Expands to: Notation Coq.Init.Specif.existS2 +Notation sym_eq := eq_sym +Expands to: Notation Coq.Init.Logic.sym_eq Inductive eq (A : Type) (x : A) : A -> Prop := eq_refl : x = x For eq: Argument A is implicit and maximally inserted diff --git a/test-suite/output/PrintInfos.v b/test-suite/output/PrintInfos.v index a498db3e89..62aa80f8ab 100644 --- a/test-suite/output/PrintInfos.v +++ b/test-suite/output/PrintInfos.v @@ -26,8 +26,7 @@ About bar. Print bar. About Peano. (* Module *) -Set Warnings "-deprecated". -About existS2. (* Notation *) +About sym_eq. (* Notation *) Arguments eq_refl {A} {x}, {A} x. Print eq_refl. @@ -46,4 +45,3 @@ Goal forall n:nat, let g := newdef in n <> newdef n -> newdef n <> n -> False. About g. (* search hypothesis *) About h. (* search hypothesis *) Abort. - diff --git a/test-suite/output/UnivBinders.out b/test-suite/output/UnivBinders.out index f8f11d7cf6..1e50ba511a 100644 --- a/test-suite/output/UnivBinders.out +++ b/test-suite/output/UnivBinders.out @@ -5,7 +5,7 @@ PWrap has primitive projections with eta conversion. For PWrap: Argument scope is [type_scope] For pwrap: Argument scopes are [type_scope _] punwrap@{u} = -fun (A : Type@{u}) (p : PWrap@{u} A) => p.(punwrap) +fun (A : Type@{u}) (p : PWrap@{u} A) => punwrap _ p : forall A : Type@{u}, PWrap@{u} A -> A (* u |= *) diff --git a/test-suite/stm/Nijmegen_QArithSternBrocot_Zaux.v b/test-suite/stm/Nijmegen_QArithSternBrocot_Zaux.v index 06357cfc21..3c427237b4 100644 --- a/test-suite/stm/Nijmegen_QArithSternBrocot_Zaux.v +++ b/test-suite/stm/Nijmegen_QArithSternBrocot_Zaux.v @@ -23,7 +23,7 @@ Require Export ZArithRing. Tactic Notation "ElimCompare" constr(c) constr(d) := elim_compare c d. Ltac Flip := - apply Zgt_lt || apply Zlt_gt || apply Zle_ge || apply Zge_le; assumption. + apply Z.gt_lt || apply Z.lt_gt || apply Z.le_ge || apply Z.ge_le; assumption. Ltac Falsum := try intro; apply False_ind; @@ -37,12 +37,12 @@ Ltac Falsum := Ltac Step_l a := match goal with | |- (?X1 < ?X2)%Z => replace X1 with a; [ idtac | try ring ] - end. + end. Ltac Step_r a := match goal with | |- (?X1 < ?X2)%Z => replace X2 with a; [ idtac | try ring ] - end. + end. Ltac CaseEq formula := generalize (refl_equal formula); pattern formula at -1 in |- *; @@ -53,7 +53,7 @@ Lemma pair_1 : forall (A B : Set) (H : A * B), H = pair (fst H) (snd H). Proof. intros. case H. - intros. + intros. simpl in |- *. reflexivity. Qed. @@ -73,10 +73,10 @@ Proof. Qed. -Section projection. +Section projection. Variable A : Set. Variable P : A -> Prop. - + Definition projP1 (H : sig P) := let (x, h) := H in x. Definition projP2 (H : sig P) := let (x, h) as H return (P (projP1 H)) := H in h. @@ -131,11 +131,11 @@ Declare Right Step neq_stepr. Lemma not_O_S : forall n : nat, n <> 0 -> {p : nat | n = S p}. -Proof. +Proof. intros [| np] Hn; [ exists 0; apply False_ind; apply Hn | exists np ]; - reflexivity. + reflexivity. Qed. - + Lemma lt_minus_neq : forall m n : nat, m < n -> n - m <> 0. Proof. @@ -156,12 +156,12 @@ Proof. Qed. Lemma le_plus_O_l : forall p q : nat, p + q <= 0 -> p = 0. -Proof. +Proof. intros; omega. Qed. Lemma le_plus_O_r : forall p q : nat, p + q <= 0 -> q = 0. -Proof. +Proof. intros; omega. Qed. @@ -228,8 +228,8 @@ Proof. assumption. intro. right. - apply Zle_lt_trans with (m := x). - apply Zge_le. + apply Z.le_lt_trans with (m := x). + apply Z.ge_le. assumption. assumption. Qed. @@ -268,7 +268,7 @@ Proof. left. assumption. intro H0. - generalize (Zge_le _ _ H0). + generalize (Z.ge_le _ _ H0). intro. case (Z_le_lt_eq_dec _ _ H1). intro. @@ -290,25 +290,25 @@ Proof. left. assumption. intro H. - generalize (Zge_le _ _ H). + generalize (Z.ge_le _ _ H). intro H0. case (Z_le_lt_eq_dec y x H0). intro H1. left. right. - apply Zlt_gt. + apply Z.lt_gt. assumption. intro. right. symmetry in |- *. assumption. Qed. - + Lemma Z_dec' : forall x y : Z, {(x < y)%Z} + {(y < x)%Z} + {x = y}. Proof. intros x y. - case (Z_eq_dec x y); intro H; + case (Z.eq_dec x y); intro H; [ right; assumption | left; apply (not_Zeq_inf _ _ H) ]. Qed. @@ -321,7 +321,7 @@ Proof. assumption. intro. right. - apply Zge_le. + apply Z.ge_le. assumption. Qed. @@ -335,7 +335,7 @@ Lemma Z_lt_lt_S_eq_dec : Proof. intros. generalize (Zlt_le_succ _ _ H). - unfold Zsucc in |- *. + unfold Z.succ in |- *. apply Z_le_lt_eq_dec. Qed. @@ -347,7 +347,7 @@ Proof. case (Z_lt_le_dec a c). intro z. right. - intro. + intro. elim H. intros. generalize z. @@ -356,8 +356,8 @@ Proof. intro. case (Z_lt_le_dec b d). intro z0. - right. - intro. + right. + intro. elim H. intros. generalize z0. @@ -367,7 +367,7 @@ Proof. left. split. assumption. - assumption. + assumption. Qed. (*###########################################################################*) @@ -386,30 +386,30 @@ Qed. Lemma Zlt_minus : forall a b : Z, (b < a)%Z -> (0 < a - b)%Z. Proof. - intros a b. + intros a b. intros. apply Zplus_lt_reg_l with b. - unfold Zminus in |- *. + unfold Zminus in |- *. rewrite (Zplus_comm a). - rewrite (Zplus_assoc b (- b)). + rewrite (Zplus_assoc b (- b)). rewrite Zplus_opp_r. - simpl in |- *. - rewrite <- Zplus_0_r_reverse. + simpl in |- *. + rewrite <- Zplus_0_r_reverse. assumption. Qed. Lemma Zle_minus : forall a b : Z, (b <= a)%Z -> (0 <= a - b)%Z. Proof. - intros a b. + intros a b. intros. apply Zplus_le_reg_l with b. - unfold Zminus in |- *. + unfold Zminus in |- *. rewrite (Zplus_comm a). - rewrite (Zplus_assoc b (- b)). + rewrite (Zplus_assoc b (- b)). rewrite Zplus_opp_r. - simpl in |- *. - rewrite <- Zplus_0_r_reverse. + simpl in |- *. + rewrite <- Zplus_0_r_reverse. assumption. Qed. @@ -417,7 +417,7 @@ Lemma Zlt_plus_plus : forall m n p q : Z, (m < n)%Z -> (p < q)%Z -> (m + p < n + q)%Z. Proof. intros. - apply Zlt_trans with (m := (n + p)%Z). + apply Z.lt_trans with (m := (n + p)%Z). rewrite Zplus_comm. rewrite Zplus_comm with (n := n). apply Zplus_lt_compat_l. @@ -459,11 +459,11 @@ Lemma Zge_gt_plus_plus : Proof. intros. case (Zle_lt_or_eq n m). - apply Zge_le. + apply Z.ge_le. assumption. intro. apply Zgt_plus_plus. - apply Zlt_gt. + apply Z.lt_gt. assumption. assumption. intro. @@ -521,7 +521,7 @@ Qed. Lemma Zle_neg_opp : forall x : Z, (x <= 0)%Z -> (0 <= - x)%Z. -Proof. +Proof. intros. apply Zplus_le_reg_l with x. rewrite Zplus_opp_r. @@ -530,7 +530,7 @@ Proof. Qed. Lemma Zle_pos_opp : forall x : Z, (0 <= x)%Z -> (- x <= 0)%Z. -Proof. +Proof. intros. apply Zplus_le_reg_l with x. rewrite Zplus_opp_r. @@ -542,7 +542,7 @@ Qed. Lemma Zge_opp : forall x y : Z, (x <= y)%Z -> (- x >= - y)%Z. Proof. intros. - apply Zle_ge. + apply Z.le_ge. apply Zplus_le_reg_l with (p := (x + y)%Z). ring_simplify (x + y + - y)%Z (x + y + - x)%Z. assumption. @@ -584,8 +584,8 @@ Proof. ring_simplify (- a * x + a * x)%Z. replace (- a * x + a * y)%Z with ((y - x) * a)%Z. apply Zmult_gt_0_le_0_compat. - apply Zlt_gt. - assumption. + apply Z.lt_gt. + assumption. unfold Zminus in |- *. apply Zle_left. assumption. @@ -621,7 +621,7 @@ Proof. rewrite H0. reflexivity. Qed. - + Lemma Zsimpl_mult_l : forall n m p : Z, n <> 0%Z -> (n * m)%Z = (n * p)%Z -> m = p. Proof. @@ -642,14 +642,14 @@ Lemma Zlt_reg_mult_l : Proof. intros. case (Zcompare_Gt_spec x 0). - unfold Zgt in H. + unfold Z.gt in H. assumption. intros. - cut (x = Zpos x0). + cut (x = Zpos x0). intro. rewrite H2. - unfold Zlt in H0. - unfold Zlt in |- *. + unfold Z.lt in H0. + unfold Z.lt in |- *. cut ((Zpos x0 * y ?= Zpos x0 * z)%Z = (y ?= z)%Z). intro. exact (trans_eq H3 H0). @@ -672,10 +672,10 @@ Proof. intro. cut ((y ?= x)%Z = (- x ?= - y)%Z). intro. - exact (trans_eq H0 H1). + exact (trans_eq H0 H1). exact (Zcompare_opp y x). apply sym_eq. - exact (Zlt_gt x y H). + exact (Z.lt_gt x y H). Qed. @@ -698,22 +698,22 @@ Proof. intro. rewrite H6 in H4. assumption. - exact (Zopp_involutive (x * z)). - exact (Zopp_involutive (x * y)). + exact (Z.opp_involutive (x * z)). + exact (Z.opp_involutive (x * y)). cut ((- (- x * y))%Z = (- - (x * y))%Z). intro. rewrite H4 in H3. - cut ((- (- x * z))%Z = (- - (x * z))%Z). + cut ((- (- x * z))%Z = (- - (x * z))%Z). intro. rewrite H5 in H3. assumption. cut ((- x * z)%Z = (- (x * z))%Z). intro. - exact (f_equal Zopp H5). + exact (f_equal Z.opp H5). exact (Zopp_mult_distr_l_reverse x z). cut ((- x * y)%Z = (- (x * y))%Z). intro. - exact (f_equal Zopp H4). + exact (f_equal Z.opp H4). exact (Zopp_mult_distr_l_reverse x y). exact (Zlt_opp (- x * y) (- x * z) H2). exact (Zlt_reg_mult_l (- x) y z H1 H0). @@ -735,14 +735,14 @@ Proof. assumption. exact (sym_eq H2). exact (Zorder.Zlt_not_eq y x H0). - exact (Zgt_lt x y H). + exact (Z.gt_lt x y H). Qed. Lemma Zmult_resp_nonzero : forall x y : Z, x <> 0%Z -> y <> 0%Z -> (x * y)%Z <> 0%Z. Proof. intros x y Hx Hy Hxy. - apply Hx. + apply Hx. apply Zmult_integral_l with y; assumption. Qed. @@ -769,12 +769,12 @@ Qed. Lemma not_Zle_lt : forall x y : Z, ~ (y <= x)%Z -> (x < y)%Z. Proof. - intros; apply Zgt_lt; apply Znot_le_gt; assumption. + intros; apply Z.gt_lt; apply Znot_le_gt; assumption. Qed. Lemma not_Zlt : forall x y : Z, ~ (y < x)%Z -> (x <= y)%Z. Proof. - intros x y H1 H2; apply H1; apply Zgt_lt; assumption. + intros x y H1 H2; apply H1; apply Z.gt_lt; assumption. Qed. @@ -813,7 +813,7 @@ Proof. cut (x > 0)%Z. intro. exact (Zlt_reg_mult_l x y z H4 H2). - exact (Zlt_gt 0 x H3). + exact (Z.lt_gt 0 x H3). intro. apply False_ind. cut (x * z < x * y)%Z. @@ -849,7 +849,7 @@ Proof. cut (x > 0)%Z. intro. exact (Zlt_reg_mult_l x z y H4 H2). - exact (Zlt_gt 0 x H3). + exact (Z.lt_gt 0 x H3). Qed. Lemma Zlt_mult_mult : @@ -857,9 +857,9 @@ Lemma Zlt_mult_mult : (0 < a)%Z -> (0 < d)%Z -> (a < b)%Z -> (c < d)%Z -> (a * c < b * d)%Z. Proof. intros. - apply Zlt_trans with (a * d)%Z. + apply Z.lt_trans with (a * d)%Z. apply Zlt_reg_mult_l. - Flip. + Flip. assumption. rewrite Zmult_comm. rewrite Zmult_comm with b d. @@ -881,11 +881,11 @@ Proof. apply Zgt_not_eq. assumption. trivial. - + intro. case (not_Zeq x y H1). trivial. - + intro. apply False_ind. cut (a * y > a * x)%Z. @@ -913,14 +913,14 @@ Proof. rewrite Zmult_opp_opp. rewrite Zmult_opp_opp. assumption. - apply Zopp_involutive. - apply Zopp_involutive. - apply Zgt_lt. + apply Z.opp_involutive. + apply Z.opp_involutive. + apply Z.gt_lt. apply Zlt_opp. - apply Zgt_lt. + apply Z.gt_lt. assumption. simpl in |- *. - rewrite Zopp_involutive. + rewrite Z.opp_involutive. assumption. Qed. @@ -944,7 +944,7 @@ Proof. constructor. replace (-1 * y)%Z with (- y)%Z. replace (-1 * x)%Z with (- x)%Z. - apply Zlt_gt. + apply Z.lt_gt. assumption. ring. ring. @@ -959,13 +959,13 @@ Proof. trivial. intro. apply False_ind. - apply (Zlt_irrefl (a * x)). - apply Zle_lt_trans with (m := (a * y)%Z). + apply (Z.lt_irrefl (a * x)). + apply Z.le_lt_trans with (m := (a * y)%Z). assumption. - apply Zgt_lt. + apply Z.gt_lt. apply Zlt_conv_mult_l. assumption. - apply Zgt_lt. + apply Z.gt_lt. assumption. Qed. @@ -973,17 +973,17 @@ Lemma Zlt_mult_cancel_l : forall x y z : Z, (0 < x)%Z -> (x * y < x * z)%Z -> (y < z)%Z. Proof. intros. - apply Zgt_lt. + apply Z.gt_lt. apply Zgt_mult_reg_absorb_l with x. - apply Zlt_gt. - assumption. - apply Zlt_gt. + apply Z.lt_gt. + assumption. + apply Z.lt_gt. assumption. Qed. - + Lemma Zmin_cancel_Zle : forall x y : Z, (- x <= - y)%Z -> (y <= x)%Z. -Proof. +Proof. intros. apply Zmult_cancel_Zle with (a := (-1)%Z). constructor. @@ -1004,18 +1004,18 @@ Proof. trivial. intro. apply False_ind. - apply (Zlt_irrefl (a * y)). - apply Zle_lt_trans with (m := (a * x)%Z). + apply (Z.lt_irrefl (a * y)). + apply Z.le_lt_trans with (m := (a * x)%Z). assumption. apply Zlt_reg_mult_l. - apply Zlt_gt. + apply Z.lt_gt. assumption. - apply Zgt_lt. + apply Z.gt_lt. assumption. Qed. Lemma Zopp_Zle : forall x y : Z, (y <= x)%Z -> (- x <= - y)%Z. -Proof. +Proof. intros. apply Zmult_cancel_Zle with (a := (-1)%Z). constructor. @@ -1026,7 +1026,7 @@ Proof. clear x H; ring. Qed. - + Lemma Zle_lt_eq_S : forall x y : Z, (x <= y)%Z -> (y < x + 1)%Z -> y = x. Proof. intros. @@ -1035,8 +1035,8 @@ Proof. apply False_ind. generalize (Zlt_le_succ x y H1). intro. - apply (Zlt_not_le y (x + 1) H0). - replace (x + 1)%Z with (Zsucc x). + apply (Zlt_not_le y (x + 1) H0). + replace (x + 1)%Z with (Z.succ x). assumption. reflexivity. intro H1. @@ -1053,8 +1053,8 @@ Proof. apply False_ind. generalize (Zlt_le_succ x y H). intro. - apply (Zlt_not_le y (x + 1) H1). - replace (x + 1)%Z with (Zsucc x). + apply (Zlt_not_le y (x + 1) H1). + replace (x + 1)%Z with (Z.succ x). assumption. reflexivity. trivial. @@ -1067,9 +1067,9 @@ Proof. intros. case (Z_zerop c). intro. - rewrite e. + rewrite e. left. - apply sym_not_eq. + apply sym_not_eq. intro. apply H; repeat split; assumption. intro; right; assumption. @@ -1085,21 +1085,21 @@ Proof. [ apply False_ind; apply H; repeat split | right; right ] | right; left ] | left ]; assumption. -Qed. +Qed. Lemma mediant_1 : forall m n m' n' : Z, (m' * n < m * n')%Z -> ((m + m') * n < m * (n + n'))%Z. Proof. - intros. - rewrite Zmult_plus_distr_r. + intros. + rewrite Zmult_plus_distr_r. rewrite Zmult_plus_distr_l. apply Zplus_lt_compat_l. assumption. Qed. - + Lemma mediant_2 : forall m n m' n' : Z, - (m' * n < m * n')%Z -> (m' * (n + n') < (m + m') * n')%Z. + (m' * n < m * n')%Z -> (m' * (n + n') < (m + m') * n')%Z. Proof. intros. rewrite Zmult_plus_distr_l. @@ -1121,7 +1121,7 @@ Proof. assumption. assumption. ring. -Qed. +Qed. Lemma fraction_lt_trans : forall a b c d e f : Z, @@ -1130,21 +1130,21 @@ Lemma fraction_lt_trans : (0 < f)%Z -> (a * d < c * b)%Z -> (c * f < e * d)%Z -> (a * f < e * b)%Z. Proof. intros. - apply Zgt_lt. + apply Z.gt_lt. apply Zgt_mult_reg_absorb_l with d. Flip. apply Zgt_trans with (c * b * f)%Z. replace (d * (e * b))%Z with (b * (e * d))%Z. replace (c * b * f)%Z with (b * (c * f))%Z. - apply Zlt_gt. + apply Z.lt_gt. apply Zlt_reg_mult_l. Flip. assumption. ring. ring. - replace (c * b * f)%Z with (f * (c * b))%Z. + replace (c * b * f)%Z with (f * (c * b))%Z. replace (d * (a * f))%Z with (f * (a * d))%Z. - apply Zlt_gt. + apply Z.lt_gt. apply Zlt_reg_mult_l. Flip. assumption. @@ -1157,7 +1157,7 @@ Lemma square_pos : forall a : Z, a <> 0%Z -> (0 < a * a)%Z. Proof. intros [| p| p]; intros; [ Falsum | constructor | constructor ]. Qed. - + Hint Resolve square_pos: zarith. (*###########################################################################*) @@ -1182,19 +1182,19 @@ Proof. intros. unfold Z_of_nat in |- *. rewrite H0. - + apply f_equal with (A := positive) (B := Z) (f := Zpos). cut (P_of_succ_nat (nat_of_P p) = P_of_succ_nat (S x)). intro. rewrite P_of_succ_nat_o_nat_of_P_eq_succ in H1. - cut (Ppred (Psucc p) = Ppred (P_of_succ_nat (S x))). + cut (Pos.pred (Pos.succ p) = Pos.pred (P_of_succ_nat (S x))). intro. - rewrite Ppred_succ in H2. + rewrite Pos.pred_succ in H2. simpl in H2. - rewrite Ppred_succ in H2. + rewrite Pos.pred_succ in H2. apply sym_eq. assumption. - apply f_equal with (A := positive) (B := positive) (f := Ppred). + apply f_equal with (A := positive) (B := positive) (f := Pos.pred). assumption. apply f_equal with (f := P_of_succ_nat). assumption. @@ -1222,7 +1222,7 @@ Lemma NEG_neq_ZERO : forall p : positive, Zneg p <> 0%Z. Proof. intros. apply Zorder.Zlt_not_eq. - unfold Zlt in |- *. + unfold Z.lt in |- *. constructor. Qed. @@ -1237,7 +1237,7 @@ Qed. Lemma nat_nat_pos : forall m n : nat, ((m + 1) * (n + 1) > 0)%Z. (*QF*) Proof. intros. - apply Zlt_gt. + apply Z.lt_gt. cut (Z_of_nat m + 1 > 0)%Z. intro. cut (0 < Z_of_nat n + 1)%Z. @@ -1246,24 +1246,24 @@ Proof. rewrite Zmult_0_r. intro. assumption. - + apply Zlt_reg_mult_l. assumption. assumption. - change (0 < Zsucc (Z_of_nat n))%Z in |- *. + change (0 < Z.succ (Z_of_nat n))%Z in |- *. apply Zle_lt_succ. change (Z_of_nat 0 <= Z_of_nat n)%Z in |- *. apply Znat.inj_le. apply le_O_n. - apply Zlt_gt. - change (0 < Zsucc (Z_of_nat m))%Z in |- *. + apply Z.lt_gt. + change (0 < Z.succ (Z_of_nat m))%Z in |- *. apply Zle_lt_succ. change (Z_of_nat 0 <= Z_of_nat m)%Z in |- *. apply Znat.inj_le. apply le_O_n. Qed. - - + + Theorem S_predn : forall m : nat, m <> 0 -> S (pred m) = m. (*QF*) Proof. intros. @@ -1271,8 +1271,8 @@ Proof. intro. case s. intros. - rewrite <- e. - rewrite <- pred_Sn with (n := x). + rewrite <- e. + rewrite <- pred_Sn with (n := x). trivial. intro. apply False_ind. @@ -1281,7 +1281,7 @@ Proof. assumption. Qed. -Lemma absolu_1 : forall x : Z, Zabs_nat x = 0 -> x = 0%Z. (*QF*) +Lemma absolu_1 : forall x : Z, Z.abs_nat x = 0 -> x = 0%Z. (*QF*) Proof. intros. case (dec_eq x 0). @@ -1302,15 +1302,15 @@ Proof. apply proj1 with (B := x = 0%Z -> (x ?= 0)%Z = Datatypes.Eq). change ((x ?= 0)%Z = Datatypes.Eq <-> x = 0%Z) in |- *. apply Zcompare_Eq_iff_eq. - + (***) intro. - cut (exists h : nat, Zabs_nat x = S h). + cut (exists h : nat, Z.abs_nat x = S h). intro. case H3. rewrite H. exact O_S. - + change (x < 0)%Z in H2. cut (0 > x)%Z. intro. @@ -1324,7 +1324,7 @@ Proof. case H6. intros. rewrite H7. - unfold Zabs_nat in |- *. + unfold Z.abs_nat in |- *. generalize x1. exact ZL4. cut (x = (- Zpos x0)%Z). @@ -1335,21 +1335,21 @@ Proof. cut ((- - x)%Z = x). intro. rewrite <- H6. - exact (f_equal Zopp H5). - apply Zopp_involutive. + exact (f_equal Z.opp H5). + apply Z.opp_involutive. apply Zcompare_Gt_spec. assumption. - apply Zlt_gt. + apply Z.lt_gt. assumption. - + (***) intro. - cut (exists h : nat, Zabs_nat x = S h). + cut (exists h : nat, Z.abs_nat x = S h). intro. case H3. rewrite H. exact O_S. - + cut (exists p : positive, (x + - (0))%Z = Zpos p). simpl in |- *. rewrite Zplus_0_r. @@ -1357,12 +1357,12 @@ Proof. case H3. intros. rewrite H4. - unfold Zabs_nat in |- *. + unfold Z.abs_nat in |- *. generalize x0. exact ZL4. apply Zcompare_Gt_spec. assumption. - + (***) cut ((x < 0)%Z \/ (0 < x)%Z). intro. @@ -1373,14 +1373,14 @@ Proof. assumption. intro. right. - apply Zlt_gt. + apply Z.lt_gt. assumption. assumption. apply not_Zeq. assumption. Qed. -Lemma absolu_2 : forall x : Z, x <> 0%Z -> Zabs_nat x <> 0. (*QF*) +Lemma absolu_2 : forall x : Z, x <> 0%Z -> Z.abs_nat x <> 0. (*QF*) Proof. intros. intro. @@ -1392,7 +1392,7 @@ Qed. -Lemma absolu_inject_nat : forall n : nat, Zabs_nat (Z_of_nat n) = n. +Lemma absolu_inject_nat : forall n : nat, Z.abs_nat (Z_of_nat n) = n. Proof. simple induction n; simpl in |- *. reflexivity. @@ -1404,7 +1404,7 @@ Qed. Lemma eq_inj : forall m n : nat, m = n :>Z -> m = n. Proof. intros. - generalize (f_equal Zabs_nat H). + generalize (f_equal Z.abs_nat H). intro. rewrite (absolu_inject_nat m) in H0. rewrite (absolu_inject_nat n) in H0. @@ -1438,7 +1438,7 @@ Qed. Lemma le_absolu : forall x y : Z, - (0 <= x)%Z -> (0 <= y)%Z -> (x <= y)%Z -> Zabs_nat x <= Zabs_nat y. + (0 <= x)%Z -> (0 <= y)%Z -> (x <= y)%Z -> Z.abs_nat x <= Z.abs_nat y. Proof. intros [| x| x] [| y| y] Hx Hy Hxy; apply le_O_n || @@ -1451,7 +1451,7 @@ Proof. | id1:(Zpos _ <= Zneg _)%Z |- _ => apply False_ind; apply id1; constructor end). - simpl in |- *. + simpl in |- *. apply le_inj. do 2 rewrite ZL9. assumption. @@ -1459,7 +1459,7 @@ Qed. Lemma lt_absolu : forall x y : Z, - (0 <= x)%Z -> (0 <= y)%Z -> (x < y)%Z -> Zabs_nat x < Zabs_nat y. + (0 <= x)%Z -> (0 <= y)%Z -> (x < y)%Z -> Z.abs_nat x < Z.abs_nat y. Proof. intros [| x| x] [| y| y] Hx Hy Hxy; inversion Hxy; try @@ -1470,13 +1470,13 @@ Proof. apply False_ind; apply id1; constructor | id1:(Zpos _ <= Zneg _)%Z |- _ => apply False_ind; apply id1; constructor - end; simpl in |- *; apply lt_inj; repeat rewrite ZL9; + end; simpl in |- *; apply lt_inj; repeat rewrite ZL9; assumption. Qed. Lemma absolu_plus : forall x y : Z, - (0 <= x)%Z -> (0 <= y)%Z -> Zabs_nat (x + y) = Zabs_nat x + Zabs_nat y. + (0 <= x)%Z -> (0 <= y)%Z -> Z.abs_nat (x + y) = Z.abs_nat x + Z.abs_nat y. Proof. intros [| x| x] [| y| y] Hx Hy; trivial; try @@ -1489,23 +1489,23 @@ Proof. apply False_ind; apply id1; constructor end. rewrite <- BinInt.Zpos_plus_distr. - unfold Zabs_nat in |- *. + unfold Z.abs_nat in |- *. apply nat_of_P_plus_morphism. Qed. Lemma pred_absolu : - forall x : Z, (0 < x)%Z -> pred (Zabs_nat x) = Zabs_nat (x - 1). + forall x : Z, (0 < x)%Z -> pred (Z.abs_nat x) = Z.abs_nat (x - 1). Proof. intros x Hx. generalize (Z_lt_lt_S_eq_dec 0 x Hx); simpl in |- *; intros [H1| H1]; - [ replace (Zabs_nat x) with (Zabs_nat (x - 1 + 1)); + [ replace (Z.abs_nat x) with (Z.abs_nat (x - 1 + 1)); [ idtac | apply f_equal with Z; auto with zarith ]; rewrite absolu_plus; - [ unfold Zabs_nat at 2, nat_of_P, Piter_op in |- *; omega + [ unfold Z.abs_nat at 2, nat_of_P, Pos.iter_op in |- *; omega | auto with zarith | intro; discriminate ] | rewrite <- H1; reflexivity ]. -Qed. +Qed. Definition pred_nat : forall (x : Z) (Hx : (0 < x)%Z), nat. intros [| px| px] Hx; try abstract (discriminate Hx). @@ -1535,7 +1535,7 @@ Proof. Qed. Lemma absolu_pred_nat : - forall (m : Z) (Hm : (0 < m)%Z), S (pred_nat m Hm) = Zabs_nat m. + forall (m : Z) (Hm : (0 < m)%Z), S (pred_nat m Hm) = Z.abs_nat m. Proof. intros [| px| px] Hx; try discriminate Hx. unfold pred_nat in |- *. @@ -1545,7 +1545,7 @@ Proof. Qed. Lemma pred_nat_absolu : - forall (m : Z) (Hm : (0 < m)%Z), pred_nat m Hm = Zabs_nat (m - 1). + forall (m : Z) (Hm : (0 < m)%Z), pred_nat m Hm = Z.abs_nat (m - 1). Proof. intros [| px| px] Hx; try discriminate Hx. unfold pred_nat in |- *. @@ -1557,15 +1557,15 @@ Lemma minus_pred_nat : S (pred_nat n Hn) - S (pred_nat m Hm) = S (pred_nat (n - m) Hnm). Proof. intros. - simpl in |- *. + simpl in |- *. destruct n; try discriminate Hn. destruct m; try discriminate Hm. unfold pred_nat at 1 2 in |- *. rewrite minus_pred; try apply lt_O_nat_of_P. apply eq_inj. - rewrite <- pred_nat_unfolded. + rewrite <- pred_nat_unfolded. rewrite Znat.inj_minus1. - repeat rewrite ZL9. + repeat rewrite ZL9. reflexivity. apply le_inj. apply Zlt_le_weak. @@ -1581,13 +1581,13 @@ Qed. Lemma Zsgn_1 : - forall x : Z, {Zsgn x = 0%Z} + {Zsgn x = 1%Z} + {Zsgn x = (-1)%Z}. (*QF*) + forall x : Z, {Z.sgn x = 0%Z} + {Z.sgn x = 1%Z} + {Z.sgn x = (-1)%Z}. (*QF*) Proof. intros. case x. left. left. - unfold Zsgn in |- *. + unfold Z.sgn in |- *. reflexivity. intro. simpl in |- *. @@ -1601,13 +1601,13 @@ Proof. Qed. -Lemma Zsgn_2 : forall x : Z, Zsgn x = 0%Z -> x = 0%Z. (*QF*) +Lemma Zsgn_2 : forall x : Z, Z.sgn x = 0%Z -> x = 0%Z. (*QF*) Proof. intros [| p1| p1]; simpl in |- *; intro H; constructor || discriminate H. Qed. -Lemma Zsgn_3 : forall x : Z, x <> 0%Z -> Zsgn x <> 0%Z. (*QF*) +Lemma Zsgn_3 : forall x : Z, x <> 0%Z -> Z.sgn x <> 0%Z. (*QF*) Proof. intro. case x. @@ -1626,21 +1626,21 @@ Qed. -Theorem Zsgn_4 : forall a : Z, a = (Zsgn a * Zabs_nat a)%Z. (*QF*) +Theorem Zsgn_4 : forall a : Z, a = (Z.sgn a * Z.abs_nat a)%Z. (*QF*) Proof. intro. case a. simpl in |- *. reflexivity. intro. - unfold Zsgn in |- *. - unfold Zabs_nat in |- *. + unfold Z.sgn in |- *. + unfold Z.abs_nat in |- *. rewrite Zmult_1_l. symmetry in |- *. apply ZL9. intros. - unfold Zsgn in |- *. - unfold Zabs_nat in |- *. + unfold Z.sgn in |- *. + unfold Z.abs_nat in |- *. rewrite ZL9. constructor. Qed. @@ -1650,7 +1650,7 @@ Theorem Zsgn_5 : forall a b x y : Z, x <> 0%Z -> y <> 0%Z -> - (Zsgn a * x)%Z = (Zsgn b * y)%Z -> (Zsgn a * y)%Z = (Zsgn b * x)%Z. (*QF*) + (Z.sgn a * x)%Z = (Z.sgn b * y)%Z -> (Z.sgn a * y)%Z = (Z.sgn b * x)%Z. (*QF*) Proof. intros a b x y H H0. case a. @@ -1660,7 +1660,7 @@ Proof. trivial. intro. - unfold Zsgn in |- *. + unfold Z.sgn in |- *. intro. rewrite Zmult_1_l in H1. simpl in H1. @@ -1669,11 +1669,11 @@ Proof. symmetry in |- *. assumption. intro. - unfold Zsgn in |- *. + unfold Z.sgn in |- *. intro. apply False_ind. apply H0. - apply Zopp_inj. + apply Z.opp_inj. simpl in |- *. transitivity (-1 * y)%Z. constructor. @@ -1683,13 +1683,13 @@ Proof. simpl in |- *. reflexivity. intro. - unfold Zsgn at 1 in |- *. - unfold Zsgn at 2 in |- *. + unfold Z.sgn at 1 in |- *. + unfold Z.sgn at 2 in |- *. intro. transitivity y. rewrite Zmult_1_l. reflexivity. - transitivity (Zsgn b * (Zsgn b * y))%Z. + transitivity (Z.sgn b * (Z.sgn b * y))%Z. case (Zsgn_1 b). intro. case s. @@ -1712,20 +1712,20 @@ Proof. rewrite H1. reflexivity. intro. - unfold Zsgn at 1 in |- *. - unfold Zsgn at 2 in |- *. + unfold Z.sgn at 1 in |- *. + unfold Z.sgn at 2 in |- *. intro. - transitivity (Zsgn b * (-1 * (Zsgn b * y)))%Z. + transitivity (Z.sgn b * (-1 * (Z.sgn b * y)))%Z. case (Zsgn_1 b). intros. case s. intro. apply False_ind. apply H. - apply Zopp_inj. + apply Z.opp_inj. transitivity (-1 * x)%Z. ring. - unfold Zopp in |- *. + unfold Z.opp in |- *. rewrite e in H1. transitivity (0 * y)%Z. assumption. @@ -1741,7 +1741,7 @@ Proof. ring. Qed. -Lemma Zsgn_6 : forall x : Z, x = 0%Z -> Zsgn x = 0%Z. +Lemma Zsgn_6 : forall x : Z, x = 0%Z -> Z.sgn x = 0%Z. Proof. intros. rewrite H. @@ -1750,44 +1750,44 @@ Proof. Qed. -Lemma Zsgn_7 : forall x : Z, (x > 0)%Z -> Zsgn x = 1%Z. +Lemma Zsgn_7 : forall x : Z, (x > 0)%Z -> Z.sgn x = 1%Z. Proof. intro. case x. intro. apply False_ind. - apply (Zlt_irrefl 0). + apply (Z.lt_irrefl 0). Flip. intros. simpl in |- *. reflexivity. intros. apply False_ind. - apply (Zlt_irrefl (Zneg p)). - apply Zlt_trans with 0%Z. + apply (Z.lt_irrefl (Zneg p)). + apply Z.lt_trans with 0%Z. constructor. Flip. Qed. -Lemma Zsgn_7' : forall x : Z, (0 < x)%Z -> Zsgn x = 1%Z. +Lemma Zsgn_7' : forall x : Z, (0 < x)%Z -> Z.sgn x = 1%Z. Proof. intros; apply Zsgn_7; Flip. Qed. -Lemma Zsgn_8 : forall x : Z, (x < 0)%Z -> Zsgn x = (-1)%Z. +Lemma Zsgn_8 : forall x : Z, (x < 0)%Z -> Z.sgn x = (-1)%Z. Proof. intro. case x. intro. apply False_ind. - apply (Zlt_irrefl 0). + apply (Z.lt_irrefl 0). assumption. intros. apply False_ind. - apply (Zlt_irrefl 0). - apply Zlt_trans with (Zpos p). + apply (Z.lt_irrefl 0). + apply Z.lt_trans with (Zpos p). constructor. assumption. intros. @@ -1795,7 +1795,7 @@ Proof. reflexivity. Qed. -Lemma Zsgn_9 : forall x : Z, Zsgn x = 1%Z -> (0 < x)%Z. +Lemma Zsgn_9 : forall x : Z, Z.sgn x = 1%Z -> (0 < x)%Z. Proof. intro. case x. @@ -1809,8 +1809,8 @@ Proof. apply False_ind. discriminate. Qed. - -Lemma Zsgn_10 : forall x : Z, Zsgn x = (-1)%Z -> (x < 0)%Z. + +Lemma Zsgn_10 : forall x : Z, Z.sgn x = (-1)%Z -> (x < 0)%Z. Proof. intro. case x. @@ -1822,9 +1822,9 @@ Proof. discriminate. intros. constructor. -Qed. +Qed. -Lemma Zsgn_11 : forall x : Z, (Zsgn x < 0)%Z -> (x < 0)%Z. +Lemma Zsgn_11 : forall x : Z, (Z.sgn x < 0)%Z -> (x < 0)%Z. Proof. intros. apply Zsgn_10. @@ -1833,7 +1833,7 @@ Proof. apply False_ind. case s. intro. - generalize (Zorder.Zlt_not_eq _ _ H). + generalize (Zorder.Zlt_not_eq _ _ H). intro. apply (H0 e). intro. @@ -1842,9 +1842,9 @@ Proof. intro. discriminate. trivial. -Qed. +Qed. -Lemma Zsgn_12 : forall x : Z, (0 < Zsgn x)%Z -> (0 < x)%Z. +Lemma Zsgn_12 : forall x : Z, (0 < Z.sgn x)%Z -> (0 < x)%Z. Proof. intros. apply Zsgn_9. @@ -1852,7 +1852,7 @@ Proof. intro. case s. intro. - generalize (Zorder.Zlt_not_eq _ _ H). + generalize (Zorder.Zlt_not_eq _ _ H). intro. generalize (sym_eq e). intro. @@ -1865,78 +1865,78 @@ Proof. intro. apply False_ind. discriminate. -Qed. +Qed. -Lemma Zsgn_13 : forall x : Z, (0 <= Zsgn x)%Z -> (0 <= x)%Z. +Lemma Zsgn_13 : forall x : Z, (0 <= Z.sgn x)%Z -> (0 <= x)%Z. Proof. - intros. - case (Z_le_lt_eq_dec 0 (Zsgn x) H). + intros. + case (Z_le_lt_eq_dec 0 (Z.sgn x) H). intro. apply Zlt_le_weak. apply Zsgn_12. - assumption. + assumption. intro. - assert (x = 0%Z). + assert (x = 0%Z). apply Zsgn_2. symmetry in |- *. assumption. rewrite H0. - apply Zle_refl. + apply Z.le_refl. Qed. -Lemma Zsgn_14 : forall x : Z, (Zsgn x <= 0)%Z -> (x <= 0)%Z. +Lemma Zsgn_14 : forall x : Z, (Z.sgn x <= 0)%Z -> (x <= 0)%Z. Proof. - intros. - case (Z_le_lt_eq_dec (Zsgn x) 0 H). + intros. + case (Z_le_lt_eq_dec (Z.sgn x) 0 H). intro. apply Zlt_le_weak. apply Zsgn_11. - assumption. + assumption. intro. - assert (x = 0%Z). + assert (x = 0%Z). apply Zsgn_2. assumption. rewrite H0. - apply Zle_refl. + apply Z.le_refl. Qed. -Lemma Zsgn_15 : forall x y : Z, Zsgn (x * y) = (Zsgn x * Zsgn y)%Z. +Lemma Zsgn_15 : forall x y : Z, Z.sgn (x * y) = (Z.sgn x * Z.sgn y)%Z. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; constructor. Qed. Lemma Zsgn_16 : forall x y : Z, - Zsgn (x * y) = 1%Z -> {(0 < x)%Z /\ (0 < y)%Z} + {(x < 0)%Z /\ (y < 0)%Z}. + Z.sgn (x * y) = 1%Z -> {(0 < x)%Z /\ (0 < y)%Z} + {(x < 0)%Z /\ (y < 0)%Z}. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intro H; try discriminate H; [ left | right ]; repeat split. -Qed. +Qed. Lemma Zsgn_17 : forall x y : Z, - Zsgn (x * y) = (-1)%Z -> {(0 < x)%Z /\ (y < 0)%Z} + {(x < 0)%Z /\ (0 < y)%Z}. + Z.sgn (x * y) = (-1)%Z -> {(0 < x)%Z /\ (y < 0)%Z} + {(x < 0)%Z /\ (0 < y)%Z}. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intro H; try discriminate H; [ left | right ]; repeat split. -Qed. +Qed. -Lemma Zsgn_18 : forall x y : Z, Zsgn (x * y) = 0%Z -> {x = 0%Z} + {y = 0%Z}. +Lemma Zsgn_18 : forall x y : Z, Z.sgn (x * y) = 0%Z -> {x = 0%Z} + {y = 0%Z}. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intro H; try discriminate H; [ left | right | right ]; constructor. -Qed. +Qed. -Lemma Zsgn_19 : forall x y : Z, (0 < Zsgn x + Zsgn y)%Z -> (0 < x + y)%Z. +Lemma Zsgn_19 : forall x y : Z, (0 < Z.sgn x + Z.sgn y)%Z -> (0 < x + y)%Z. Proof. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intro H; discriminate H || (constructor || apply Zsgn_12; assumption). Qed. -Lemma Zsgn_20 : forall x y : Z, (Zsgn x + Zsgn y < 0)%Z -> (x + y < 0)%Z. +Lemma Zsgn_20 : forall x y : Z, (Z.sgn x + Z.sgn y < 0)%Z -> (x + y < 0)%Z. Proof. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intro H; @@ -1944,43 +1944,43 @@ Proof. Qed. -Lemma Zsgn_21 : forall x y : Z, (0 < Zsgn x + Zsgn y)%Z -> (0 <= x)%Z. +Lemma Zsgn_21 : forall x y : Z, (0 < Z.sgn x + Z.sgn y)%Z -> (0 <= x)%Z. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intros H H0; discriminate H || discriminate H0. Qed. -Lemma Zsgn_22 : forall x y : Z, (Zsgn x + Zsgn y < 0)%Z -> (x <= 0)%Z. +Lemma Zsgn_22 : forall x y : Z, (Z.sgn x + Z.sgn y < 0)%Z -> (x <= 0)%Z. Proof. Proof. intros [|p1|p1]; [intros y|intros [|p2|p2] ..]; simpl in |- *; intros H H0; discriminate H || discriminate H0. Qed. -Lemma Zsgn_23 : forall x y : Z, (0 < Zsgn x + Zsgn y)%Z -> (0 <= y)%Z. +Lemma Zsgn_23 : forall x y : Z, (0 < Z.sgn x + Z.sgn y)%Z -> (0 <= y)%Z. Proof. intros [|p1|p1] [|p2|p2]; simpl in |- *; intros H H0; discriminate H || discriminate H0. Qed. -Lemma Zsgn_24 : forall x y : Z, (Zsgn x + Zsgn y < 0)%Z -> (y <= 0)%Z. +Lemma Zsgn_24 : forall x y : Z, (Z.sgn x + Z.sgn y < 0)%Z -> (y <= 0)%Z. Proof. intros [|p1|p1] [|p2|p2]; simpl in |- *; intros H H0; discriminate H || discriminate H0. Qed. -Lemma Zsgn_25 : forall x : Z, Zsgn (- x) = (- Zsgn x)%Z. +Lemma Zsgn_25 : forall x : Z, Z.sgn (- x) = (- Z.sgn x)%Z. Proof. intros [| p1| p1]; simpl in |- *; reflexivity. Qed. -Lemma Zsgn_26 : forall x : Z, (0 < x)%Z -> (0 < Zsgn x)%Z. +Lemma Zsgn_26 : forall x : Z, (0 < x)%Z -> (0 < Z.sgn x)%Z. Proof. intros [| p| p] Hp; trivial. Qed. -Lemma Zsgn_27 : forall x : Z, (x < 0)%Z -> (Zsgn x < 0)%Z. +Lemma Zsgn_27 : forall x : Z, (x < 0)%Z -> (Z.sgn x < 0)%Z. Proof. intros [| p| p] Hp; trivial. Qed. @@ -1994,7 +1994,7 @@ Hint Resolve Zsgn_1 Zsgn_2 Zsgn_3 Zsgn_4 Zsgn_5 Zsgn_6 Zsgn_7 Zsgn_7' Zsgn_8 (** Properties of Zabs *) (*###########################################################################*) -Lemma Zabs_1 : forall z p : Z, (Zabs z < p)%Z -> (z < p)%Z /\ (- p < z)%Z. +Lemma Zabs_1 : forall z p : Z, (Z.abs z < p)%Z -> (z < p)%Z /\ (- p < z)%Z. Proof. intros z p. case z. @@ -2003,25 +2003,25 @@ Proof. split. assumption. apply Zgt_mult_conv_absorb_l with (a := (-1)%Z). - replace (-1)%Z with (Zpred 0). + replace (-1)%Z with (Z.pred 0). apply Zlt_pred. simpl; trivial. ring_simplify (-1 * - p)%Z (-1 * 0)%Z. - apply Zlt_gt. + apply Z.lt_gt. assumption. intros. simpl in H. split. assumption. - apply Zlt_trans with (m := 0%Z). + apply Z.lt_trans with (m := 0%Z). apply Zgt_mult_conv_absorb_l with (a := (-1)%Z). - replace (-1)%Z with (Zpred 0). + replace (-1)%Z with (Z.pred 0). apply Zlt_pred. simpl; trivial. ring_simplify (-1 * - p)%Z (-1 * 0)%Z. - apply Zlt_gt. - apply Zlt_trans with (m := Zpos p0). + apply Z.lt_gt. + apply Z.lt_trans with (m := Zpos p0). constructor. assumption. constructor. @@ -2029,28 +2029,28 @@ Proof. intros. simpl in H. split. - apply Zlt_trans with (m := Zpos p0). + apply Z.lt_trans with (m := Zpos p0). constructor. assumption. - + apply Zgt_mult_conv_absorb_l with (a := (-1)%Z). - replace (-1)%Z with (Zpred 0). + replace (-1)%Z with (Z.pred 0). apply Zlt_pred. simpl;trivial. ring_simplify (-1 * - p)%Z. replace (-1 * Zneg p0)%Z with (- Zneg p0)%Z. - replace (- Zneg p0)%Z with (Zpos p0). - apply Zlt_gt. + replace (- Zneg p0)%Z with (Zpos p0). + apply Z.lt_gt. assumption. symmetry in |- *. apply Zopp_neg. - rewrite Zopp_mult_distr_l_reverse with (n := 1%Z). + rewrite Zopp_mult_distr_l_reverse with (n := 1%Z). simpl in |- *. constructor. Qed. -Lemma Zabs_2 : forall z p : Z, (Zabs z > p)%Z -> (z > p)%Z \/ (- p > z)%Z. +Lemma Zabs_2 : forall z p : Z, (Z.abs z > p)%Z -> (z > p)%Z \/ (- p > z)%Z. Proof. intros z p. case z. @@ -2067,7 +2067,7 @@ Proof. intros. simpl in H. right. - apply Zlt_gt. + apply Z.lt_gt. apply Zgt_mult_conv_absorb_l with (a := (-1)%Z). constructor. ring_simplify (-1 * - p)%Z. @@ -2076,22 +2076,22 @@ Proof. reflexivity. Qed. -Lemma Zabs_3 : forall z p : Z, (z < p)%Z /\ (- p < z)%Z -> (Zabs z < p)%Z. +Lemma Zabs_3 : forall z p : Z, (z < p)%Z /\ (- p < z)%Z -> (Z.abs z < p)%Z. Proof. intros z p. case z. - intro. + intro. simpl in |- *. elim H. intros. assumption. - + intros. elim H. intros. simpl in |- *. assumption. - + intros. elim H. intros. @@ -2100,14 +2100,14 @@ Proof. constructor. replace (-1 * Zpos p0)%Z with (Zneg p0). replace (-1 * p)%Z with (- p)%Z. - apply Zlt_gt. + apply Z.lt_gt. assumption. - ring. + ring. simpl in |- *. reflexivity. Qed. -Lemma Zabs_4 : forall z p : Z, (Zabs z < p)%Z -> (- p < z < p)%Z. +Lemma Zabs_4 : forall z p : Z, (Z.abs z < p)%Z -> (- p < z < p)%Z. Proof. intros. split. @@ -2118,28 +2118,28 @@ Proof. apply Zabs_1. assumption. Qed. - -Lemma Zabs_5 : forall z p : Z, (Zabs z <= p)%Z -> (- p <= z <= p)%Z. + +Lemma Zabs_5 : forall z p : Z, (Z.abs z <= p)%Z -> (- p <= z <= p)%Z. Proof. intros. split. - replace (- p)%Z with (Zsucc (- Zsucc p)). + replace (- p)%Z with (Z.succ (- Z.succ p)). apply Zlt_le_succ. - apply proj2 with (A := (z < Zsucc p)%Z). + apply proj2 with (A := (z < Z.succ p)%Z). apply Zabs_1. apply Zle_lt_succ. assumption. - unfold Zsucc in |- *. + unfold Z.succ in |- *. ring. apply Zlt_succ_le. - apply proj1 with (B := (- Zsucc p < z)%Z). + apply proj1 with (B := (- Z.succ p < z)%Z). apply Zabs_1. apply Zle_lt_succ. assumption. Qed. -Lemma Zabs_6 : forall z p : Z, (Zabs z <= p)%Z -> (z <= p)%Z. +Lemma Zabs_6 : forall z p : Z, (Z.abs z <= p)%Z -> (z <= p)%Z. Proof. intros. apply proj2 with (A := (- p <= z)%Z). @@ -2147,7 +2147,7 @@ Proof. assumption. Qed. -Lemma Zabs_7 : forall z p : Z, (Zabs z <= p)%Z -> (- p <= z)%Z. +Lemma Zabs_7 : forall z p : Z, (Z.abs z <= p)%Z -> (- p <= z)%Z. Proof. intros. apply proj1 with (B := (z <= p)%Z). @@ -2155,7 +2155,7 @@ Proof. assumption. Qed. -Lemma Zabs_8 : forall z p : Z, (- p <= z <= p)%Z -> (Zabs z <= p)%Z. +Lemma Zabs_8 : forall z p : Z, (- p <= z <= p)%Z -> (Z.abs z <= p)%Z. Proof. intros. apply Zlt_succ_le. @@ -2165,14 +2165,14 @@ Proof. split. apply Zle_lt_succ. assumption. - apply Zlt_le_trans with (m := (- p)%Z). - apply Zgt_lt. + apply Z.lt_le_trans with (m := (- p)%Z). + apply Z.gt_lt. apply Zlt_opp. apply Zlt_succ. assumption. Qed. -Lemma Zabs_min : forall z : Z, Zabs z = Zabs (- z). +Lemma Zabs_min : forall z : Z, Z.abs z = Z.abs (- z). Proof. intro. case z. @@ -2187,67 +2187,67 @@ Proof. Qed. Lemma Zabs_9 : - forall z p : Z, (0 <= p)%Z -> (p < z)%Z \/ (z < - p)%Z -> (p < Zabs z)%Z. + forall z p : Z, (0 <= p)%Z -> (p < z)%Z \/ (z < - p)%Z -> (p < Z.abs z)%Z. Proof. intros. case H0. intro. - replace (Zabs z) with z. + replace (Z.abs z) with z. assumption. symmetry in |- *. - apply Zabs_eq. + apply Z.abs_eq. apply Zlt_le_weak. - apply Zle_lt_trans with (m := p). + apply Z.le_lt_trans with (m := p). assumption. assumption. intro. - cut (Zabs z = (- z)%Z). + cut (Z.abs z = (- z)%Z). intro. rewrite H2. apply Zmin_cancel_Zlt. ring_simplify (- - z)%Z. assumption. rewrite Zabs_min. - apply Zabs_eq. + apply Z.abs_eq. apply Zlt_le_weak. - apply Zle_lt_trans with (m := p). + apply Z.le_lt_trans with (m := p). assumption. apply Zmin_cancel_Zlt. ring_simplify (- - z)%Z. assumption. Qed. -Lemma Zabs_10 : forall z : Z, (0 <= Zabs z)%Z. +Lemma Zabs_10 : forall z : Z, (0 <= Z.abs z)%Z. Proof. intro. case (Z_zerop z). intro. rewrite e. simpl in |- *. - apply Zle_refl. + apply Z.le_refl. intro. case (not_Zeq z 0 n). intro. apply Zlt_le_weak. apply Zabs_9. - apply Zle_refl. + apply Z.le_refl. simpl in |- *. right. assumption. intro. apply Zlt_le_weak. apply Zabs_9. - apply Zle_refl. + apply Z.le_refl. simpl in |- *. left. assumption. Qed. -Lemma Zabs_11 : forall z : Z, z <> 0%Z -> (0 < Zabs z)%Z. +Lemma Zabs_11 : forall z : Z, z <> 0%Z -> (0 < Z.abs z)%Z. Proof. intros. apply Zabs_9. - apply Zle_refl. + apply Z.le_refl. simpl in |- *. apply not_Zeq. intro. @@ -2256,14 +2256,14 @@ Proof. assumption. Qed. -Lemma Zabs_12 : forall z m : Z, (m < Zabs z)%Z -> {(m < z)%Z} + {(z < - m)%Z}. +Lemma Zabs_12 : forall z m : Z, (m < Z.abs z)%Z -> {(m < z)%Z} + {(z < - m)%Z}. Proof. intros [| p| p] m; simpl in |- *; intros H; - [ left | left | right; apply Zmin_cancel_Zlt; rewrite Zopp_involutive ]; + [ left | left | right; apply Zmin_cancel_Zlt; rewrite Z.opp_involutive ]; assumption. Qed. -Lemma Zabs_mult : forall z p : Z, Zabs (z * p) = (Zabs z * Zabs p)%Z. +Lemma Zabs_mult : forall z p : Z, Z.abs (z * p) = (Z.abs z * Z.abs p)%Z. Proof. intros. case z. @@ -2290,22 +2290,22 @@ Proof. reflexivity. Qed. -Lemma Zabs_plus : forall z p : Z, (Zabs (z + p) <= Zabs z + Zabs p)%Z. +Lemma Zabs_plus : forall z p : Z, (Z.abs (z + p) <= Z.abs z + Z.abs p)%Z. Proof. intros. case z. simpl in |- *. - apply Zle_refl. + apply Z.le_refl. case p. intro. simpl in |- *. - apply Zle_refl. + apply Z.le_refl. intros. simpl in |- *. - apply Zle_refl. + apply Z.le_refl. intros. - unfold Zabs at 2 in |- *. - unfold Zabs at 2 in |- *. + unfold Z.abs at 2 in |- *. + unfold Z.abs at 2 in |- *. apply Zabs_8. split. apply Zplus_le_reg_l with (Zpos p1 - Zneg p0)%Z. @@ -2322,17 +2322,17 @@ Proof. ring. ring. apply Zplus_le_compat. - apply Zle_refl. + apply Z.le_refl. apply Zlt_le_weak. constructor. - + case p. simpl in |- *. intro. - apply Zle_refl. + apply Z.le_refl. intros. - unfold Zabs at 2 in |- *. - unfold Zabs at 2 in |- *. + unfold Z.abs at 2 in |- *. + unfold Z.abs at 2 in |- *. apply Zabs_8. split. apply Zplus_le_reg_l with (Zpos p1 + Zneg p0)%Z. @@ -2360,13 +2360,13 @@ Proof. apply Zplus_le_compat. apply Zlt_le_weak. constructor. - apply Zle_refl. + apply Z.le_refl. intros. simpl in |- *. - apply Zle_refl. + apply Z.le_refl. Qed. -Lemma Zabs_neg : forall z : Z, (z <= 0)%Z -> Zabs z = (- z)%Z. +Lemma Zabs_neg : forall z : Z, (z <= 0)%Z -> Z.abs z = (- z)%Z. Proof. intro. case z. @@ -2383,11 +2383,11 @@ Proof. reflexivity. Qed. -Lemma Zle_Zabs: forall z, (z <= Zabs z)%Z. +Lemma Zle_Zabs: forall z, (z <= Z.abs z)%Z. Proof. - intros [|z|z]; simpl; auto with zarith; apply Zle_neg_pos. + intros [|z|z]; simpl; auto with zarith; apply Zle_neg_pos. Qed. - + Hint Resolve Zabs_1 Zabs_2 Zabs_3 Zabs_4 Zabs_5 Zabs_6 Zabs_7 Zabs_8 Zabs_9 Zabs_10 Zabs_11 Zabs_12 Zabs_min Zabs_neg Zabs_mult Zabs_plus Zle_Zabs: zarith. @@ -2400,7 +2400,7 @@ Lemma Zind : forall (P : Z -> Prop) (p : Z), P p -> (forall q : Z, (p <= q)%Z -> P q -> P (q + 1)%Z) -> - forall q : Z, (p <= q)%Z -> P q. + forall q : Z, (p <= q)%Z -> P q. Proof. intros P p. intro. @@ -2426,14 +2426,14 @@ Proof. replace (p + Z_of_nat (S k))%Z with (p + k + 1)%Z. apply H0. apply Zplus_le_reg_l with (p := (- p)%Z). - replace (- p + p)%Z with (Z_of_nat 0). + replace (- p + p)%Z with (Z_of_nat 0). ring_simplify (- p + (p + Z_of_nat k))%Z. apply Znat.inj_le. apply le_O_n. - ring_simplify; auto with arith. + ring_simplify; auto with arith. assumption. rewrite (Znat.inj_S k). - unfold Zsucc in |- *. + unfold Z.succ in |- *. ring. intros. cut (exists k : nat, (q - p)%Z = Z_of_nat k). @@ -2457,7 +2457,7 @@ Lemma Zrec : forall (P : Z -> Set) (p : Z), P p -> (forall q : Z, (p <= q)%Z -> P q -> P (q + 1)%Z) -> - forall q : Z, (p <= q)%Z -> P q. + forall q : Z, (p <= q)%Z -> P q. Proof. intros F p. intro. @@ -2483,7 +2483,7 @@ Proof. replace (p + Z_of_nat (S k))%Z with (p + k + 1)%Z. apply H0. apply Zplus_le_reg_l with (p := (- p)%Z). - replace (- p + p)%Z with (Z_of_nat 0). + replace (- p + p)%Z with (Z_of_nat 0). replace (- p + (p + Z_of_nat k))%Z with (Z_of_nat k). apply Znat.inj_le. apply le_O_n. @@ -2491,7 +2491,7 @@ Proof. rewrite Zplus_opp_l; reflexivity. assumption. rewrite (Znat.inj_S k). - unfold Zsucc in |- *. + unfold Z.succ in |- *. apply Zplus_assoc_reverse. intros. cut {k : nat | (q - p)%Z = Z_of_nat k}. @@ -2540,14 +2540,14 @@ Proof. replace (p - 0)%Z with p. assumption. unfold Zminus in |- *. - unfold Zopp in |- *. + unfold Z.opp in |- *. rewrite Zplus_0_r; reflexivity. replace (p - Z_of_nat (S k))%Z with (p - k - 1)%Z. apply H0. apply Zplus_le_reg_l with (p := (- p)%Z). - replace (- p + p)%Z with (- Z_of_nat 0)%Z. + replace (- p + p)%Z with (- Z_of_nat 0)%Z. replace (- p + (p - Z_of_nat k))%Z with (- Z_of_nat k)%Z. - apply Zge_le. + apply Z.ge_le. apply Zge_opp. apply Znat.inj_le. apply le_O_n. @@ -2555,7 +2555,7 @@ Proof. rewrite Zplus_opp_l; reflexivity. assumption. rewrite (Znat.inj_S k). - unfold Zsucc in |- *. + unfold Z.succ in |- *. unfold Zminus at 1 2 in |- *. rewrite Zplus_assoc_reverse. rewrite <- Zopp_plus_distr. @@ -2567,16 +2567,16 @@ Proof. intro k. intros. exists k. - apply Zopp_inj. + apply Z.opp_inj. apply Zplus_reg_l with (n := p). - replace (p + - (p - Z_of_nat k))%Z with (Z_of_nat k). + replace (p + - (p - Z_of_nat k))%Z with (Z_of_nat k). rewrite <- e. reflexivity. unfold Zminus in |- *. rewrite Zopp_plus_distr. rewrite Zplus_assoc. rewrite Zplus_opp_r. - rewrite Zopp_involutive. + rewrite Z.opp_involutive. reflexivity. apply Z_of_nat_complete_inf. unfold Zminus in |- *. @@ -2615,17 +2615,17 @@ Proof. replace (p - Z_of_nat (S k))%Z with (p - k - 1)%Z. apply H0. apply Zplus_le_reg_l with (p := (- p)%Z). - replace (- p + p)%Z with (- Z_of_nat 0)%Z. + replace (- p + p)%Z with (- Z_of_nat 0)%Z. replace (- p + (p - Z_of_nat k))%Z with (- Z_of_nat k)%Z. - apply Zge_le. + apply Z.ge_le. apply Zge_opp. apply Znat.inj_le. apply le_O_n. - ring. + ring. ring_simplify; auto with arith. assumption. rewrite (Znat.inj_S k). - unfold Zsucc in |- *. + unfold Z.succ in |- *. ring. intros. cut (exists k : nat, (p - q)%Z = Z_of_nat k). @@ -2634,9 +2634,9 @@ Proof. intro k. intros. exists k. - apply Zopp_inj. + apply Z.opp_inj. apply Zplus_reg_l with (n := p). - replace (p + - (p - Z_of_nat k))%Z with (Z_of_nat k). + replace (p + - (p - Z_of_nat k))%Z with (Z_of_nat k). rewrite <- H3. ring. ring. @@ -2654,44 +2654,44 @@ Proof. intros P p WF_ind_step q Hq. cut (forall x : Z, (p <= x)%Z -> forall y : Z, (p <= y < x)%Z -> P y). intro. - apply (H (Zsucc q)). + apply (H (Z.succ q)). apply Zle_le_succ. assumption. - + split; [ assumption | exact (Zlt_succ q) ]. - intros x0 Hx0; generalize Hx0; pattern x0 in |- *. + intros x0 Hx0; generalize Hx0; pattern x0 in |- *. apply Zrec with (p := p). intros. absurd (p <= p)%Z. apply Zgt_not_le. apply Zgt_le_trans with (m := y). - apply Zlt_gt. + apply Z.lt_gt. elim H. intros. assumption. elim H. intros. assumption. - apply Zle_refl. + apply Z.le_refl. - intros. - apply WF_ind_step. + intros. + apply WF_ind_step. intros. apply (H0 H). - split. + split. elim H2. intros. assumption. - apply Zlt_le_trans with y. + apply Z.lt_le_trans with y. elim H2. intros. assumption. - apply Zgt_succ_le. - apply Zlt_gt. + apply Zgt_succ_le. + apply Z.lt_gt. elim H1. intros. - unfold Zsucc in |- *. + unfold Z.succ in |- *. assumption. assumption. Qed. @@ -2744,44 +2744,44 @@ Proof. intros P p WF_ind_step q Hq. cut (forall x : Z, (p <= x)%Z -> forall y : Z, (p <= y < x)%Z -> P y). intro. - apply (H (Zsucc q)). + apply (H (Z.succ q)). apply Zle_le_succ. assumption. - + split; [ assumption | exact (Zlt_succ q) ]. - intros x0 Hx0; generalize Hx0; pattern x0 in |- *. + intros x0 Hx0; generalize Hx0; pattern x0 in |- *. apply Zind with (p := p). intros. absurd (p <= p)%Z. apply Zgt_not_le. apply Zgt_le_trans with (m := y). - apply Zlt_gt. + apply Z.lt_gt. elim H. intros. assumption. elim H. intros. assumption. - apply Zle_refl. + apply Z.le_refl. - intros. - apply WF_ind_step. + intros. + apply WF_ind_step. intros. apply (H0 H). - split. + split. elim H2. intros. assumption. - apply Zlt_le_trans with y. + apply Z.lt_le_trans with y. elim H2. intros. assumption. - apply Zgt_succ_le. - apply Zlt_gt. + apply Zgt_succ_le. + apply Z.lt_gt. elim H1. intros. - unfold Zsucc in |- *. + unfold Z.succ in |- *. assumption. assumption. Qed. @@ -2830,16 +2830,16 @@ Qed. (** Properties of Zmax *) (*###########################################################################*) -Definition Zmax (n m : Z) := (n + m - Zmin n m)%Z. +Definition Zmax (n m : Z) := (n + m - Z.min n m)%Z. Lemma ZmaxSS : forall n m : Z, (Zmax n m + 1)%Z = Zmax (n + 1) (m + 1). Proof. intros. unfold Zmax in |- *. - replace (Zmin (n + 1) (m + 1)) with (Zmin n m + 1)%Z. + replace (Z.min (n + 1) (m + 1)) with (Z.min n m + 1)%Z. ring. symmetry in |- *. - change (Zmin (Zsucc n) (Zsucc m) = Zsucc (Zmin n m)) in |- *. + change (Z.min (Z.succ n) (Z.succ m) = Z.succ (Z.min n m)) in |- *. symmetry in |- *. apply Zmin_SS. Qed. @@ -2848,29 +2848,29 @@ Lemma Zle_max_l : forall n m : Z, (n <= Zmax n m)%Z. Proof. intros. unfold Zmax in |- *. - apply Zplus_le_reg_l with (p := (- n + Zmin n m)%Z). - ring_simplify (- n + Zmin n m + n)%Z. - ring_simplify (- n + Zmin n m + (n + m - Zmin n m))%Z. - apply Zle_min_r. + apply Zplus_le_reg_l with (p := (- n + Z.min n m)%Z). + ring_simplify (- n + Z.min n m + n)%Z. + ring_simplify (- n + Z.min n m + (n + m - Z.min n m))%Z. + apply Z.le_min_r. Qed. Lemma Zle_max_r : forall n m : Z, (m <= Zmax n m)%Z. Proof. intros. unfold Zmax in |- *. - apply Zplus_le_reg_l with (p := (- m + Zmin n m)%Z). - ring_simplify (- m + Zmin n m + m)%Z. - ring_simplify (- m + Zmin n m + (n + m - Zmin n m))%Z. - apply Zle_min_l. + apply Zplus_le_reg_l with (p := (- m + Z.min n m)%Z). + ring_simplify (- m + Z.min n m + m)%Z. + ring_simplify (- m + Z.min n m + (n + m - Z.min n m))%Z. + apply Z.le_min_l. Qed. -Lemma Zmin_or_informative : forall n m : Z, {Zmin n m = n} + {Zmin n m = m}. +Lemma Zmin_or_informative : forall n m : Z, {Z.min n m = n} + {Z.min n m = m}. Proof. intros. case (Z_lt_ge_dec n m). - unfold Zmin in |- *. - unfold Zlt in |- *. + unfold Z.min in |- *. + unfold Z.lt in |- *. intro z. rewrite z. left. @@ -2880,8 +2880,8 @@ Proof. intro. case H. intros z0. - unfold Zmin in |- *. - unfold Zgt in z0. + unfold Z.min in |- *. + unfold Z.gt in z0. rewrite z0. right. reflexivity. @@ -2894,14 +2894,14 @@ Proof. elim H. intro. left. - apply Zlt_gt. + apply Z.lt_gt. assumption. intro. right. symmetry in |- *. assumption. - apply Z_le_lt_eq_dec. - apply Zge_le. + apply Z_le_lt_eq_dec. + apply Z.ge_le. assumption. Qed. @@ -2925,8 +2925,8 @@ Proof. assumption. ring. Qed. - -Lemma Zmax_or_informative : forall n m : Z, {Zmax n m = n} + {Zmax n m = m}. + +Lemma Zmax_or_informative : forall n m : Z, {Zmax n m = n} + {Zmax n m = m}. Proof. intros. unfold Zmax in |- *. @@ -2960,12 +2960,12 @@ Proof. exact Zeven.Zeven_Sn. Qed. -Lemma Zeven_pred : forall x : Z, Zeven.Zodd x -> Zeven.Zeven (x - 1). +Lemma Zeven_pred : forall x : Z, Zeven.Zodd x -> Zeven.Zeven (x - 1). Proof. exact Zeven.Zeven_pred. Qed. -(* This lemma used to be useful since it was mentioned with an unnecessary premise +(* This lemma used to be useful since it was mentioned with an unnecessary premise `x>=0` as Z_modulo_2 in ZArith, but the ZArith version has been fixed. *) Definition Z_modulo_2_always : @@ -2987,10 +2987,10 @@ Proof. Qed. Lemma Z_div_le : - forall a b c : Z, (0 < c)%Z -> (b <= a)%Z -> (b / c <= a / c)%Z. + forall a b c : Z, (0 < c)%Z -> (b <= a)%Z -> (b / c <= a / c)%Z. Proof. intros. - apply Zge_le. + apply Z.ge_le. apply Z_div_ge; Flip; assumption. Qed. @@ -2998,7 +2998,7 @@ Lemma Z_div_nonneg : forall a b : Z, (0 < b)%Z -> (0 <= a)%Z -> (0 <= a / b)%Z. Proof. intros. - apply Zge_le. + apply Z.ge_le. apply Z_div_ge0; Flip; assumption. Qed. @@ -3012,7 +3012,7 @@ Proof. intro. apply (Zlt_not_le (b * (a / b) + a mod b) 0 H0). apply Zplus_le_0_compat. - apply Zmult_le_0_compat. + apply Zmult_le_0_compat. apply Zlt_le_weak; assumption. Flip. assumption. diff --git a/test-suite/success/Case11.v b/test-suite/success/Case11.v index 445ffac8cb..fbe909ec41 100644 --- a/test-suite/success/Case11.v +++ b/test-suite/success/Case11.v @@ -5,9 +5,9 @@ Section A. Variables (Alpha : Set) (Beta : Set). -Definition nodep_prod_of_dep (c : sigS (fun a : Alpha => Beta)) : +Definition nodep_prod_of_dep (c : sigT (fun a : Alpha => Beta)) : Alpha * Beta := match c with - | existS _ a b => (a, b) + | existT _ a b => (a, b) end. End A. diff --git a/test-suite/success/Case17.v b/test-suite/success/Case17.v index 861d04668f..a4efcca945 100644 --- a/test-suite/success/Case17.v +++ b/test-suite/success/Case17.v @@ -1,5 +1,5 @@ (* Check the synthesis of predicate from a cast in case of matching of - the first component (here [list bool]) of a dependent type (here [sigS]) + the first component (here [list bool]) of a dependent type (here [sigT]) (Simplification of an example from file parsing2.v of the Coq'Art exercises) *) @@ -19,10 +19,10 @@ Axiom HHH : forall A : Prop, A. Check (match rec l0 (HHH _) with - | inleft (existS _ (false :: l1) _) => inright _ (HHH _) - | inleft (existS _ (true :: l1) (exist _ t1 (conj Hp Hl))) => + | inleft (existT _ (false :: l1) _) => inright _ (HHH _) + | inleft (existT _ (true :: l1) (exist _ t1 (conj Hp Hl))) => inright _ (HHH _) - | inleft (existS _ _ _) => inright _ (HHH _) + | inleft (existT _ _ _) => inright _ (HHH _) | inright Hnp => inright _ (HHH _) end :{l'' : list bool & @@ -39,10 +39,10 @@ Check {t : nat | parse_rel l' l'' t /\ length l'' <= length l'}} + {(forall (l'' : list bool) (t : nat), ~ parse_rel l' l'' t)}) => match rec l0 (HHH _) with - | inleft (existS _ (false :: l1) _) => inright _ (HHH _) - | inleft (existS _ (true :: l1) (exist _ t1 (conj Hp Hl))) => + | inleft (existT _ (false :: l1) _) => inright _ (HHH _) + | inleft (existT _ (true :: l1) (exist _ t1 (conj Hp Hl))) => inright _ (HHH _) - | inleft (existS _ _ _) => inright _ (HHH _) + | inleft (existT _ _ _) => inright _ (HHH _) | inright Hnp => inright _ (HHH _) end :{l'' : list bool & diff --git a/test-suite/success/CombinedScheme.v b/test-suite/success/CombinedScheme.v new file mode 100644 index 0000000000..d6ca7a299f --- /dev/null +++ b/test-suite/success/CombinedScheme.v @@ -0,0 +1,35 @@ +Inductive even (x : bool) : nat -> Type := +| evenO : even x 0 +| evenS : forall n, odd x n -> even x (S n) +with odd (x : bool) : nat -> Type := +| oddS : forall n, even x n -> odd x (S n). + +Scheme even_ind_prop := Induction for even Sort Prop +with odd_ind_prop := Induction for odd Sort Prop. + +Combined Scheme even_cprop from even_ind_prop, odd_ind_prop. + +Check even_cprop : + forall (x : bool) (P : forall n : nat, even x n -> Prop) + (P0 : forall n : nat, odd x n -> Prop), + P 0 (evenO x) -> + (forall (n : nat) (o : odd x n), P0 n o -> P (S n) (evenS x n o)) -> + (forall (n : nat) (e : even x n), P n e -> P0 (S n) (oddS x n e)) -> + (forall (n : nat) (e : even x n), P n e) /\ + (forall (n : nat) (o : odd x n), P0 n o). + +Scheme even_ind_type := Induction for even Sort Type +with odd_ind_type := Induction for odd Sort Type. + +(* This didn't work in v8.7 *) + +Combined Scheme even_ctype from even_ind_type, odd_ind_type. + +Check even_ctype : + forall (x : bool) (P : forall n : nat, even x n -> Prop) + (P0 : forall n : nat, odd x n -> Prop), + P 0 (evenO x) -> + (forall (n : nat) (o : odd x n), P0 n o -> P (S n) (evenS x n o)) -> + (forall (n : nat) (e : even x n), P n e -> P0 (S n) (oddS x n e)) -> + (forall (n : nat) (e : even x n), P n e) * + (forall (n : nat) (o : odd x n), P0 n o). diff --git a/test-suite/success/CompatCurrentFlag.v b/test-suite/success/CompatCurrentFlag.v index 288c9d1da0..5650dba236 100644 --- a/test-suite/success/CompatCurrentFlag.v +++ b/test-suite/success/CompatCurrentFlag.v @@ -1,3 +1,3 @@ -(* -*- coq-prog-args: ("-compat" "8.8") -*- *) +(* -*- coq-prog-args: ("-compat" "8.9") -*- *) (** Check that the current compatibility flag actually requires the relevant modules. *) -Import Coq.Compat.Coq88. +Import Coq.Compat.Coq89. diff --git a/test-suite/success/CompatOldFlag.v b/test-suite/success/CompatOldFlag.v index b7bbc505b4..37d50ee67d 100644 --- a/test-suite/success/CompatOldFlag.v +++ b/test-suite/success/CompatOldFlag.v @@ -1,5 +1,5 @@ -(* -*- coq-prog-args: ("-compat" "8.6") -*- *) +(* -*- coq-prog-args: ("-compat" "8.7") -*- *) (** Check that the current-minus-two compatibility flag actually requires the relevant modules. *) +Import Coq.Compat.Coq89. Import Coq.Compat.Coq88. Import Coq.Compat.Coq87. -Import Coq.Compat.Coq86. diff --git a/test-suite/success/CompatPreviousFlag.v b/test-suite/success/CompatPreviousFlag.v index 9cfe60390f..9981388381 100644 --- a/test-suite/success/CompatPreviousFlag.v +++ b/test-suite/success/CompatPreviousFlag.v @@ -1,4 +1,4 @@ -(* -*- coq-prog-args: ("-compat" "8.7") -*- *) +(* -*- coq-prog-args: ("-compat" "8.8") -*- *) (** Check that the current-minus-one compatibility flag actually requires the relevant modules. *) +Import Coq.Compat.Coq89. Import Coq.Compat.Coq88. -Import Coq.Compat.Coq87. diff --git a/test-suite/success/FunindExtraction_compat86.v b/test-suite/success/FunindExtraction_compat86.v deleted file mode 100644 index 8912197d2f..0000000000 --- a/test-suite/success/FunindExtraction_compat86.v +++ /dev/null @@ -1,506 +0,0 @@ -(* -*- coq-prog-args: ("-compat" "8.6") -*- *) - -Definition iszero (n : nat) : bool := - match n with - | O => true - | _ => false - end. - -Functional Scheme iszero_ind := Induction for iszero Sort Prop. - -Lemma toto : forall n : nat, n = 0 -> iszero n = true. -intros x eg. - functional induction iszero x; simpl. -trivial. -inversion eg. -Qed. - - -Function ftest (n m : nat) : nat := - match n with - | O => match m with - | O => 0 - | _ => 1 - end - | S p => 0 - end. -(* MS: FIXME: apparently can't define R_ftest_complete. Rest of the file goes through. *) - -Lemma test1 : forall n m : nat, ftest n m <= 2. -intros n m. - functional induction ftest n m; auto. -Qed. - -Lemma test2 : forall m n, ~ 2 = ftest n m. -Proof. -intros n m;intro H. -functional inversion H ftest. -Qed. - -Lemma test3 : forall n m, ftest n m = 0 -> (n = 0 /\ m = 0) \/ n <> 0. -Proof. -functional inversion 1 ftest;auto. -Qed. - - -Require Import Arith. -Lemma test11 : forall m : nat, ftest 0 m <= 2. -intros m. - functional induction ftest 0 m. -auto. -auto. -auto with *. -Qed. - -Function lamfix (m n : nat) {struct n } : nat := - match n with - | O => m - | S p => lamfix m p - end. - -(* Parameter v1 v2 : nat. *) - -Lemma lamfix_lem : forall v1 v2 : nat, lamfix v1 v2 = v1. -intros v1 v2. - functional induction lamfix v1 v2. -trivial. -assumption. -Defined. - - - -(* polymorphic function *) -Require Import List. - -Functional Scheme app_ind := Induction for app Sort Prop. - -Lemma appnil : forall (A : Set) (l l' : list A), l' = nil -> l = l ++ l'. -intros A l l'. - functional induction app A l l'; intuition. - rewrite <- H0; trivial. -Qed. - - - - - -Require Export Arith. - - -Function trivfun (n : nat) : nat := - match n with - | O => 0 - | S m => trivfun m - end. - - -(* essaie de parametre variables non locaux:*) - -Parameter varessai : nat. - -Lemma first_try : trivfun varessai = 0. - functional induction trivfun varessai. -trivial. -assumption. -Defined. - - - Functional Scheme triv_ind := Induction for trivfun Sort Prop. - -Lemma bisrepetita : forall n' : nat, trivfun n' = 0. -intros n'. - functional induction trivfun n'. -trivial. -assumption. -Qed. - - - - - - - -Function iseven (n : nat) : bool := - match n with - | O => true - | S (S m) => iseven m - | _ => false - end. - - -Function funex (n : nat) : nat := - match iseven n with - | true => n - | false => match n with - | O => 0 - | S r => funex r - end - end. - - -Function nat_equal_bool (n m : nat) {struct n} : bool := - match n with - | O => match m with - | O => true - | _ => false - end - | S p => match m with - | O => false - | S q => nat_equal_bool p q - end - end. - - -Require Export Div2. -Require Import Nat. -Functional Scheme div2_ind := Induction for div2 Sort Prop. -Lemma div2_inf : forall n : nat, div2 n <= n. -intros n. - functional induction div2 n. -auto. -auto. - -apply le_S. -apply le_n_S. -exact IHn0. -Qed. - -(* reuse this lemma as a scheme:*) - -Function nested_lam (n : nat) : nat -> nat := - match n with - | O => fun m : nat => 0 - | S n' => fun m : nat => m + nested_lam n' m - end. - - -Lemma nest : forall n m : nat, nested_lam n m = n * m. -intros n m. - functional induction nested_lam n m; simpl;auto. -Qed. - - -Function essai (x : nat) (p : nat * nat) {struct x} : nat := - let (n, m) := (p: nat*nat) in - match n with - | O => 0 - | S q => match x with - | O => 1 - | S r => S (essai r (q, m)) - end - end. - -Lemma essai_essai : - forall (x : nat) (p : nat * nat), let (n, m) := p in 0 < n -> 0 < essai x p. -intros x p. - functional induction essai x p; intros. -inversion H. -auto with arith. - auto with arith. -Qed. - -Function plus_x_not_five'' (n m : nat) {struct n} : nat := - let x := nat_equal_bool m 5 in - let y := 0 in - match n with - | O => y - | S q => - let recapp := plus_x_not_five'' q m in - match x with - | true => S recapp - | false => S recapp - end - end. - -Lemma notplusfive'' : forall x y : nat, y = 5 -> plus_x_not_five'' x y = x. -intros a b. - functional induction plus_x_not_five'' a b; intros hyp; simpl; auto. -Qed. - -Lemma iseq_eq : forall n m : nat, n = m -> nat_equal_bool n m = true. -intros n m. - functional induction nat_equal_bool n m; simpl; intros hyp; auto. -rewrite <- hyp in y; simpl in y;tauto. -inversion hyp. -Qed. - -Lemma iseq_eq' : forall n m : nat, nat_equal_bool n m = true -> n = m. -intros n m. - functional induction nat_equal_bool n m; simpl; intros eg; auto. -inversion eg. -inversion eg. -Qed. - - -Inductive istrue : bool -> Prop := - istrue0 : istrue true. - -Functional Scheme add_ind := Induction for add Sort Prop. - -Lemma inf_x_plusxy' : forall x y : nat, x <= x + y. -intros n m. - functional induction add n m; intros. -auto with arith. -auto with arith. -Qed. - - -Lemma inf_x_plusxy'' : forall x : nat, x <= x + 0. -intros n. -unfold plus. - functional induction plus n 0; intros. -auto with arith. -apply le_n_S. -assumption. -Qed. - -Lemma inf_x_plusxy''' : forall x : nat, x <= 0 + x. -intros n. - functional induction plus 0 n; intros; auto with arith. -Qed. - -Function mod2 (n : nat) : nat := - match n with - | O => 0 - | S (S m) => S (mod2 m) - | _ => 0 - end. - -Lemma princ_mod2 : forall n : nat, mod2 n <= n. -intros n. - functional induction mod2 n; simpl; auto with arith. -Qed. - -Function isfour (n : nat) : bool := - match n with - | S (S (S (S O))) => true - | _ => false - end. - -Function isononeorfour (n : nat) : bool := - match n with - | S O => true - | S (S (S (S O))) => true - | _ => false - end. - -Lemma toto'' : forall n : nat, istrue (isfour n) -> istrue (isononeorfour n). -intros n. - functional induction isononeorfour n; intros istr; simpl; - inversion istr. -apply istrue0. -destruct n. inversion istr. -destruct n. tauto. -destruct n. inversion istr. -destruct n. inversion istr. -destruct n. tauto. -simpl in *. inversion H0. -Qed. - -Lemma toto' : forall n m : nat, n = 4 -> istrue (isononeorfour n). -intros n. - functional induction isononeorfour n; intros m istr; inversion istr. -apply istrue0. -rewrite H in y; simpl in y;tauto. -Qed. - -Function ftest4 (n m : nat) : nat := - match n with - | O => match m with - | O => 0 - | S q => 1 - end - | S p => match m with - | O => 0 - | S r => 1 - end - end. - -Lemma test4 : forall n m : nat, ftest n m <= 2. -intros n m. - functional induction ftest n m; auto with arith. -Qed. - -Lemma test4' : forall n m : nat, ftest4 (S n) m <= 2. -intros n m. -assert ({n0 | n0 = S n}). -exists (S n);reflexivity. -destruct H as [n0 H1]. -rewrite <- H1;revert H1. - functional induction ftest4 n0 m. -inversion 1. -inversion 1. - -auto with arith. -auto with arith. -Qed. - -Function ftest44 (x : nat * nat) (n m : nat) : nat := - let (p, q) := (x: nat*nat) in - match n with - | O => match m with - | O => 0 - | S q => 1 - end - | S p => match m with - | O => 0 - | S r => 1 - end - end. - -Lemma test44 : - forall (pq : nat * nat) (n m o r s : nat), ftest44 pq n (S m) <= 2. -intros pq n m o r s. - functional induction ftest44 pq n (S m). -auto with arith. -auto with arith. -auto with arith. -auto with arith. -Qed. - -Function ftest2 (n m : nat) {struct n} : nat := - match n with - | O => match m with - | O => 0 - | S q => 0 - end - | S p => ftest2 p m - end. - -Lemma test2' : forall n m : nat, ftest2 n m <= 2. -intros n m. - functional induction ftest2 n m; simpl; intros; auto. -Qed. - -Function ftest3 (n m : nat) {struct n} : nat := - match n with - | O => 0 - | S p => match m with - | O => ftest3 p 0 - | S r => 0 - end - end. - -Lemma test3' : forall n m : nat, ftest3 n m <= 2. -intros n m. - functional induction ftest3 n m. -intros. -auto. -intros. -auto. -intros. -simpl. -auto. -Qed. - -Function ftest5 (n m : nat) {struct n} : nat := - match n with - | O => 0 - | S p => match m with - | O => ftest5 p 0 - | S r => ftest5 p r - end - end. - -Lemma test5 : forall n m : nat, ftest5 n m <= 2. -intros n m. - functional induction ftest5 n m. -intros. -auto. -intros. -auto. -intros. -simpl. -auto. -Qed. - -Function ftest7 (n : nat) : nat := - match ftest5 n 0 with - | O => 0 - | S r => 0 - end. - -Lemma essai7 : - forall (Hrec : forall n : nat, ftest5 n 0 = 0 -> ftest7 n <= 2) - (Hrec0 : forall n r : nat, ftest5 n 0 = S r -> ftest7 n <= 2) - (n : nat), ftest7 n <= 2. -intros hyp1 hyp2 n. - functional induction ftest7 n; auto. -Qed. - -Function ftest6 (n m : nat) {struct n} : nat := - match n with - | O => 0 - | S p => match ftest5 p 0 with - | O => ftest6 p 0 - | S r => ftest6 p r - end - end. - - -Lemma princ6 : - (forall n m : nat, n = 0 -> ftest6 0 m <= 2) -> - (forall n m p : nat, - ftest6 p 0 <= 2 -> ftest5 p 0 = 0 -> n = S p -> ftest6 (S p) m <= 2) -> - (forall n m p r : nat, - ftest6 p r <= 2 -> ftest5 p 0 = S r -> n = S p -> ftest6 (S p) m <= 2) -> - forall x y : nat, ftest6 x y <= 2. -intros hyp1 hyp2 hyp3 n m. -generalize hyp1 hyp2 hyp3. -clear hyp1 hyp2 hyp3. - functional induction ftest6 n m; auto. -Qed. - -Lemma essai6 : forall n m : nat, ftest6 n m <= 2. -intros n m. - functional induction ftest6 n m; simpl; auto. -Qed. - -(* Some tests with modules *) -Module M. -Function test_m (n:nat) : nat := - match n with - | 0 => 0 - | S n => S (S (test_m n)) - end. - -Lemma test_m_is_double : forall n, div2 (test_m n) = n. -Proof. -intros n. -functional induction (test_m n). -reflexivity. -simpl;rewrite IHn0;reflexivity. -Qed. -End M. -(* We redefine a new Function with the same name *) -Function test_m (n:nat) : nat := - pred n. - -Lemma test_m_is_pred : forall n, test_m n = pred n. -Proof. -intro n. -functional induction (test_m n). (* the test_m_ind to use is the last defined saying that test_m = pred*) -reflexivity. -Qed. - -(* Checks if the dot notation are correctly treated in infos *) -Lemma M_test_m_is_double : forall n, div2 (M.test_m n) = n. -intro n. -(* here we should apply M.test_m_ind *) -functional induction (M.test_m n). -reflexivity. -simpl;rewrite IHn0;reflexivity. -Qed. - -Import M. -(* Now test_m is the one which defines double *) - -Lemma test_m_is_double : forall n, div2 (M.test_m n) = n. -intro n. -(* here we should apply M.test_m_ind *) -functional induction (test_m n). -reflexivity. -simpl;rewrite IHn0;reflexivity. -Qed. - -Extraction iszero. diff --git a/test-suite/success/Injection.v b/test-suite/success/Injection.v index 78652fb64b..7ee471bae7 100644 --- a/test-suite/success/Injection.v +++ b/test-suite/success/Injection.v @@ -19,8 +19,8 @@ Qed. (* Check that no tuple needs to be built *) Lemma l3 : forall x y : nat, - existS (fun n : nat => {n = n} + {n = n}) x (left _ (refl_equal x)) = - existS (fun n : nat => {n = n} + {n = n}) y (left _ (refl_equal y)) -> + existT (fun n : nat => {n = n} + {n = n}) x (left _ (refl_equal x)) = + existT (fun n : nat => {n = n} + {n = n}) y (left _ (refl_equal y)) -> x = y. intros x y H. injection H. @@ -30,10 +30,10 @@ Qed. (* Check that a tuple is built (actually the same as the initial one) *) Lemma l4 : forall p1 p2 : {0 = 0} + {0 = 0}, - existS (fun n : nat => {n = n} + {n = n}) 0 p1 = - existS (fun n : nat => {n = n} + {n = n}) 0 p2 -> - existS (fun n : nat => {n = n} + {n = n}) 0 p1 = - existS (fun n : nat => {n = n} + {n = n}) 0 p2. + existT (fun n : nat => {n = n} + {n = n}) 0 p1 = + existT (fun n : nat => {n = n} + {n = n}) 0 p2 -> + existT (fun n : nat => {n = n} + {n = n}) 0 p1 = + existT (fun n : nat => {n = n} + {n = n}) 0 p2. intros. injection H. exact (fun H => H). diff --git a/test-suite/success/rewrite.v b/test-suite/success/rewrite.v index 448d0082db..baf089796f 100644 --- a/test-suite/success/rewrite.v +++ b/test-suite/success/rewrite.v @@ -7,7 +7,7 @@ Inductive listn : nat -> Set := Axiom ax : forall (n n' : nat) (l : listn (n + n')) (l' : listn (n' + n)), - existS _ (n + n') l = existS _ (n' + n) l'. + existT _ (n + n') l = existT _ (n' + n) l'. Lemma lem : forall (n n' : nat) (l : listn (n + n')) (l' : listn (n' + n)), @@ -72,7 +72,7 @@ Qed. Require Import JMeq. -Goal forall A B (a:A) (b:B), JMeq a b -> JMeq b a -> True. +Goal forall A B (a:A) (b:B), JMeq a b -> JMeq b a -> True. inversion 1; (* Goal is now [JMeq a a -> True] *) dependent rewrite H3. Undo. intros; inversion H; dependent rewrite H4 in H0. @@ -135,7 +135,7 @@ Abort. Goal forall x y, x=y+0 -> let z := x+1 in x+1=y -> z=z -> z=x. intros. subst x. (* was failing *) -subst z. +subst z. rewrite H0. auto with arith. Qed. diff --git a/test-suite/tools/update-compat/run.sh b/test-suite/tools/update-compat/run.sh new file mode 100755 index 0000000000..02a2348450 --- /dev/null +++ b/test-suite/tools/update-compat/run.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# allow running this script from any directory by basing things on where the script lives +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +# we assume that the script lives in test-suite/tools/update-compat/, +# and that update-compat.py lives in dev/tools/ +cd "${SCRIPT_DIR}/../../.." +dev/tools/update-compat.py --assert-unchanged --cur-version=8.9 || exit $? diff --git a/theories/Arith/Compare_dec.v b/theories/Arith/Compare_dec.v index 713aef858e..6f220f2023 100644 --- a/theories/Arith/Compare_dec.v +++ b/theories/Arith/Compare_dec.v @@ -135,10 +135,10 @@ Qed. See now [Nat.compare] and its properties. In scope [nat_scope], the notation for [Nat.compare] is "?=" *) -Notation nat_compare := Nat.compare (compat "8.6"). +Notation nat_compare := Nat.compare (compat "8.7"). -Notation nat_compare_spec := Nat.compare_spec (compat "8.6"). -Notation nat_compare_eq_iff := Nat.compare_eq_iff (compat "8.6"). +Notation nat_compare_spec := Nat.compare_spec (compat "8.7"). +Notation nat_compare_eq_iff := Nat.compare_eq_iff (compat "8.7"). Notation nat_compare_S := Nat.compare_succ (only parsing). Lemma nat_compare_lt n m : n<m <-> (n ?= m) = Lt. diff --git a/theories/Compat/Coq88.v b/theories/Compat/Coq88.v index 578425bfb5..950cd8242b 100644 --- a/theories/Compat/Coq88.v +++ b/theories/Compat/Coq88.v @@ -9,6 +9,8 @@ (************************************************************************) (** Compatibility file for making Coq act similar to Coq v8.8 *) +Require Export Coq.Compat.Coq89. + (** In Coq 8.9, prim token notations follow [Import] rather than [Require]. So we make all of the relevant notations accessible in compatibility mode. *) diff --git a/theories/Compat/Coq86.v b/theories/Compat/Coq89.v index 666be207eb..d25671887f 100644 --- a/theories/Compat/Coq86.v +++ b/theories/Compat/Coq89.v @@ -8,8 +8,4 @@ (* * (see LICENSE file for the text of the license) *) (************************************************************************) -(** Compatibility file for making Coq act similar to Coq v8.6 *) -Require Export Coq.Compat.Coq87. - -Require Export Coq.extraction.Extraction. -Require Export Coq.funind.FunInd. +(** Compatibility file for making Coq act similar to Coq v8.9 *) diff --git a/theories/FSets/FMapFacts.v b/theories/FSets/FMapFacts.v index 997059669d..2d5a79838a 100644 --- a/theories/FSets/FMapFacts.v +++ b/theories/FSets/FMapFacts.v @@ -26,7 +26,7 @@ Hint Extern 1 (Equivalence _) => constructor; congruence. Module WFacts_fun (E:DecidableType)(Import M:WSfun E). -Notation option_map := option_map (compat "8.6"). +Notation option_map := option_map (compat "8.7"). Notation eq_dec := E.eq_dec. Definition eqb x y := if eq_dec x y then true else false. diff --git a/theories/Init/Datatypes.v b/theories/Init/Datatypes.v index 76c39f275d..8a0265438a 100644 --- a/theories/Init/Datatypes.v +++ b/theories/Init/Datatypes.v @@ -177,11 +177,12 @@ Arguments inr {A B} _ , A [B] _. the pair [pair A B a b] of [a] and [b] is abbreviated [(a,b)] *) Inductive prod (A B:Type) : Type := - pair : A -> B -> prod A B. + pair : A -> B -> A * B + +where "x * y" := (prod x y) : type_scope. Add Printing Let prod. -Notation "x * y" := (prod x y) : type_scope. Notation "( x , y , .. , z )" := (pair .. (pair x y) .. z) : core_scope. Arguments pair {A B} _ _. @@ -189,18 +190,14 @@ Arguments pair {A B} _ _. Section projections. Context {A : Type} {B : Type}. - Definition fst (p:A * B) := match p with - | (x, y) => x - end. - Definition snd (p:A * B) := match p with - | (x, y) => y - end. + Definition fst (p:A * B) := match p with (x, y) => x end. + Definition snd (p:A * B) := match p with (x, y) => y end. End projections. Hint Resolve pair inl inr: core. Lemma surjective_pairing : - forall (A B:Type) (p:A * B), p = pair (fst p) (snd p). + forall (A B:Type) (p:A * B), p = (fst p, snd p). Proof. destruct p; reflexivity. Qed. @@ -213,13 +210,19 @@ Proof. rewrite Hfst; rewrite Hsnd; reflexivity. Qed. -Definition prod_uncurry (A B C:Type) (f:prod A B -> C) - (x:A) (y:B) : C := f (pair x y). +Definition prod_uncurry (A B C:Type) (f:A * B -> C) + (x:A) (y:B) : C := f (x,y). Definition prod_curry (A B C:Type) (f:A -> B -> C) - (p:prod A B) : C := match p with - | pair x y => f x y - end. + (p:A * B) : C := match p with (x, y) => f x y end. + +Import EqNotations. + +Lemma rew_pair : forall A (P Q : A->Type) x1 x2 (y1:P x1) (y2:Q x1) (H:x1=x2), + (rew H in y1, rew H in y2) = rew [fun x => (P x * Q x)%type] H in (y1,y2). +Proof. + destruct H. reflexivity. +Defined. (** Polymorphic lists and some operations *) @@ -254,7 +257,6 @@ Definition app (A : Type) : list A -> list A -> list A := | a :: l1 => a :: app l1 m end. - Infix "++" := app (right associativity, at level 60) : list_scope. (* Unset Universe Polymorphism. *) diff --git a/theories/Init/Logic.v b/theories/Init/Logic.v index 9d60cf54c3..4ec0049a9c 100644 --- a/theories/Init/Logic.v +++ b/theories/Init/Logic.v @@ -406,6 +406,37 @@ End EqNotations. Import EqNotations. +Section equality_dep. + Variable A : Type. + Variable B : A -> Type. + Variable f : forall x, B x. + Variables x y : A. + + Theorem f_equal_dep : forall (H: x = y), rew H in f x = f y. + Proof. + destruct H; reflexivity. + Defined. + +End equality_dep. + +Section equality_dep2. + + Variable A A' : Type. + Variable B : A -> Type. + Variable B' : A' -> Type. + Variable f : A -> A'. + Variable g : forall a:A, B a -> B' (f a). + Variables x y : A. + + Lemma f_equal_dep2 : forall {A A' B B'} (f : A -> A') (g : forall a:A, B a -> B' (f a)) + {x1 x2 : A} {y1 : B x1} {y2 : B x2} (H : x1 = x2), + rew H in y1 = y2 -> rew f_equal f H in g x1 y1 = g x2 y2. + Proof. + destruct H, 1. reflexivity. + Defined. + +End equality_dep2. + Lemma rew_opp_r : forall A (P:A->Type) (x y:A) (H:x=y) (a:P y), rew H in rew <- H in a = a. Proof. intros. @@ -492,6 +523,42 @@ Proof. destruct e''; reflexivity. Defined. +Theorem rew_map : forall A B (P:B->Type) (f:A->B) x1 x2 (H:x1=x2) (y:P (f x1)), + rew [fun x => P (f x)] H in y = rew f_equal f H in y. +Proof. + destruct H; reflexivity. +Defined. + +Theorem eq_trans_map : forall {A B} {x1 x2 x3:A} {y1:B x1} {y2:B x2} {y3:B x3}, + forall (H1:x1=x2) (H2:x2=x3) (H1': rew H1 in y1 = y2) (H2': rew H2 in y2 = y3), + rew eq_trans H1 H2 in y1 = y3. +Proof. + intros. destruct H2. exact (eq_trans H1' H2'). +Defined. + +Lemma map_subst : forall {A} {P Q:A->Type} (f : forall x, P x -> Q x) {x y} (H:x=y) (z:P x), + rew H in f x z = f y (rew H in z). +Proof. + destruct H. reflexivity. +Defined. + +Lemma map_subst_map : forall {A B} {P:A->Type} {Q:B->Type} (f:A->B) (g : forall x, P x -> Q (f x)), + forall {x y} (H:x=y) (z:P x), rew f_equal f H in g x z = g y (rew H in z). +Proof. + destruct H. reflexivity. +Defined. + +Lemma rew_swap : forall A (P:A->Type) x1 x2 (H:x1=x2) (y1:P x1) (y2:P x2), rew H in y1 = y2 -> y1 = rew <- H in y2. +Proof. + destruct H. trivial. +Defined. + +Lemma rew_compose : forall A (P:A->Type) x1 x2 x3 (H1:x1=x2) (H2:x2=x3) (y:P x1), + rew H2 in rew H1 in y = rew (eq_trans H1 H2) in y. +Proof. + destruct H2. reflexivity. +Defined. + (** Extra properties of equality *) Theorem eq_id_comm_l : forall A (f:A->A) (Hf:forall a, a = f a), forall a, f_equal f (Hf a) = Hf (f a). diff --git a/theories/Init/Specif.v b/theories/Init/Specif.v index db8857df64..a5f926f7ab 100644 --- a/theories/Init/Specif.v +++ b/theories/Init/Specif.v @@ -154,6 +154,10 @@ Section Projections. End Projections. +Local Notation "( x ; y )" := (existT _ x y) (at level 0, format "( x ; '/ ' y )"). +Local Notation "x .1" := (projT1 x) (at level 1, left associativity, format "x .1"). +Local Notation "x .2" := (projT2 x) (at level 1, left associativity, format "x .2"). + (** [sigT2] of a predicate can be projected to a [sigT]. This allows [projT1] and [projT2] to be usable with [sigT2]. @@ -231,6 +235,7 @@ Proof. Qed. (** Equality of sigma types *) + Import EqNotations. Local Notation "'rew' 'dependent' H 'in' H'" := (match H with @@ -244,18 +249,18 @@ Section sigT. Local Unset Implicit Arguments. (** Projecting an equality of a pair to equality of the first components *) Definition projT1_eq {A} {P : A -> Type} {u v : { a : A & P a }} (p : u = v) - : projT1 u = projT1 v - := f_equal (@projT1 _ _) p. + : u.1 = v.1 + := f_equal (fun x => x.1) p. (** Projecting an equality of a pair to equality of the second components *) Definition projT2_eq {A} {P : A -> Type} {u v : { a : A & P a }} (p : u = v) - : rew projT1_eq p in projT2 u = projT2 v + : rew projT1_eq p in u.2 = v.2 := rew dependent p in eq_refl. (** Equality of [sigT] is itself a [sigT] (forwards-reasoning version) *) Definition eq_existT_uncurried {A : Type} {P : A -> Type} {u1 v1 : A} {u2 : P u1} {v2 : P v1} (pq : { p : u1 = v1 & rew p in u2 = v2 }) - : existT _ u1 u2 = existT _ v1 v2. + : (u1; u2) = (v1; v2). Proof. destruct pq as [p q]. destruct q; simpl in *. @@ -264,23 +269,55 @@ Section sigT. (** Equality of [sigT] is itself a [sigT] (backwards-reasoning version) *) Definition eq_sigT_uncurried {A : Type} {P : A -> Type} (u v : { a : A & P a }) - (pq : { p : projT1 u = projT1 v & rew p in projT2 u = projT2 v }) + (pq : { p : u.1 = v.1 & rew p in u.2 = v.2 }) : u = v. Proof. destruct u as [u1 u2], v as [v1 v2]; simpl in *. apply eq_existT_uncurried; exact pq. Defined. + Lemma eq_existT_curried {A : Type} {P : A -> Type} {u1 v1 : A} {u2 : P u1} {v2 : P v1} + (p : u1 = v1) (q : rew p in u2 = v2) : (u1; u2) = (v1; v2). + Proof. + destruct p, q. reflexivity. + Defined. + + Local Notation "(= u ; v )" := (eq_existT_curried u v) (at level 0, format "(= u ; '/ ' v )"). + + Lemma eq_existT_curried_map {A A' P P'} (f:A -> A') (g:forall u:A, P u -> P' (f u)) + {u1 v1 : A} {u2 : P u1} {v2 : P v1} (p : u1 = v1) (q : rew p in u2 = v2) : + f_equal (fun x => (f x.1; g x.1 x.2)) (= p; q) = + (= f_equal f p; f_equal_dep2 f g p q). + Proof. + destruct p, q. reflexivity. + Defined. + + Lemma eq_existT_curried_trans {A P} {u1 v1 w1 : A} {u2 : P u1} {v2 : P v1} {w2 : P w1} + (p : u1 = v1) (q : rew p in u2 = v2) + (p' : v1 = w1) (q': rew p' in v2 = w2) : + eq_trans (= p; q) (= p'; q') = + (= eq_trans p p'; eq_trans_map p p' q q'). + Proof. + destruct p', q'. reflexivity. + Defined. + + Theorem eq_existT_curried_congr {A P} {u1 v1 : A} {u2 : P u1} {v2 : P v1} + {p p' : u1 = v1} {q : rew p in u2 = v2} {q': rew p' in u2 = v2} + (r : p = p') : rew [fun H => rew H in u2 = v2] r in q = q' -> (= p; q) = (= p'; q'). + Proof. + destruct r, 1. reflexivity. + Qed. + (** Curried version of proving equality of sigma types *) Definition eq_sigT {A : Type} {P : A -> Type} (u v : { a : A & P a }) - (p : projT1 u = projT1 v) (q : rew p in projT2 u = projT2 v) + (p : u.1 = v.1) (q : rew p in u.2 = v.2) : u = v := eq_sigT_uncurried u v (existT _ p q). (** Equality of [sigT] when the property is an hProp *) Definition eq_sigT_hprop {A P} (P_hprop : forall (x : A) (p q : P x), p = q) (u v : { a : A & P a }) - (p : projT1 u = projT1 v) + (p : u.1 = v.1) : u = v := eq_sigT u v p (P_hprop _ _ _). @@ -289,7 +326,7 @@ Section sigT. but for simplicity, we don't. *) Definition eq_sigT_uncurried_iff {A P} (u v : { a : A & P a }) - : u = v <-> { p : projT1 u = projT1 v & rew p in projT2 u = projT2 v }. + : u = v <-> { p : u.1 = v.1 & rew p in u.2 = v.2 }. Proof. split; [ intro; subst; exists eq_refl; reflexivity | apply eq_sigT_uncurried ]. Defined. @@ -305,12 +342,12 @@ Section sigT. (** Equivalence of equality of [sigT] involving hProps with equality of the first components *) Definition eq_sigT_hprop_iff {A P} (P_hprop : forall (x : A) (p q : P x), p = q) (u v : { a : A & P a }) - : u = v <-> (projT1 u = projT1 v) + : u = v <-> (u.1 = v.1) := conj (fun p => f_equal (@projT1 _ _) p) (eq_sigT_hprop P_hprop u v). (** Non-dependent classification of equality of [sigT] *) Definition eq_sigT_nondep {A B : Type} (u v : { a : A & B }) - (p : projT1 u = projT1 v) (q : projT2 u = projT2 v) + (p : u.1 = v.1) (q : u.2 = v.2) : u = v := @eq_sigT _ _ u v p (eq_trans (rew_const _ _) q). @@ -319,8 +356,8 @@ Section sigT. : rew [fun a => { p : P a & Q a p }] H in u = existT (Q y) - (rew H in projT1 u) - (rew dependent H in (projT2 u)). + (rew H in u.1) + (rew dependent H in (u.2)). Proof. destruct H, u; reflexivity. Defined. @@ -416,12 +453,12 @@ Section sigT2. : u = v :> { a : A & P a } := f_equal _ p. Definition projT1_of_sigT2_eq {A} {P Q : A -> Type} {u v : { a : A & P a & Q a }} (p : u = v) - : projT1 u = projT1 v + : u.1 = v.1 := projT1_eq (sigT_of_sigT2_eq p). (** Projecting an equality of a pair to equality of the second components *) Definition projT2_of_sigT2_eq {A} {P Q : A -> Type} {u v : { a : A & P a & Q a }} (p : u = v) - : rew projT1_of_sigT2_eq p in projT2 u = projT2 v + : rew projT1_of_sigT2_eq p in u.2 = v.2 := rew dependent p in eq_refl. (** Projecting an equality of a pair to equality of the third components *) @@ -443,8 +480,8 @@ Section sigT2. (** Equality of [sigT2] is itself a [sigT2] (backwards-reasoning version) *) Definition eq_sigT2_uncurried {A : Type} {P Q : A -> Type} (u v : { a : A & P a & Q a }) - (pqr : { p : projT1 u = projT1 v - & rew p in projT2 u = projT2 v & rew p in projT3 u = projT3 v }) + (pqr : { p : u.1 = v.1 + & rew p in u.2 = v.2 & rew p in projT3 u = projT3 v }) : u = v. Proof. destruct u as [u1 u2 u3], v as [v1 v2 v3]; simpl in *. @@ -453,8 +490,8 @@ Section sigT2. (** Curried version of proving equality of sigma types *) Definition eq_sigT2 {A : Type} {P Q : A -> Type} (u v : { a : A & P a & Q a }) - (p : projT1 u = projT1 v) - (q : rew p in projT2 u = projT2 v) + (p : u.1 = v.1) + (q : rew p in u.2 = v.2) (r : rew p in projT3 u = projT3 v) : u = v := eq_sigT2_uncurried u v (existT2 _ _ p q r). @@ -472,8 +509,8 @@ Section sigT2. Definition eq_sigT2_uncurried_iff {A P Q} (u v : { a : A & P a & Q a }) : u = v - <-> { p : projT1 u = projT1 v - & rew p in projT2 u = projT2 v & rew p in projT3 u = projT3 v }. + <-> { p : u.1 = v.1 + & rew p in u.2 = v.2 & rew p in projT3 u = projT3 v }. Proof. split; [ intro; subst; exists eq_refl; reflexivity | apply eq_sigT2_uncurried ]. Defined. @@ -498,7 +535,7 @@ Section sigT2. (** Non-dependent classification of equality of [sigT] *) Definition eq_sigT2_nondep {A B C : Type} (u v : { a : A & B & C }) - (p : projT1 u = projT1 v) (q : projT2 u = projT2 v) (r : projT3 u = projT3 v) + (p : u.1 = v.1) (q : u.2 = v.2) (r : projT3 u = projT3 v) : u = v := @eq_sigT2 _ _ _ u v p (eq_trans (rew_const _ _) q) (eq_trans (rew_const _ _) r). @@ -510,8 +547,8 @@ Section sigT2. = existT2 (Q y) (R y) - (rew H in projT1 u) - (rew dependent H in projT2 u) + (rew H in u.1) + (rew dependent H in u.2) (rew dependent H in projT3 u). Proof. destruct H, u; reflexivity. @@ -745,16 +782,16 @@ Hint Resolve exist exist2 existT existT2: core. (* Compatibility *) -Notation sigS := sigT (compat "8.6"). -Notation existS := existT (compat "8.6"). -Notation sigS_rect := sigT_rect (compat "8.6"). -Notation sigS_rec := sigT_rec (compat "8.6"). -Notation sigS_ind := sigT_ind (compat "8.6"). -Notation projS1 := projT1 (compat "8.6"). -Notation projS2 := projT2 (compat "8.6"). - -Notation sigS2 := sigT2 (compat "8.6"). -Notation existS2 := existT2 (compat "8.6"). -Notation sigS2_rect := sigT2_rect (compat "8.6"). -Notation sigS2_rec := sigT2_rec (compat "8.6"). -Notation sigS2_ind := sigT2_ind (compat "8.6"). +Notation sigS := sigT (compat "8.7"). +Notation existS := existT (compat "8.7"). +Notation sigS_rect := sigT_rect (compat "8.7"). +Notation sigS_rec := sigT_rec (compat "8.7"). +Notation sigS_ind := sigT_ind (compat "8.7"). +Notation projS1 := projT1 (compat "8.7"). +Notation projS2 := projT2 (compat "8.7"). + +Notation sigS2 := sigT2 (compat "8.7"). +Notation existS2 := existT2 (compat "8.7"). +Notation sigS2_rect := sigT2_rect (compat "8.7"). +Notation sigS2_rec := sigT2_rec (compat "8.7"). +Notation sigS2_ind := sigT2_ind (compat "8.7"). diff --git a/theories/Lists/List.v b/theories/Lists/List.v index ca5f154e95..4614d215eb 100644 --- a/theories/Lists/List.v +++ b/theories/Lists/List.v @@ -1023,6 +1023,18 @@ Proof. intros; rewrite H by intuition; rewrite IHl; auto. Qed. +Lemma ext_in_map : + forall (A B : Type)(f g:A->B) l, map f l = map g l -> forall a, In a l -> f a = g a. +Proof. induction l; intros [=] ? []; subst; auto. Qed. + +Arguments ext_in_map [A B f g l]. + +Lemma map_ext_in_iff : + forall (A B : Type)(f g:A->B) l, map f l = map g l <-> forall a, In a l -> f a = g a. +Proof. split; [apply ext_in_map | apply map_ext_in]. Qed. + +Arguments map_ext_in_iff [A B f g l]. + Lemma map_ext : forall (A B : Type)(f g:A->B), (forall a, f a = g a) -> forall l, map f l = map g l. Proof. @@ -1717,6 +1729,32 @@ Section Cutting. end end. + Lemma firstn_skipn_comm : forall m n l, + firstn m (skipn n l) = skipn n (firstn (n + m) l). + Proof. now intros m; induction n; intros []; simpl; destruct m. Qed. + + Lemma skipn_firstn_comm : forall m n l, + skipn m (firstn n l) = firstn (n - m) (skipn m l). + Proof. now induction m; intros [] []; simpl; rewrite ?firstn_nil. Qed. + + Lemma skipn_O : forall l, skipn 0 l = l. + Proof. reflexivity. Qed. + + Lemma skipn_nil : forall n, skipn n ([] : list A) = []. + Proof. now intros []. Qed. + + Lemma skipn_cons n a l: skipn (S n) (a::l) = skipn n l. + Proof. reflexivity. Qed. + + Lemma skipn_none : forall l, skipn (length l) l = []. + Proof. now induction l. Qed. + + Lemma skipn_all2 n: forall l, length l <= n -> skipn n l = []. + Proof. + intros l L%Nat.sub_0_le; rewrite <-(firstn_all l) at 1. + now rewrite skipn_firstn_comm, L. + Qed. + Lemma firstn_skipn : forall n l, firstn n l ++ skipn n l = l. Proof. induction n. @@ -1730,6 +1768,51 @@ Section Cutting. induction n; destruct l; simpl; auto. Qed. + Lemma skipn_length n : + forall l, length (skipn n l) = length l - n. + Proof. + induction n. + - intros l; simpl; rewrite Nat.sub_0_r; reflexivity. + - destruct l; simpl; auto. + Qed. + + Lemma skipn_all l: skipn (length l) l = nil. + Proof. now induction l. Qed. + + Lemma skipn_app n : forall l1 l2, + skipn n (l1 ++ l2) = (skipn n l1) ++ (skipn (n - length l1) l2). + Proof. induction n; auto; intros [|]; simpl; auto. Qed. + + Lemma firstn_skipn_rev: forall x l, + firstn x l = rev (skipn (length l - x) (rev l)). + Proof. + intros x l; rewrite <-(firstn_skipn x l) at 3. + rewrite rev_app_distr, skipn_app, rev_app_distr, rev_length, + skipn_length, Nat.sub_diag; simpl; rewrite rev_involutive. + rewrite <-app_nil_r at 1; f_equal; symmetry; apply length_zero_iff_nil. + repeat rewrite rev_length, skipn_length; apply Nat.sub_diag. + Qed. + + Lemma firstn_rev: forall x l, + firstn x (rev l) = rev (skipn (length l - x) l). + Proof. + now intros x l; rewrite firstn_skipn_rev, rev_involutive, rev_length. + Qed. + + Lemma skipn_rev: forall x l, + skipn x (rev l) = rev (firstn (length l - x) l). + Proof. + intros x l; rewrite firstn_skipn_rev, rev_involutive, <-rev_length. + destruct (Nat.le_ge_cases (length (rev l)) x) as [L | L]. + - rewrite skipn_all2; [apply Nat.sub_0_le in L | trivial]. + now rewrite L, Nat.sub_0_r, skipn_none. + - replace (length (rev l) - (length (rev l) - x)) + with (length (rev l) + x - length (rev l)). + rewrite minus_plus. reflexivity. + rewrite <- (Nat.sub_add _ _ L) at 2. + now rewrite <-!(Nat.add_comm x), <-minus_plus_simpl_l_reverse. + Qed. + Lemma removelast_firstn : forall n l, n < length l -> removelast (firstn (S n) l) = firstn n l. Proof. @@ -2073,6 +2156,14 @@ Section NatSeq. rewrite in_seq. intros (H,_). apply (Lt.lt_irrefl _ H). Qed. + Lemma seq_app : forall len1 len2 start, + seq start (len1 + len2) = seq start len1 ++ seq (start + len1) len2. + Proof. + induction len1 as [|len1' IHlen]; intros; simpl in *. + - now rewrite Nat.add_0_r. + - now rewrite Nat.add_succ_r, IHlen. + Qed. + End NatSeq. Section Exists_Forall. diff --git a/theories/Logic/EqdepFacts.v b/theories/Logic/EqdepFacts.v index d938b315f1..8e59941f37 100644 --- a/theories/Logic/EqdepFacts.v +++ b/theories/Logic/EqdepFacts.v @@ -125,7 +125,7 @@ Proof. apply eq_dep_intro. Qed. -Notation eq_sigS_eq_dep := eq_sigT_eq_dep (compat "8.6"). (* Compatibility *) +Notation eq_sigS_eq_dep := eq_sigT_eq_dep (compat "8.7"). (* Compatibility *) Lemma eq_dep_eq_sigT : forall (U:Type) (P:U -> Type) (p q:U) (x:P p) (y:P q), diff --git a/theories/NArith/BinNat.v b/theories/NArith/BinNat.v index bd27f94abd..92c124ec32 100644 --- a/theories/NArith/BinNat.v +++ b/theories/NArith/BinNat.v @@ -966,33 +966,33 @@ Notation N_ind := N_ind (only parsing). Notation N0 := N0 (only parsing). Notation Npos := N.pos (only parsing). -Notation Ndiscr := N.discr (compat "8.6"). +Notation Ndiscr := N.discr (compat "8.7"). Notation Ndouble_plus_one := N.succ_double (only parsing). -Notation Ndouble := N.double (compat "8.6"). -Notation Nsucc := N.succ (compat "8.6"). -Notation Npred := N.pred (compat "8.6"). -Notation Nsucc_pos := N.succ_pos (compat "8.6"). -Notation Ppred_N := Pos.pred_N (compat "8.6"). +Notation Ndouble := N.double (compat "8.7"). +Notation Nsucc := N.succ (compat "8.7"). +Notation Npred := N.pred (compat "8.7"). +Notation Nsucc_pos := N.succ_pos (compat "8.7"). +Notation Ppred_N := Pos.pred_N (compat "8.7"). Notation Nplus := N.add (only parsing). Notation Nminus := N.sub (only parsing). Notation Nmult := N.mul (only parsing). -Notation Neqb := N.eqb (compat "8.6"). -Notation Ncompare := N.compare (compat "8.6"). -Notation Nlt := N.lt (compat "8.6"). -Notation Ngt := N.gt (compat "8.6"). -Notation Nle := N.le (compat "8.6"). -Notation Nge := N.ge (compat "8.6"). -Notation Nmin := N.min (compat "8.6"). -Notation Nmax := N.max (compat "8.6"). -Notation Ndiv2 := N.div2 (compat "8.6"). -Notation Neven := N.even (compat "8.6"). -Notation Nodd := N.odd (compat "8.6"). -Notation Npow := N.pow (compat "8.6"). -Notation Nlog2 := N.log2 (compat "8.6"). +Notation Neqb := N.eqb (compat "8.7"). +Notation Ncompare := N.compare (compat "8.7"). +Notation Nlt := N.lt (compat "8.7"). +Notation Ngt := N.gt (compat "8.7"). +Notation Nle := N.le (compat "8.7"). +Notation Nge := N.ge (compat "8.7"). +Notation Nmin := N.min (compat "8.7"). +Notation Nmax := N.max (compat "8.7"). +Notation Ndiv2 := N.div2 (compat "8.7"). +Notation Neven := N.even (compat "8.7"). +Notation Nodd := N.odd (compat "8.7"). +Notation Npow := N.pow (compat "8.7"). +Notation Nlog2 := N.log2 (compat "8.7"). Notation nat_of_N := N.to_nat (only parsing). Notation N_of_nat := N.of_nat (only parsing). -Notation N_eq_dec := N.eq_dec (compat "8.6"). +Notation N_eq_dec := N.eq_dec (compat "8.7"). Notation Nrect := N.peano_rect (only parsing). Notation Nrect_base := N.peano_rect_base (only parsing). Notation Nrect_step := N.peano_rect_succ (only parsing). @@ -1001,11 +1001,11 @@ Notation Nrec := N.peano_rec (only parsing). Notation Nrec_base := N.peano_rec_base (only parsing). Notation Nrec_succ := N.peano_rec_succ (only parsing). -Notation Npred_succ := N.pred_succ (compat "8.6"). +Notation Npred_succ := N.pred_succ (compat "8.7"). Notation Npred_minus := N.pred_sub (only parsing). -Notation Nsucc_pred := N.succ_pred (compat "8.6"). +Notation Nsucc_pred := N.succ_pred (compat "8.7"). Notation Ppred_N_spec := N.pos_pred_spec (only parsing). -Notation Nsucc_pos_spec := N.succ_pos_spec (compat "8.6"). +Notation Nsucc_pos_spec := N.succ_pos_spec (compat "8.7"). Notation Ppred_Nsucc := N.pos_pred_succ (only parsing). Notation Nplus_0_l := N.add_0_l (only parsing). Notation Nplus_0_r := N.add_0_r (only parsing). @@ -1013,7 +1013,7 @@ Notation Nplus_comm := N.add_comm (only parsing). Notation Nplus_assoc := N.add_assoc (only parsing). Notation Nplus_succ := N.add_succ_l (only parsing). Notation Nsucc_0 := N.succ_0_discr (only parsing). -Notation Nsucc_inj := N.succ_inj (compat "8.6"). +Notation Nsucc_inj := N.succ_inj (compat "8.7"). Notation Nminus_N0_Nle := N.sub_0_le (only parsing). Notation Nminus_0_r := N.sub_0_r (only parsing). Notation Nminus_succ_r:= N.sub_succ_r (only parsing). @@ -1023,29 +1023,29 @@ Notation Nmult_1_r := N.mul_1_r (only parsing). Notation Nmult_comm := N.mul_comm (only parsing). Notation Nmult_assoc := N.mul_assoc (only parsing). Notation Nmult_plus_distr_r := N.mul_add_distr_r (only parsing). -Notation Neqb_eq := N.eqb_eq (compat "8.6"). +Notation Neqb_eq := N.eqb_eq (compat "8.7"). Notation Nle_0 := N.le_0_l (only parsing). -Notation Ncompare_refl := N.compare_refl (compat "8.6"). +Notation Ncompare_refl := N.compare_refl (compat "8.7"). Notation Ncompare_Eq_eq := N.compare_eq (only parsing). Notation Ncompare_eq_correct := N.compare_eq_iff (only parsing). -Notation Nlt_irrefl := N.lt_irrefl (compat "8.6"). -Notation Nlt_trans := N.lt_trans (compat "8.6"). +Notation Nlt_irrefl := N.lt_irrefl (compat "8.7"). +Notation Nlt_trans := N.lt_trans (compat "8.7"). Notation Nle_lteq := N.lt_eq_cases (only parsing). -Notation Nlt_succ_r := N.lt_succ_r (compat "8.6"). -Notation Nle_trans := N.le_trans (compat "8.6"). -Notation Nle_succ_l := N.le_succ_l (compat "8.6"). -Notation Ncompare_spec := N.compare_spec (compat "8.6"). +Notation Nlt_succ_r := N.lt_succ_r (compat "8.7"). +Notation Nle_trans := N.le_trans (compat "8.7"). +Notation Nle_succ_l := N.le_succ_l (compat "8.7"). +Notation Ncompare_spec := N.compare_spec (compat "8.7"). Notation Ncompare_0 := N.compare_0_r (only parsing). Notation Ndouble_div2 := N.div2_double (only parsing). Notation Ndouble_plus_one_div2 := N.div2_succ_double (only parsing). -Notation Ndouble_inj := N.double_inj (compat "8.6"). +Notation Ndouble_inj := N.double_inj (compat "8.7"). Notation Ndouble_plus_one_inj := N.succ_double_inj (only parsing). -Notation Npow_0_r := N.pow_0_r (compat "8.6"). -Notation Npow_succ_r := N.pow_succ_r (compat "8.6"). -Notation Nlog2_spec := N.log2_spec (compat "8.6"). -Notation Nlog2_nonpos := N.log2_nonpos (compat "8.6"). -Notation Neven_spec := N.even_spec (compat "8.6"). -Notation Nodd_spec := N.odd_spec (compat "8.6"). +Notation Npow_0_r := N.pow_0_r (compat "8.7"). +Notation Npow_succ_r := N.pow_succ_r (compat "8.7"). +Notation Nlog2_spec := N.log2_spec (compat "8.7"). +Notation Nlog2_nonpos := N.log2_nonpos (compat "8.7"). +Notation Neven_spec := N.even_spec (compat "8.7"). +Notation Nodd_spec := N.odd_spec (compat "8.7"). Notation Nlt_not_eq := N.lt_neq (only parsing). Notation Ngt_Nlt := N.gt_lt (only parsing). diff --git a/theories/NArith/Ndec.v b/theories/NArith/Ndec.v index 67c30f2250..e2b2b4904e 100644 --- a/theories/NArith/Ndec.v +++ b/theories/NArith/Ndec.v @@ -22,8 +22,8 @@ Local Open Scope N_scope. (** Obsolete results about boolean comparisons over [N], kept for compatibility with IntMap and SMC. *) -Notation Peqb := Pos.eqb (compat "8.6"). -Notation Neqb := N.eqb (compat "8.6"). +Notation Peqb := Pos.eqb (compat "8.7"). +Notation Neqb := N.eqb (compat "8.7"). Notation Peqb_correct := Pos.eqb_refl (only parsing). Notation Neqb_correct := N.eqb_refl (only parsing). Notation Neqb_comm := N.eqb_sym (only parsing). diff --git a/theories/NArith/Ndiv_def.v b/theories/NArith/Ndiv_def.v index 7c9fd86958..885c0d48b1 100644 --- a/theories/NArith/Ndiv_def.v +++ b/theories/NArith/Ndiv_def.v @@ -24,10 +24,10 @@ Lemma Pdiv_eucl_remainder a b : snd (Pdiv_eucl a b) < Npos b. Proof. now apply (N.pos_div_eucl_remainder a (Npos b)). Qed. -Notation Ndiv_eucl := N.div_eucl (compat "8.6"). -Notation Ndiv := N.div (compat "8.6"). +Notation Ndiv_eucl := N.div_eucl (compat "8.7"). +Notation Ndiv := N.div (compat "8.7"). Notation Nmod := N.modulo (only parsing). Notation Ndiv_eucl_correct := N.div_eucl_spec (only parsing). Notation Ndiv_mod_eq := N.div_mod' (only parsing). -Notation Nmod_lt := N.mod_lt (compat "8.6"). +Notation Nmod_lt := N.mod_lt (compat "8.7"). diff --git a/theories/NArith/Nsqrt_def.v b/theories/NArith/Nsqrt_def.v index e771fe9167..f043328375 100644 --- a/theories/NArith/Nsqrt_def.v +++ b/theories/NArith/Nsqrt_def.v @@ -13,8 +13,8 @@ Require Import BinNat. (** Obsolete file, see [BinNat] now, only compatibility notations remain here. *) -Notation Nsqrtrem := N.sqrtrem (compat "8.6"). -Notation Nsqrt := N.sqrt (compat "8.6"). -Notation Nsqrtrem_spec := N.sqrtrem_spec (compat "8.6"). +Notation Nsqrtrem := N.sqrtrem (compat "8.7"). +Notation Nsqrt := N.sqrt (compat "8.7"). +Notation Nsqrtrem_spec := N.sqrtrem_spec (compat "8.7"). Notation Nsqrt_spec := (fun n => N.sqrt_spec n (N.le_0_l n)) (only parsing). -Notation Nsqrtrem_sqrt := N.sqrtrem_sqrt (compat "8.6"). +Notation Nsqrtrem_sqrt := N.sqrtrem_sqrt (compat "8.7"). diff --git a/theories/PArith/BinPos.v b/theories/PArith/BinPos.v index dcaae1606d..01ecdd710c 100644 --- a/theories/PArith/BinPos.v +++ b/theories/PArith/BinPos.v @@ -1907,12 +1907,12 @@ Notation IsNul := Pos.IsNul (only parsing). Notation IsPos := Pos.IsPos (only parsing). Notation IsNeg := Pos.IsNeg (only parsing). -Notation Psucc := Pos.succ (compat "8.6"). +Notation Psucc := Pos.succ (compat "8.7"). Notation Pplus := Pos.add (only parsing). Notation Pplus_carry := Pos.add_carry (only parsing). -Notation Ppred := Pos.pred (compat "8.6"). -Notation Piter_op := Pos.iter_op (compat "8.6"). -Notation Piter_op_succ := Pos.iter_op_succ (compat "8.6"). +Notation Ppred := Pos.pred (compat "8.7"). +Notation Piter_op := Pos.iter_op (compat "8.7"). +Notation Piter_op_succ := Pos.iter_op_succ (compat "8.7"). Notation Pmult_nat := (Pos.iter_op plus) (only parsing). Notation nat_of_P := Pos.to_nat (only parsing). Notation P_of_succ_nat := Pos.of_succ_nat (only parsing). @@ -1922,29 +1922,29 @@ Notation positive_mask_rect := Pos.mask_rect (only parsing). Notation positive_mask_ind := Pos.mask_ind (only parsing). Notation positive_mask_rec := Pos.mask_rec (only parsing). Notation Pdouble_plus_one_mask := Pos.succ_double_mask (only parsing). -Notation Pdouble_mask := Pos.double_mask (compat "8.6"). +Notation Pdouble_mask := Pos.double_mask (compat "8.7"). Notation Pdouble_minus_two := Pos.double_pred_mask (only parsing). Notation Pminus_mask := Pos.sub_mask (only parsing). Notation Pminus_mask_carry := Pos.sub_mask_carry (only parsing). Notation Pminus := Pos.sub (only parsing). Notation Pmult := Pos.mul (only parsing). Notation iter_pos := @Pos.iter (only parsing). -Notation Ppow := Pos.pow (compat "8.6"). -Notation Pdiv2 := Pos.div2 (compat "8.6"). -Notation Pdiv2_up := Pos.div2_up (compat "8.6"). +Notation Ppow := Pos.pow (compat "8.7"). +Notation Pdiv2 := Pos.div2 (compat "8.7"). +Notation Pdiv2_up := Pos.div2_up (compat "8.7"). Notation Psize := Pos.size_nat (only parsing). Notation Psize_pos := Pos.size (only parsing). Notation Pcompare x y m := (Pos.compare_cont m x y) (only parsing). -Notation Plt := Pos.lt (compat "8.6"). -Notation Pgt := Pos.gt (compat "8.6"). -Notation Ple := Pos.le (compat "8.6"). -Notation Pge := Pos.ge (compat "8.6"). -Notation Pmin := Pos.min (compat "8.6"). -Notation Pmax := Pos.max (compat "8.6"). -Notation Peqb := Pos.eqb (compat "8.6"). +Notation Plt := Pos.lt (compat "8.7"). +Notation Pgt := Pos.gt (compat "8.7"). +Notation Ple := Pos.le (compat "8.7"). +Notation Pge := Pos.ge (compat "8.7"). +Notation Pmin := Pos.min (compat "8.7"). +Notation Pmax := Pos.max (compat "8.7"). +Notation Peqb := Pos.eqb (compat "8.7"). Notation positive_eq_dec := Pos.eq_dec (only parsing). Notation xI_succ_xO := Pos.xI_succ_xO (only parsing). -Notation Psucc_discr := Pos.succ_discr (compat "8.6"). +Notation Psucc_discr := Pos.succ_discr (compat "8.7"). Notation Psucc_o_double_minus_one_eq_xO := Pos.succ_pred_double (only parsing). Notation Pdouble_minus_one_o_succ_eq_xI := @@ -1953,9 +1953,9 @@ Notation xO_succ_permute := Pos.double_succ (only parsing). Notation double_moins_un_xO_discr := Pos.pred_double_xO_discr (only parsing). Notation Psucc_not_one := Pos.succ_not_1 (only parsing). -Notation Ppred_succ := Pos.pred_succ (compat "8.6"). +Notation Ppred_succ := Pos.pred_succ (compat "8.7"). Notation Psucc_pred := Pos.succ_pred_or (only parsing). -Notation Psucc_inj := Pos.succ_inj (compat "8.6"). +Notation Psucc_inj := Pos.succ_inj (compat "8.7"). Notation Pplus_carry_spec := Pos.add_carry_spec (only parsing). Notation Pplus_comm := Pos.add_comm (only parsing). Notation Pplus_succ_permute_r := Pos.add_succ_r (only parsing). @@ -2002,17 +2002,17 @@ Notation Pmult_xO_discr := Pos.mul_xO_discr (only parsing). Notation Pmult_reg_r := Pos.mul_reg_r (only parsing). Notation Pmult_reg_l := Pos.mul_reg_l (only parsing). Notation Pmult_1_inversion_l := Pos.mul_eq_1_l (only parsing). -Notation Psquare_xO := Pos.square_xO (compat "8.6"). -Notation Psquare_xI := Pos.square_xI (compat "8.6"). +Notation Psquare_xO := Pos.square_xO (compat "8.7"). +Notation Psquare_xI := Pos.square_xI (compat "8.7"). Notation iter_pos_swap_gen := Pos.iter_swap_gen (only parsing). Notation iter_pos_swap := Pos.iter_swap (only parsing). Notation iter_pos_succ := Pos.iter_succ (only parsing). Notation iter_pos_plus := Pos.iter_add (only parsing). Notation iter_pos_invariant := Pos.iter_invariant (only parsing). -Notation Ppow_1_r := Pos.pow_1_r (compat "8.6"). -Notation Ppow_succ_r := Pos.pow_succ_r (compat "8.6"). -Notation Peqb_refl := Pos.eqb_refl (compat "8.6"). -Notation Peqb_eq := Pos.eqb_eq (compat "8.6"). +Notation Ppow_1_r := Pos.pow_1_r (compat "8.7"). +Notation Ppow_succ_r := Pos.pow_succ_r (compat "8.7"). +Notation Peqb_refl := Pos.eqb_refl (compat "8.7"). +Notation Peqb_eq := Pos.eqb_eq (compat "8.7"). Notation Pcompare_refl_id := Pos.compare_cont_refl (only parsing). Notation Pcompare_eq_iff := Pos.compare_eq_iff (only parsing). Notation Pcompare_Gt_Lt := Pos.compare_cont_Gt_Lt (only parsing). @@ -2022,23 +2022,23 @@ Notation Pcompare_Lt_Gt := Pos.compare_cont_Lt_Gt (only parsing). Notation Pcompare_antisym := Pos.compare_cont_antisym (only parsing). Notation ZC1 := Pos.gt_lt (only parsing). Notation ZC2 := Pos.lt_gt (only parsing). -Notation Pcompare_spec := Pos.compare_spec (compat "8.6"). +Notation Pcompare_spec := Pos.compare_spec (compat "8.7"). Notation Pcompare_p_Sp := Pos.lt_succ_diag_r (only parsing). -Notation Pcompare_succ_succ := Pos.compare_succ_succ (compat "8.6"). +Notation Pcompare_succ_succ := Pos.compare_succ_succ (compat "8.7"). Notation Pcompare_1 := Pos.nlt_1_r (only parsing). Notation Plt_1 := Pos.nlt_1_r (only parsing). -Notation Plt_1_succ := Pos.lt_1_succ (compat "8.6"). -Notation Plt_lt_succ := Pos.lt_lt_succ (compat "8.6"). -Notation Plt_irrefl := Pos.lt_irrefl (compat "8.6"). -Notation Plt_trans := Pos.lt_trans (compat "8.6"). -Notation Plt_ind := Pos.lt_ind (compat "8.6"). -Notation Ple_lteq := Pos.le_lteq (compat "8.6"). -Notation Ple_refl := Pos.le_refl (compat "8.6"). -Notation Ple_lt_trans := Pos.le_lt_trans (compat "8.6"). -Notation Plt_le_trans := Pos.lt_le_trans (compat "8.6"). -Notation Ple_trans := Pos.le_trans (compat "8.6"). -Notation Plt_succ_r := Pos.lt_succ_r (compat "8.6"). -Notation Ple_succ_l := Pos.le_succ_l (compat "8.6"). +Notation Plt_1_succ := Pos.lt_1_succ (compat "8.7"). +Notation Plt_lt_succ := Pos.lt_lt_succ (compat "8.7"). +Notation Plt_irrefl := Pos.lt_irrefl (compat "8.7"). +Notation Plt_trans := Pos.lt_trans (compat "8.7"). +Notation Plt_ind := Pos.lt_ind (compat "8.7"). +Notation Ple_lteq := Pos.le_lteq (compat "8.7"). +Notation Ple_refl := Pos.le_refl (compat "8.7"). +Notation Ple_lt_trans := Pos.le_lt_trans (compat "8.7"). +Notation Plt_le_trans := Pos.lt_le_trans (compat "8.7"). +Notation Ple_trans := Pos.le_trans (compat "8.7"). +Notation Plt_succ_r := Pos.lt_succ_r (compat "8.7"). +Notation Ple_succ_l := Pos.le_succ_l (compat "8.7"). Notation Pplus_compare_mono_l := Pos.add_compare_mono_l (only parsing). Notation Pplus_compare_mono_r := Pos.add_compare_mono_r (only parsing). Notation Pplus_lt_mono_l := Pos.add_lt_mono_l (only parsing). @@ -2057,8 +2057,8 @@ Notation Pmult_le_mono_r := Pos.mul_le_mono_r (only parsing). Notation Pmult_le_mono := Pos.mul_le_mono (only parsing). Notation Plt_plus_r := Pos.lt_add_r (only parsing). Notation Plt_not_plus_l := Pos.lt_not_add_l (only parsing). -Notation Ppow_gt_1 := Pos.pow_gt_1 (compat "8.6"). -Notation Ppred_mask := Pos.pred_mask (compat "8.6"). +Notation Ppow_gt_1 := Pos.pow_gt_1 (compat "8.7"). +Notation Ppred_mask := Pos.pred_mask (compat "8.7"). Notation Pminus_mask_succ_r := Pos.sub_mask_succ_r (only parsing). Notation Pminus_mask_carry_spec := Pos.sub_mask_carry_spec (only parsing). Notation Pminus_succ_r := Pos.sub_succ_r (only parsing). diff --git a/theories/ZArith/BinInt.v b/theories/ZArith/BinInt.v index a11d491a8b..1241345338 100644 --- a/theories/ZArith/BinInt.v +++ b/theories/ZArith/BinInt.v @@ -1571,40 +1571,40 @@ End Z2Pos. Notation Zdouble_plus_one := Z.succ_double (only parsing). Notation Zdouble_minus_one := Z.pred_double (only parsing). -Notation Zdouble := Z.double (compat "8.6"). +Notation Zdouble := Z.double (compat "8.7"). Notation ZPminus := Z.pos_sub (only parsing). -Notation Zsucc' := Z.succ (compat "8.6"). -Notation Zpred' := Z.pred (compat "8.6"). -Notation Zplus' := Z.add (compat "8.6"). +Notation Zsucc' := Z.succ (compat "8.7"). +Notation Zpred' := Z.pred (compat "8.7"). +Notation Zplus' := Z.add (compat "8.7"). Notation Zplus := Z.add (only parsing). (* Slightly incompatible *) -Notation Zopp := Z.opp (compat "8.6"). -Notation Zsucc := Z.succ (compat "8.6"). -Notation Zpred := Z.pred (compat "8.6"). +Notation Zopp := Z.opp (compat "8.7"). +Notation Zsucc := Z.succ (compat "8.7"). +Notation Zpred := Z.pred (compat "8.7"). Notation Zminus := Z.sub (only parsing). Notation Zmult := Z.mul (only parsing). -Notation Zcompare := Z.compare (compat "8.6"). -Notation Zsgn := Z.sgn (compat "8.6"). -Notation Zle := Z.le (compat "8.6"). -Notation Zge := Z.ge (compat "8.6"). -Notation Zlt := Z.lt (compat "8.6"). -Notation Zgt := Z.gt (compat "8.6"). -Notation Zmax := Z.max (compat "8.6"). -Notation Zmin := Z.min (compat "8.6"). -Notation Zabs := Z.abs (compat "8.6"). -Notation Zabs_nat := Z.abs_nat (compat "8.6"). -Notation Zabs_N := Z.abs_N (compat "8.6"). +Notation Zcompare := Z.compare (compat "8.7"). +Notation Zsgn := Z.sgn (compat "8.7"). +Notation Zle := Z.le (compat "8.7"). +Notation Zge := Z.ge (compat "8.7"). +Notation Zlt := Z.lt (compat "8.7"). +Notation Zgt := Z.gt (compat "8.7"). +Notation Zmax := Z.max (compat "8.7"). +Notation Zmin := Z.min (compat "8.7"). +Notation Zabs := Z.abs (compat "8.7"). +Notation Zabs_nat := Z.abs_nat (compat "8.7"). +Notation Zabs_N := Z.abs_N (compat "8.7"). Notation Z_of_nat := Z.of_nat (only parsing). Notation Z_of_N := Z.of_N (only parsing). Notation Zind := Z.peano_ind (only parsing). -Notation Zopp_0 := Z.opp_0 (compat "8.6"). -Notation Zopp_involutive := Z.opp_involutive (compat "8.6"). -Notation Zopp_inj := Z.opp_inj (compat "8.6"). +Notation Zopp_0 := Z.opp_0 (compat "8.7"). +Notation Zopp_involutive := Z.opp_involutive (compat "8.7"). +Notation Zopp_inj := Z.opp_inj (compat "8.7"). Notation Zplus_0_l := Z.add_0_l (only parsing). Notation Zplus_0_r := Z.add_0_r (only parsing). Notation Zplus_comm := Z.add_comm (only parsing). Notation Zopp_plus_distr := Z.opp_add_distr (only parsing). -Notation Zopp_succ := Z.opp_succ (compat "8.6"). +Notation Zopp_succ := Z.opp_succ (compat "8.7"). Notation Zplus_opp_r := Z.add_opp_diag_r (only parsing). Notation Zplus_opp_l := Z.add_opp_diag_l (only parsing). Notation Zplus_assoc := Z.add_assoc (only parsing). @@ -1613,11 +1613,11 @@ Notation Zplus_reg_l := Z.add_reg_l (only parsing). Notation Zplus_succ_l := Z.add_succ_l (only parsing). Notation Zplus_succ_comm := Z.add_succ_comm (only parsing). Notation Zsucc_discr := Z.neq_succ_diag_r (only parsing). -Notation Zsucc_inj := Z.succ_inj (compat "8.6"). -Notation Zsucc'_inj := Z.succ_inj (compat "8.6"). -Notation Zsucc'_pred' := Z.succ_pred (compat "8.6"). -Notation Zpred'_succ' := Z.pred_succ (compat "8.6"). -Notation Zpred'_inj := Z.pred_inj (compat "8.6"). +Notation Zsucc_inj := Z.succ_inj (compat "8.7"). +Notation Zsucc'_inj := Z.succ_inj (compat "8.7"). +Notation Zsucc'_pred' := Z.succ_pred (compat "8.7"). +Notation Zpred'_succ' := Z.pred_succ (compat "8.7"). +Notation Zpred'_inj := Z.pred_inj (compat "8.7"). Notation Zsucc'_discr := Z.neq_succ_diag_r (only parsing). Notation Zminus_0_r := Z.sub_0_r (only parsing). Notation Zminus_diag := Z.sub_diag (only parsing). diff --git a/theories/ZArith/ZArith_dec.v b/theories/ZArith/ZArith_dec.v index 9bcdb73afa..6cadf30f85 100644 --- a/theories/ZArith/ZArith_dec.v +++ b/theories/ZArith/ZArith_dec.v @@ -34,7 +34,7 @@ Lemma Zcompare_rec (P:Set) (n m:Z) : ((n ?= m) = Eq -> P) -> ((n ?= m) = Lt -> P) -> ((n ?= m) = Gt -> P) -> P. Proof. apply Zcompare_rect. Defined. -Notation Z_eq_dec := Z.eq_dec (compat "8.6"). +Notation Z_eq_dec := Z.eq_dec (compat "8.7"). Section decidability. diff --git a/theories/ZArith/Zabs.v b/theories/ZArith/Zabs.v index 0d8450e36b..057eb49965 100644 --- a/theories/ZArith/Zabs.v +++ b/theories/ZArith/Zabs.v @@ -29,17 +29,17 @@ Local Open Scope Z_scope. (**********************************************************************) (** * Properties of absolute value *) -Notation Zabs_eq := Z.abs_eq (compat "8.6"). +Notation Zabs_eq := Z.abs_eq (compat "8.7"). Notation Zabs_non_eq := Z.abs_neq (only parsing). Notation Zabs_Zopp := Z.abs_opp (only parsing). Notation Zabs_pos := Z.abs_nonneg (only parsing). -Notation Zabs_involutive := Z.abs_involutive (compat "8.6"). +Notation Zabs_involutive := Z.abs_involutive (compat "8.7"). Notation Zabs_eq_case := Z.abs_eq_cases (only parsing). -Notation Zabs_triangle := Z.abs_triangle (compat "8.6"). +Notation Zabs_triangle := Z.abs_triangle (compat "8.7"). Notation Zsgn_Zabs := Z.sgn_abs (only parsing). Notation Zabs_Zsgn := Z.abs_sgn (only parsing). Notation Zabs_Zmult := Z.abs_mul (only parsing). -Notation Zabs_square := Z.abs_square (compat "8.6"). +Notation Zabs_square := Z.abs_square (compat "8.7"). (** * Proving a property of the absolute value by cases *) diff --git a/theories/ZArith/Zcompare.v b/theories/ZArith/Zcompare.v index c8432e27bb..6ccb0153de 100644 --- a/theories/ZArith/Zcompare.v +++ b/theories/ZArith/Zcompare.v @@ -183,15 +183,15 @@ Qed. (** Compatibility notations *) -Notation Zcompare_refl := Z.compare_refl (compat "8.6"). +Notation Zcompare_refl := Z.compare_refl (compat "8.7"). Notation Zcompare_Eq_eq := Z.compare_eq (only parsing). Notation Zcompare_Eq_iff_eq := Z.compare_eq_iff (only parsing). -Notation Zcompare_spec := Z.compare_spec (compat "8.6"). -Notation Zmin_l := Z.min_l (compat "8.6"). -Notation Zmin_r := Z.min_r (compat "8.6"). -Notation Zmax_l := Z.max_l (compat "8.6"). -Notation Zmax_r := Z.max_r (compat "8.6"). -Notation Zabs_eq := Z.abs_eq (compat "8.6"). +Notation Zcompare_spec := Z.compare_spec (compat "8.7"). +Notation Zmin_l := Z.min_l (compat "8.7"). +Notation Zmin_r := Z.min_r (compat "8.7"). +Notation Zmax_l := Z.max_l (compat "8.7"). +Notation Zmax_r := Z.max_r (compat "8.7"). +Notation Zabs_eq := Z.abs_eq (compat "8.7"). Notation Zabs_non_eq := Z.abs_neq (only parsing). Notation Zsgn_0 := Z.sgn_null (only parsing). Notation Zsgn_1 := Z.sgn_pos (only parsing). diff --git a/theories/ZArith/Zdiv.v b/theories/ZArith/Zdiv.v index 15d0e48747..74614e114a 100644 --- a/theories/ZArith/Zdiv.v +++ b/theories/ZArith/Zdiv.v @@ -21,11 +21,11 @@ Local Open Scope Z_scope. specifications and properties are in [BinInt]. *) Notation Zdiv_eucl_POS := Z.pos_div_eucl (only parsing). -Notation Zdiv_eucl := Z.div_eucl (compat "8.6"). -Notation Zdiv := Z.div (compat "8.6"). +Notation Zdiv_eucl := Z.div_eucl (compat "8.7"). +Notation Zdiv := Z.div (compat "8.7"). Notation Zmod := Z.modulo (only parsing). -Notation Zdiv_eucl_eq := Z.div_eucl_eq (compat "8.6"). +Notation Zdiv_eucl_eq := Z.div_eucl_eq (compat "8.7"). Notation Z_div_mod_eq_full := Z.div_mod (only parsing). Notation Zmod_POS_bound := Z.pos_div_eucl_bound (only parsing). Notation Zmod_pos_bound := Z.mod_pos_bound (only parsing). diff --git a/theories/ZArith/Zeven.v b/theories/ZArith/Zeven.v index 00a58b517e..9e83bfc136 100644 --- a/theories/ZArith/Zeven.v +++ b/theories/ZArith/Zeven.v @@ -141,8 +141,8 @@ Notation Zodd_bool_pred := Z.odd_pred (only parsing). (** * Definition of [Z.quot2], [Z.div2] and properties wrt [Zeven] and [Zodd] *) -Notation Zdiv2 := Z.div2 (compat "8.6"). -Notation Zquot2 := Z.quot2 (compat "8.6"). +Notation Zdiv2 := Z.div2 (compat "8.7"). +Notation Zquot2 := Z.quot2 (compat "8.7"). (** Properties of [Z.div2] *) diff --git a/theories/ZArith/Zmax.v b/theories/ZArith/Zmax.v index 7f595fcfd0..26bd9e8171 100644 --- a/theories/ZArith/Zmax.v +++ b/theories/ZArith/Zmax.v @@ -18,22 +18,22 @@ Local Open Scope Z_scope. (** Exact compatibility *) -Notation Zmax_case := Z.max_case (compat "8.6"). -Notation Zmax_case_strong := Z.max_case_strong (compat "8.6"). +Notation Zmax_case := Z.max_case (compat "8.7"). +Notation Zmax_case_strong := Z.max_case_strong (compat "8.7"). Notation Zmax_right := Z.max_r (only parsing). -Notation Zle_max_l := Z.le_max_l (compat "8.6"). -Notation Zle_max_r := Z.le_max_r (compat "8.6"). -Notation Zmax_lub := Z.max_lub (compat "8.6"). -Notation Zmax_lub_lt := Z.max_lub_lt (compat "8.6"). +Notation Zle_max_l := Z.le_max_l (compat "8.7"). +Notation Zle_max_r := Z.le_max_r (compat "8.7"). +Notation Zmax_lub := Z.max_lub (compat "8.7"). +Notation Zmax_lub_lt := Z.max_lub_lt (compat "8.7"). Notation Zle_max_compat_r := Z.max_le_compat_r (only parsing). Notation Zle_max_compat_l := Z.max_le_compat_l (only parsing). Notation Zmax_idempotent := Z.max_id (only parsing). Notation Zmax_n_n := Z.max_id (only parsing). -Notation Zmax_comm := Z.max_comm (compat "8.6"). -Notation Zmax_assoc := Z.max_assoc (compat "8.6"). +Notation Zmax_comm := Z.max_comm (compat "8.7"). +Notation Zmax_assoc := Z.max_assoc (compat "8.7"). Notation Zmax_irreducible_dec := Z.max_dec (only parsing). Notation Zmax_le_prime := Z.max_le (only parsing). -Notation Zsucc_max_distr := Z.succ_max_distr (compat "8.6"). +Notation Zsucc_max_distr := Z.succ_max_distr (compat "8.7"). Notation Zmax_SS := Z.succ_max_distr (only parsing). Notation Zplus_max_distr_l := Z.add_max_distr_l (only parsing). Notation Zplus_max_distr_r := Z.add_max_distr_r (only parsing). diff --git a/theories/ZArith/Zmin.v b/theories/ZArith/Zmin.v index 6bc72227b2..5509ee7865 100644 --- a/theories/ZArith/Zmin.v +++ b/theories/ZArith/Zmin.v @@ -18,20 +18,20 @@ Local Open Scope Z_scope. (** Exact compatibility *) -Notation Zmin_case := Z.min_case (compat "8.6"). -Notation Zmin_case_strong := Z.min_case_strong (compat "8.6"). -Notation Zle_min_l := Z.le_min_l (compat "8.6"). -Notation Zle_min_r := Z.le_min_r (compat "8.6"). -Notation Zmin_glb := Z.min_glb (compat "8.6"). -Notation Zmin_glb_lt := Z.min_glb_lt (compat "8.6"). +Notation Zmin_case := Z.min_case (compat "8.7"). +Notation Zmin_case_strong := Z.min_case_strong (compat "8.7"). +Notation Zle_min_l := Z.le_min_l (compat "8.7"). +Notation Zle_min_r := Z.le_min_r (compat "8.7"). +Notation Zmin_glb := Z.min_glb (compat "8.7"). +Notation Zmin_glb_lt := Z.min_glb_lt (compat "8.7"). Notation Zle_min_compat_r := Z.min_le_compat_r (only parsing). Notation Zle_min_compat_l := Z.min_le_compat_l (only parsing). Notation Zmin_idempotent := Z.min_id (only parsing). Notation Zmin_n_n := Z.min_id (only parsing). -Notation Zmin_comm := Z.min_comm (compat "8.6"). -Notation Zmin_assoc := Z.min_assoc (compat "8.6"). +Notation Zmin_comm := Z.min_comm (compat "8.7"). +Notation Zmin_assoc := Z.min_assoc (compat "8.7"). Notation Zmin_irreducible_inf := Z.min_dec (only parsing). -Notation Zsucc_min_distr := Z.succ_min_distr (compat "8.6"). +Notation Zsucc_min_distr := Z.succ_min_distr (compat "8.7"). Notation Zmin_SS := Z.succ_min_distr (only parsing). Notation Zplus_min_distr_r := Z.add_min_distr_r (only parsing). Notation Zmin_plus := Z.add_min_distr_r (only parsing). diff --git a/theories/ZArith/Znumtheory.v b/theories/ZArith/Znumtheory.v index f5444c31d7..e6066d53f9 100644 --- a/theories/ZArith/Znumtheory.v +++ b/theories/ZArith/Znumtheory.v @@ -27,20 +27,20 @@ Open Scope Z_scope. - properties of the efficient [Z.gcd] function *) -Notation Zgcd := Z.gcd (compat "8.6"). -Notation Zggcd := Z.ggcd (compat "8.6"). -Notation Zggcd_gcd := Z.ggcd_gcd (compat "8.6"). -Notation Zggcd_correct_divisors := Z.ggcd_correct_divisors (compat "8.6"). -Notation Zgcd_divide_l := Z.gcd_divide_l (compat "8.6"). -Notation Zgcd_divide_r := Z.gcd_divide_r (compat "8.6"). -Notation Zgcd_greatest := Z.gcd_greatest (compat "8.6"). -Notation Zgcd_nonneg := Z.gcd_nonneg (compat "8.6"). -Notation Zggcd_opp := Z.ggcd_opp (compat "8.6"). +Notation Zgcd := Z.gcd (compat "8.7"). +Notation Zggcd := Z.ggcd (compat "8.7"). +Notation Zggcd_gcd := Z.ggcd_gcd (compat "8.7"). +Notation Zggcd_correct_divisors := Z.ggcd_correct_divisors (compat "8.7"). +Notation Zgcd_divide_l := Z.gcd_divide_l (compat "8.7"). +Notation Zgcd_divide_r := Z.gcd_divide_r (compat "8.7"). +Notation Zgcd_greatest := Z.gcd_greatest (compat "8.7"). +Notation Zgcd_nonneg := Z.gcd_nonneg (compat "8.7"). +Notation Zggcd_opp := Z.ggcd_opp (compat "8.7"). (** The former specialized inductive predicate [Z.divide] is now a generic existential predicate. *) -Notation Zdivide := Z.divide (compat "8.6"). +Notation Zdivide := Z.divide (compat "8.7"). (** Its former constructor is now a pseudo-constructor. *) @@ -48,7 +48,7 @@ Definition Zdivide_intro a b q (H:b=q*a) : Z.divide a b := ex_intro _ q H. (** Results concerning divisibility*) -Notation Zdivide_refl := Z.divide_refl (compat "8.6"). +Notation Zdivide_refl := Z.divide_refl (compat "8.7"). Notation Zone_divide := Z.divide_1_l (only parsing). Notation Zdivide_0 := Z.divide_0_r (only parsing). Notation Zmult_divide_compat_l := Z.mul_divide_mono_l (only parsing). @@ -97,8 +97,8 @@ Notation Zdivide_1 := Z.divide_1_r (only parsing). (** If [a] divides [b] and [b] divides [a] then [a] is [b] or [-b]. *) -Notation Zdivide_antisym := Z.divide_antisym (compat "8.6"). -Notation Zdivide_trans := Z.divide_trans (compat "8.6"). +Notation Zdivide_antisym := Z.divide_antisym (compat "8.7"). +Notation Zdivide_trans := Z.divide_trans (compat "8.7"). (** If [a] divides [b] and [b<>0] then [|a| <= |b|]. *) @@ -800,7 +800,7 @@ Proof. rewrite <- Zdivide_Zdiv_eq; auto. Qed. -Notation Zgcd_comm := Z.gcd_comm (compat "8.6"). +Notation Zgcd_comm := Z.gcd_comm (compat "8.7"). Lemma Zgcd_ass a b c : Z.gcd (Z.gcd a b) c = Z.gcd a (Z.gcd b c). Proof. diff --git a/theories/ZArith/Zorder.v b/theories/ZArith/Zorder.v index a1ec4b35e0..208e84aeb7 100644 --- a/theories/ZArith/Zorder.v +++ b/theories/ZArith/Zorder.v @@ -66,10 +66,10 @@ Qed. (** * Relating strict and large orders *) -Notation Zgt_lt := Z.gt_lt (compat "8.6"). -Notation Zlt_gt := Z.lt_gt (compat "8.6"). -Notation Zge_le := Z.ge_le (compat "8.6"). -Notation Zle_ge := Z.le_ge (compat "8.6"). +Notation Zgt_lt := Z.gt_lt (compat "8.7"). +Notation Zlt_gt := Z.lt_gt (compat "8.7"). +Notation Zge_le := Z.ge_le (compat "8.7"). +Notation Zle_ge := Z.le_ge (compat "8.7"). Notation Zgt_iff_lt := Z.gt_lt_iff (only parsing). Notation Zge_iff_le := Z.ge_le_iff (only parsing). @@ -123,7 +123,7 @@ Qed. (** Reflexivity *) -Notation Zle_refl := Z.le_refl (compat "8.6"). +Notation Zle_refl := Z.le_refl (compat "8.7"). Notation Zeq_le := Z.eq_le_incl (only parsing). Hint Resolve Z.le_refl: zarith. @@ -143,7 +143,7 @@ Qed. (** Irreflexivity *) -Notation Zlt_irrefl := Z.lt_irrefl (compat "8.6"). +Notation Zlt_irrefl := Z.lt_irrefl (compat "8.7"). Notation Zlt_not_eq := Z.lt_neq (only parsing). Lemma Zgt_irrefl n : ~ n > n. @@ -167,7 +167,7 @@ Notation Zle_or_lt := Z.le_gt_cases (only parsing). (** Transitivity of strict orders *) -Notation Zlt_trans := Z.lt_trans (compat "8.6"). +Notation Zlt_trans := Z.lt_trans (compat "8.7"). Lemma Zgt_trans n m p : n > m -> m > p -> n > p. Proof. @@ -176,8 +176,8 @@ Qed. (** Mixed transitivity *) -Notation Zlt_le_trans := Z.lt_le_trans (compat "8.6"). -Notation Zle_lt_trans := Z.le_lt_trans (compat "8.6"). +Notation Zlt_le_trans := Z.lt_le_trans (compat "8.7"). +Notation Zle_lt_trans := Z.le_lt_trans (compat "8.7"). Lemma Zle_gt_trans n m p : m <= n -> m > p -> n > p. Proof. @@ -191,7 +191,7 @@ Qed. (** Transitivity of large orders *) -Notation Zle_trans := Z.le_trans (compat "8.6"). +Notation Zle_trans := Z.le_trans (compat "8.7"). Lemma Zge_trans n m p : n >= m -> m >= p -> n >= p. Proof. @@ -257,8 +257,8 @@ Qed. (** Relating strict and large order using successor or predecessor *) -Notation Zlt_succ_r := Z.lt_succ_r (compat "8.6"). -Notation Zle_succ_l := Z.le_succ_l (compat "8.6"). +Notation Zlt_succ_r := Z.lt_succ_r (compat "8.7"). +Notation Zle_succ_l := Z.le_succ_l (compat "8.7"). Lemma Zgt_le_succ n m : m > n -> Z.succ n <= m. Proof. @@ -336,8 +336,8 @@ Qed. (** Special cases of ordered integers *) -Notation Zlt_0_1 := Z.lt_0_1 (compat "8.6"). -Notation Zle_0_1 := Z.le_0_1 (compat "8.6"). +Notation Zlt_0_1 := Z.lt_0_1 (compat "8.7"). +Notation Zle_0_1 := Z.le_0_1 (compat "8.7"). Lemma Zle_neg_pos : forall p q:positive, Zneg p <= Zpos q. Proof. diff --git a/theories/ZArith/Zpow_facts.v b/theories/ZArith/Zpow_facts.v index a9bc5bd09d..881ead1c4b 100644 --- a/theories/ZArith/Zpow_facts.v +++ b/theories/ZArith/Zpow_facts.v @@ -233,7 +233,7 @@ Qed. (** * Z.square: a direct definition of [z^2] *) -Notation Psquare := Pos.square (compat "8.6"). -Notation Zsquare := Z.square (compat "8.6"). +Notation Psquare := Pos.square (compat "8.7"). +Notation Zsquare := Z.square (compat "8.7"). Notation Psquare_correct := Pos.square_spec (only parsing). Notation Zsquare_correct := Z.square_spec (only parsing). diff --git a/theories/ZArith/Zquot.v b/theories/ZArith/Zquot.v index 0c9aca2657..264109dc6f 100644 --- a/theories/ZArith/Zquot.v +++ b/theories/ZArith/Zquot.v @@ -37,17 +37,17 @@ Notation Ndiv_Zquot := N2Z.inj_quot (only parsing). Notation Nmod_Zrem := N2Z.inj_rem (only parsing). Notation Z_quot_rem_eq := Z.quot_rem' (only parsing). Notation Zrem_lt := Z.rem_bound_abs (only parsing). -Notation Zquot_unique := Z.quot_unique (compat "8.6"). -Notation Zrem_unique := Z.rem_unique (compat "8.6"). -Notation Zrem_1_r := Z.rem_1_r (compat "8.6"). -Notation Zquot_1_r := Z.quot_1_r (compat "8.6"). -Notation Zrem_1_l := Z.rem_1_l (compat "8.6"). -Notation Zquot_1_l := Z.quot_1_l (compat "8.6"). -Notation Z_quot_same := Z.quot_same (compat "8.6"). +Notation Zquot_unique := Z.quot_unique (compat "8.7"). +Notation Zrem_unique := Z.rem_unique (compat "8.7"). +Notation Zrem_1_r := Z.rem_1_r (compat "8.7"). +Notation Zquot_1_r := Z.quot_1_r (compat "8.7"). +Notation Zrem_1_l := Z.rem_1_l (compat "8.7"). +Notation Zquot_1_l := Z.quot_1_l (compat "8.7"). +Notation Z_quot_same := Z.quot_same (compat "8.7"). Notation Z_quot_mult := Z.quot_mul (only parsing). -Notation Zquot_small := Z.quot_small (compat "8.6"). -Notation Zrem_small := Z.rem_small (compat "8.6"). -Notation Zquot2_quot := Zquot2_quot (compat "8.6"). +Notation Zquot_small := Z.quot_small (compat "8.7"). +Notation Zrem_small := Z.rem_small (compat "8.7"). +Notation Zquot2_quot := Zquot2_quot (compat "8.7"). (** Particular values taken for [a÷0] and [(Z.rem a 0)]. We avise to not rely on these arbitrary values. *) diff --git a/tools/README.emacs b/tools/README.emacs deleted file mode 100644 index 4d8e3697a0..0000000000 --- a/tools/README.emacs +++ /dev/null @@ -1,31 +0,0 @@ - -DESCRIPTION: - -An emacs mode to help editing Coq vernacular files. - -AUTHOR: - -Jean-Christophe Filliatre (jcfillia@lri.fr), - from the Caml mode of Xavier Leroy. - -CONTENTS: - - gallina.el A major mode for editing Coq files in Gnu Emacs - -USAGE: - -Add the following lines to your .emacs file: - -(setq auto-mode-alist (cons '("\\.v$" . coq-mode) auto-mode-alist)) -(autoload 'coq-mode "gallina" "Major mode for editing Coq vernacular." t) - -The Coq major mode is triggered by visiting a file with extension .v, -or manually by M-x coq-mode. It gives you the correct syntax table for -the Coq language, and also a rudimentary indentation facility: - -- pressing TAB at the beginning of a line indents the line like the line above - -- extra TABs increase the indentation level (by 2 spaces by default) - -- M-TAB decreases the indentation level. - diff --git a/tools/check-translate b/tools/check-translate deleted file mode 100755 index acb6f45903..0000000000 --- a/tools/check-translate +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -echo -------------- Producing translated files --------------------- -rm */*/*.v8 >& /dev/null -make COQOPTS=-translate theories || { echo ---- Failed to translate; exit 1; } -if [ -e translated ]; then rm -r translated; fi -if [ -e successful-translation ]; then rm -r successful-translation; fi -if [ -e failed-translation ]; then rm -r failed-translation; fi -mv theories translated -mkdir theories -echo -------------------- Upgrading files -------------------------- -cd translated -for i in */*.v -do - mkdir ../theories/`dirname $i` >& /dev/null - mv "$i"8 ../theories/$i -done -cd .. -echo --------------- Recompiling translated files ------------------ -make theories || { echo ---- Failed to recompile; mv theories failed-translation; mv translated theories; exit 1; } -echo ----------------- Recompilation successful -------------------- -if [ -e successful-translation ]; then rm -r successful-translation; fi -mv theories successful-translation; mv translated theories diff --git a/tools/coq-sl.sty b/tools/coq-sl.sty deleted file mode 100644 index 9f6e5480c9..0000000000 --- a/tools/coq-sl.sty +++ /dev/null @@ -1,37 +0,0 @@ -% COQ style option, for use with the coq-latex filter. - -\typeout{Document Style option `coq-sl' <7 Apr 92>.} - -\ifcase\@ptsize - \font\sltt = cmsltt10 -\or \font\sltt = cmsltt10 \@halfmag -\or \font\sltt = cmsltt10 \@magscale1 -\fi - -{\catcode`\^^M=\active % - \gdef\@coqinputline#1^^M{\tt Coq < #1\par} % - \gdef\@coqoutputline#1^^M{\sltt#1\par} } % -\def\@coqblankline{\medskip} -\chardef\@coqbackslash="5C - -\def\coq{ - \bgroup - \flushleft - \parindent 0pt - \parskip 0pt - \let\do\@makeother\dospecials - \catcode`\^^M=\active - \catcode`\\=0 - \catcode`\ \active - \frenchspacing - \@vobeyspaces - \let\?\@coqinputline - \let\:\@coqoutputline - \let\;\@coqblankline - \let\\\@coqbackslash -} - -\def\endcoq{ - \endflushleft - \egroup\noindent -} diff --git a/tools/coq_dune.ml b/tools/coq_dune.ml index ab60920fbc..691f37b414 100644 --- a/tools/coq_dune.ml +++ b/tools/coq_dune.ml @@ -92,41 +92,6 @@ module Aux = struct | None -> DirMap.remove key map | Some x -> DirMap.add key x map - (* Available in OCaml >= 4.04 *) - let split_on_char sep s = - let open String in - let r = ref [] in - let j = ref (length s) in - for i = length s - 1 downto 0 do - if unsafe_get s i = sep then begin - r := sub s (i + 1) (!j - i - 1) :: !r; - j := i - end - done; - sub s 0 !j :: !r - - (* Available in OCaml >= 4.04 *) - let is_dir_sep = match Sys.os_type with - | "Win32" -> fun s i -> s.[i] = '\\' - | _ -> fun s i -> s.[i] = '/' - - let extension_len name = - let rec check i0 i = - if i < 0 || is_dir_sep name i then 0 - else if name.[i] = '.' then check i0 (i - 1) - else String.length name - i0 - in - let rec search_dot i = - if i < 0 || is_dir_sep name i then 0 - else if name.[i] = '.' then check i (i - 1) - else search_dot (i - 1) - in - search_dot (String.length name - 1) - - let remove_extension name = - let l = extension_len name in - if l = 0 then name else String.sub name 0 (String.length name - l) - end let add_map_list key elem map = @@ -205,18 +170,18 @@ let pp_vo_dep dir fmt vo = (* Correct path from global to local "theories/Init/Decimal.vo" -> "../../theories/Init/Decimal.vo" *) let deps = List.map (fun s -> sdir ^ s) (edep @ vo.deps) in (* The source file is also corrected as we will call coqtop from the top dir *) - let source = String.concat "/" dir ^ "/" ^ Legacy.(remove_extension vo.target) ^ ".v" in + let source = String.concat "/" dir ^ "/" ^ Filename.(remove_extension vo.target) ^ ".v" in (* The final build rule *) let action = sprintf "(chdir %%{project_root} (run coqtop -boot %s %s -compile %s))" eflag cflag source in pp_rule fmt [vo.target] deps action let pp_ml4_dep _dir fmt ml = - let target = Legacy.(remove_extension ml) ^ ".ml" in + let target = Filename.(remove_extension ml) ^ ".ml" in let ml4_rule = "(run coqp5 -loc loc -impl %{pp-file} -o %{targets})" in pp_rule fmt [target] [ml] ml4_rule let pp_mlg_dep _dir fmt ml = - let target = Legacy.(remove_extension ml) ^ ".ml" in + let target = Filename.(remove_extension ml) ^ ".ml" in let ml4_rule = "(run coqpp %{pp-file})" in pp_rule fmt [target] [ml] ml4_rule @@ -274,7 +239,7 @@ let parse_coqdep_line l = begin match targets with | [target] -> let dir, target = Filename.(dirname target, basename target) in - Some (Legacy.split_on_char '/' dir, VO { target; deps; }) + Some (String.split_on_char '/' dir, VO { target; deps; }) (* Otherwise a vio file, we ignore *) | _ -> None end diff --git a/tools/coqdep.ml b/tools/coqdep.ml index 7db0b28908..ba88069be9 100644 --- a/tools/coqdep.ml +++ b/tools/coqdep.ml @@ -496,7 +496,7 @@ let rec parse = function | "-dumpgraphbox" :: f :: ll -> option_dump := Some (true, f); parse ll | "-exclude-dir" :: r :: ll -> System.exclude_directory r; parse ll | "-exclude-dir" :: [] -> usage () - | "-coqlib" :: r :: ll -> Flags.coqlib_spec := true; Flags.coqlib := r; parse ll + | "-coqlib" :: r :: ll -> Envars.set_user_coqlib r; parse ll | "-coqlib" :: [] -> usage () | "-suffix" :: s :: ll -> suffixe := s ; parse ll | "-suffix" :: [] -> usage () diff --git a/tools/coqdoc/dune b/tools/coqdoc/dune index 8e05c7d97e..b20d9f9b2e 100644 --- a/tools/coqdoc/dune +++ b/tools/coqdoc/dune @@ -1,3 +1,9 @@ +(install + (section lib) + (files + (coqdoc.css as tools/coqdoc/coqdoc.css) + (coqdoc.sty as tools/coqdoc/coqdoc.sty))) + (executable (name main) (public_name coqdoc) diff --git a/tools/dune b/tools/dune index 05a620fb07..20048fde52 100644 --- a/tools/dune +++ b/tools/dune @@ -1,8 +1,11 @@ -(executable - (name coqc) - (public_name coqc) - (modules coqc) - (libraries coq.toplevel)) +(install + (section lib) + (files + (CoqMakefile.in as tools/CoqMakefile.in) + (TimeFileMaker.py as tools/TimeFileMaker.py) + (make-one-time-file.py as tools/make-one-time-file.py) + (make-both-time-files.py as tools/make-both-time-files.py) + (make-both-single-timing-files.py as tools/make-both-single-timing-files.py))) (executable (name coq_makefile) @@ -10,9 +13,11 @@ (modules coq_makefile) (libraries coq.lib)) -(install - (section lib) - (files (CoqMakefile.in as tools/CoqMakefile.in))) +(executable + (name coqc) + (public_name coqc) + (modules coqc) + (libraries coq.toplevel)) (executable (name coqdep) diff --git a/tools/mkwinapp.ml b/tools/mkwinapp.ml deleted file mode 100644 index 226302fb2d..0000000000 --- a/tools/mkwinapp.ml +++ /dev/null @@ -1,92 +0,0 @@ -(* OCaml-Win32 - * mkwinapp.ml - * Copyright (c) 2002-2004 by Harry Chomsky - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - *) - -(********************************************************************* - * This program alters an .exe file to make it use the "windows subsystem" - * instead of the "console subsystem". In other words, when Windows runs - * the program, it will not create a console for it. - *) - -(* Pierre Letouzey 23/12/2010 : modification to allow selecting the - subsystem to use instead of just setting the windows subsystem *) - -(* This tool can be run directly via : - ocaml unix.cma mkwinapp.ml [-set|-unset] <filename> -*) - -exception Invalid_file_format - -let input_word ic = - let lo = input_byte ic in - let hi = input_byte ic in - (hi lsl 8) + lo - -let find_pe_header ic = - seek_in ic 0x3C; - let peheader = input_word ic in - seek_in ic peheader; - if input_char ic <> 'P' then - raise Invalid_file_format; - if input_char ic <> 'E' then - raise Invalid_file_format; - peheader - -let find_optional_header ic = - let peheader = find_pe_header ic in - let coffheader = peheader + 4 in - seek_in ic (coffheader + 16); - let optsize = input_word ic in - if optsize < 96 then - raise Invalid_file_format; - let optheader = coffheader + 20 in - seek_in ic optheader; - let magic = input_word ic in - if magic <> 0x010B && magic <> 0x020B then - raise Invalid_file_format; - optheader - -let change flag ic oc = - let optheader = find_optional_header ic in - seek_out oc (optheader + 64); - for i = 1 to 4 do - output_byte oc 0 - done; - output_byte oc (if flag then 2 else 3) - -let usage () = - print_endline "Alters a Win32 executable file to use the Windows subsystem or not."; - print_endline "Usage: mkwinapp [-set|-unset] <filename>"; - print_endline "Giving no option is equivalent to -set"; - exit 1 - -let main () = - let n = Array.length Sys.argv - 1 in - if not (n = 1 || n = 2) then usage (); - let flag = - if n = 1 then true - else if Sys.argv.(1) = "-set" then true - else if Sys.argv.(1) = "-unset" then false - else usage () - in - let filename = Sys.argv.(n) in - let f = Unix.openfile filename [Unix.O_RDWR] 0 in - let ic = Unix.in_channel_of_descr f and oc = Unix.out_channel_of_descr f in - change flag ic oc - -let _ = main () diff --git a/toplevel/coqargs.ml b/toplevel/coqargs.ml index 98a28bb2b6..06d9ba3436 100644 --- a/toplevel/coqargs.ml +++ b/toplevel/coqargs.ml @@ -152,9 +152,9 @@ let add_vo_require opts d p export = let add_compat_require opts v = match v with - | Flags.V8_6 -> add_vo_require opts "Coq.Compat.Coq86" None (Some false) | Flags.V8_7 -> add_vo_require opts "Coq.Compat.Coq87" None (Some false) - | Flags.Current -> add_vo_require opts "Coq.Compat.Coq88" None (Some false) + | Flags.V8_8 -> add_vo_require opts "Coq.Compat.Coq88" None (Some false) + | Flags.Current -> add_vo_require opts "Coq.Compat.Coq89" None (Some false) let set_batch_mode opts = Flags.quiet := true; @@ -376,8 +376,7 @@ let parse_args arglist : coq_cmdopts * string list = (* Options with one arg *) |"-coqlib" -> - Flags.coqlib_spec := true; - Flags.coqlib := (next ()); + Envars.set_user_coqlib (next ()); oval |"-async-proofs" -> diff --git a/vernac/classes.ml b/vernac/classes.ml index e491761aec..c738d14af9 100644 --- a/vernac/classes.ml +++ b/vernac/classes.ml @@ -121,19 +121,167 @@ let declare_instance_constant k info global imps ?hook id decl poly sigma term t Evd.restrict_universe_context sigma levels in let uctx = Evd.check_univ_decl ~poly sigma decl in - let entry = - Declare.definition_entry ~types:termtype ~univs:uctx term - in + let entry = Declare.definition_entry ~types:termtype ~univs:uctx term in let cdecl = (DefinitionEntry entry, kind) in let kn = Declare.declare_constant id cdecl in - Declare.definition_message id; - Declare.declare_univ_binders (ConstRef kn) (Evd.universe_binders sigma); - instance_hook k info global imps ?hook (ConstRef kn); - id + Declare.definition_message id; + Declare.declare_univ_binders (ConstRef kn) (Evd.universe_binders sigma); + instance_hook k info global imps ?hook (ConstRef kn) + +let do_abstract_instance env sigma ?hook ~global ~poly k u ctx ctx' pri decl imps subst id = + let subst = List.fold_left2 + (fun subst' s decl -> if is_local_assum decl then s :: subst' else subst') + [] subst (snd k.cl_context) + in + let (_, ty_constr) = instance_constructor (k,u) subst in + let termtype = it_mkProd_or_LetIn ty_constr (ctx' @ ctx) in + let sigma = Evd.minimize_universes sigma in + Pretyping.check_evars env (Evd.from_env env) sigma termtype; + let univs = Evd.check_univ_decl ~poly sigma decl in + let termtype = to_constr sigma termtype in + let cst = Declare.declare_constant ~internal:Declare.InternalTacticRequest id + (ParameterEntry + (None,(termtype,univs),None), Decl_kinds.IsAssumption Decl_kinds.Logical) + in + Declare.declare_univ_binders (ConstRef cst) (Evd.universe_binders sigma); + instance_hook k pri global imps ?hook (ConstRef cst); id -let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) - ~program_mode poly ctx (instid, bk, cl) props ?(generalize=true) - ?(tac:unit Proofview.tactic option) ?hook pri = +let declare_instance_open env sigma ?hook ~tac ~program_mode ~global ~poly k id pri imps decl len term termtype = + let kind = Decl_kinds.Global, poly, Decl_kinds.DefinitionBody Decl_kinds.Instance in + if program_mode then + let hook vis gr _ = + let cst = match gr with ConstRef kn -> kn | _ -> assert false in + Impargs.declare_manual_implicits false gr ~enriching:false [imps]; + let pri = intern_info pri in + Typeclasses.declare_instance (Some pri) (not global) (ConstRef cst) + in + let obls, constr, typ = + match term with + | Some t -> + let obls, _, constr, typ = + Obligations.eterm_obligations env id sigma 0 t termtype + in obls, Some constr, typ + | None -> [||], None, termtype + in + let hook = Lemmas.mk_hook hook in + let ctx = Evd.evar_universe_context sigma in + ignore (Obligations.add_definition id ?term:constr + ~univdecl:decl typ ctx ~kind:(Global,poly,Instance) ~hook obls) + else + Flags.silently (fun () -> + (* spiwack: it is hard to reorder the actions to do + the pretyping after the proof has opened. As a + consequence, we use the low-level primitives to code + the refinement manually.*) + let gls = List.rev (Evd.future_goals sigma) in + let sigma = Evd.reset_future_goals sigma in + Lemmas.start_proof id ~pl:decl kind sigma (EConstr.of_constr termtype) + (Lemmas.mk_hook + (fun _ -> instance_hook k pri global imps ?hook)); + (* spiwack: I don't know what to do with the status here. *) + if not (Option.is_empty term) then + let init_refine = + Tacticals.New.tclTHENLIST [ + Refine.refine ~typecheck:false (fun sigma -> (sigma,EConstr.of_constr (Option.get term))); + Proofview.Unsafe.tclNEWGOALS (CList.map Proofview.with_empty_state gls); + Tactics.New.reduce_after_refine; + ] + in + ignore (Pfedit.by init_refine) + else if Flags.is_auto_intros () then + ignore (Pfedit.by (Tacticals.New.tclDO len Tactics.intro)); + (match tac with Some tac -> ignore (Pfedit.by tac) | None -> ())) () + +let do_transparent_instance env env' sigma ?hook ~refine ~tac ~global ~poly ~program_mode cty k u ctx ctx' pri decl imps subst id props len = + let props = + match props with + | Some (true, { CAst.v = CRecord fs }) -> + if List.length fs > List.length k.cl_props then + mismatched_props env' (List.map snd fs) k.cl_props; + Some (Inl fs) + | Some (_, t) -> Some (Inr t) + | None -> + if program_mode then Some (Inl []) + else None + in + let subst, sigma = + match props with + | None -> + (if List.is_empty k.cl_props then Some (Inl subst) else None), sigma + | Some (Inr term) -> + let sigma, c = interp_casted_constr_evars env' sigma term cty in + Some (Inr (c, subst)), sigma + | Some (Inl props) -> + let get_id qid = CAst.make ?loc:qid.CAst.loc @@ qualid_basename qid in + let props, rest = + List.fold_left + (fun (props, rest) decl -> + if is_local_assum decl then + try + let is_id (id', _) = match RelDecl.get_name decl, get_id id' with + | Name id, {CAst.v=id'} -> Id.equal id id' + | Anonymous, _ -> false + in + let (loc_mid, c) = List.find is_id rest in + let rest' = List.filter (fun v -> not (is_id v)) rest + in + let {CAst.loc;v=mid} = get_id loc_mid in + List.iter (fun (n, _, x) -> + if Name.equal n (Name mid) then + Option.iter (fun x -> Dumpglob.add_glob ?loc (ConstRef x)) x) k.cl_projs; + c :: props, rest' + with Not_found -> + ((CAst.make @@ CHole (None(* Some Evar_kinds.GoalEvar *), Namegen.IntroAnonymous, None)) :: props), rest + else props, rest) + ([], props) k.cl_props + in + match rest with + | (n, _) :: _ -> + unbound_method env' k.cl_impl (get_id n) + | _ -> + let kcl_props = List.map (Termops.map_rel_decl of_constr) k.cl_props in + let sigma, res = type_ctx_instance (push_rel_context ctx' env') sigma kcl_props props subst in + Some (Inl res), sigma + in + let term, termtype = + match subst with + | None -> let termtype = it_mkProd_or_LetIn cty ctx in + None, termtype + | Some (Inl subst) -> + let subst = List.fold_left2 + (fun subst' s decl -> if is_local_assum decl then s :: subst' else subst') + [] subst (k.cl_props @ snd k.cl_context) + in + let (app, ty_constr) = instance_constructor (k,u) subst in + let termtype = it_mkProd_or_LetIn ty_constr (ctx' @ ctx) in + let term = it_mkLambda_or_LetIn (Option.get app) (ctx' @ ctx) in + Some term, termtype + | Some (Inr (def, subst)) -> + let termtype = it_mkProd_or_LetIn cty ctx in + let term = it_mkLambda_or_LetIn def ctx in + Some term, termtype + in + let sigma = Evarutil.nf_evar_map sigma in + let sigma = Typeclasses.resolve_typeclasses ~filter:Typeclasses.no_goals_or_obligations ~fail:true env sigma in + (* Try resolving fields that are typeclasses automatically. *) + let sigma = Typeclasses.resolve_typeclasses ~filter:Typeclasses.all_evars ~fail:false env sigma in + let sigma = Evarutil.nf_evar_map_undefined sigma in + (* Beware of this step, it is required as to minimize universes. *) + let sigma = Evd.minimize_universes sigma in + (* Check that the type is free of evars now. *) + Pretyping.check_evars env (Evd.from_env env) sigma termtype; + let termtype = to_constr sigma termtype in + let term = Option.map (to_constr ~abort_on_undefined_evars:false sigma) term in + if not (Evd.has_undefined sigma) && not (Option.is_empty term) then + declare_instance_constant k pri global imps ?hook id decl poly sigma (Option.get term) termtype + else if program_mode || refine || Option.is_empty term then + declare_instance_open env sigma ?hook ~tac ~program_mode ~global ~poly k id pri imps decl len term termtype + else CErrors.user_err Pp.(str "Unsolved obligations remaining."); + id + +let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) ~program_mode + poly ctx (instid, bk, cl) props + ?(generalize=true) ?(tac:unit Proofview.tactic option) ?hook pri = let env = Global.env() in let ({CAst.loc;v=instid}, pl) = instid in let sigma, decl = Constrexpr_ops.interp_univ_decl_opt env pl in @@ -150,9 +298,9 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) cl | Explicit -> cl, Id.Set.empty in - let tclass = - if generalize then CAst.make @@ CGeneralization (Implicit, Some AbsPi, tclass) - else tclass + let tclass = + if generalize then CAst.make @@ CGeneralization (Implicit, Some AbsPi, tclass) + else tclass in let sigma, k, u, cty, ctx', ctx, len, imps, subst = let sigma, (impls, ((env', ctx), imps)) = interp_context_evars env sigma ctx in @@ -189,163 +337,12 @@ let new_instance ?(abstract=false) ?(global=false) ?(refine= !refine_instance) let env' = push_rel_context ctx env in let sigma = Evarutil.nf_evar_map sigma in let sigma = resolve_typeclasses ~filter:Typeclasses.all_evars ~fail:true env sigma in - if abstract then - begin - let subst = List.fold_left2 - (fun subst' s decl -> if is_local_assum decl then s :: subst' else subst') - [] subst (snd k.cl_context) - in - let (_, ty_constr) = instance_constructor (k,u) subst in - let termtype = it_mkProd_or_LetIn ty_constr (ctx' @ ctx) in - let sigma = Evd.minimize_universes sigma in - Pretyping.check_evars env (Evd.from_env env) sigma termtype; - let univs = Evd.check_univ_decl ~poly sigma decl in - let termtype = to_constr sigma termtype in - let cst = Declare.declare_constant ~internal:Declare.InternalTacticRequest id - (ParameterEntry - (None,(termtype,univs),None), Decl_kinds.IsAssumption Decl_kinds.Logical) - in - Declare.declare_univ_binders (ConstRef cst) (Evd.universe_binders sigma); - instance_hook k pri global imps ?hook (ConstRef cst); id - end - else ( - let props = - match props with - | Some (true, { CAst.v = CRecord fs }) -> - if List.length fs > List.length k.cl_props then - mismatched_props env' (List.map snd fs) k.cl_props; - Some (Inl fs) - | Some (_, t) -> Some (Inr t) - | None -> - if program_mode then Some (Inl []) - else None - in - let subst, sigma = - match props with - | None -> - (if List.is_empty k.cl_props then Some (Inl subst) else None), sigma - | Some (Inr term) -> - let sigma, c = interp_casted_constr_evars env' sigma term cty in - Some (Inr (c, subst)), sigma - | Some (Inl props) -> - let get_id qid = CAst.make ?loc:qid.CAst.loc @@ qualid_basename qid in - let props, rest = - List.fold_left - (fun (props, rest) decl -> - if is_local_assum decl then - try - let is_id (id', _) = match RelDecl.get_name decl, get_id id' with - | Name id, {CAst.v=id'} -> Id.equal id id' - | Anonymous, _ -> false - in - let (loc_mid, c) = - List.find is_id rest - in - let rest' = - List.filter (fun v -> not (is_id v)) rest - in - let {CAst.loc;v=mid} = get_id loc_mid in - List.iter (fun (n, _, x) -> - if Name.equal n (Name mid) then - Option.iter (fun x -> Dumpglob.add_glob ?loc (ConstRef x)) x) - k.cl_projs; - c :: props, rest' - with Not_found -> - ((CAst.make @@ CHole (None(* Some Evar_kinds.GoalEvar *), Namegen.IntroAnonymous, None)) :: props), rest - else props, rest) - ([], props) k.cl_props - in - match rest with - | (n, _) :: _ -> - unbound_method env' k.cl_impl (get_id n) - | _ -> - let kcl_props = List.map (Termops.map_rel_decl of_constr) k.cl_props in - let sigma, res = type_ctx_instance (push_rel_context ctx' env') sigma kcl_props props subst in - Some (Inl res), sigma - in - let term, termtype = - match subst with - | None -> let termtype = it_mkProd_or_LetIn cty ctx in - None, termtype - | Some (Inl subst) -> - let subst = List.fold_left2 - (fun subst' s decl -> if is_local_assum decl then s :: subst' else subst') - [] subst (k.cl_props @ snd k.cl_context) - in - let (app, ty_constr) = instance_constructor (k,u) subst in - let termtype = it_mkProd_or_LetIn ty_constr (ctx' @ ctx) in - let term = it_mkLambda_or_LetIn (Option.get app) (ctx' @ ctx) in - Some term, termtype - | Some (Inr (def, subst)) -> - let termtype = it_mkProd_or_LetIn cty ctx in - let term = it_mkLambda_or_LetIn def ctx in - Some term, termtype - in - let sigma = Evarutil.nf_evar_map sigma in - let sigma = Typeclasses.resolve_typeclasses ~filter:Typeclasses.no_goals_or_obligations ~fail:true env sigma in - (* Try resolving fields that are typeclasses automatically. *) - let sigma = Typeclasses.resolve_typeclasses ~filter:Typeclasses.all_evars ~fail:false env sigma in - let sigma = Evarutil.nf_evar_map_undefined sigma in - (* Beware of this step, it is required as to minimize universes. *) - let sigma = Evd.minimize_universes sigma in - (* Check that the type is free of evars now. *) - Pretyping.check_evars env (Evd.from_env env) sigma termtype; - let termtype = to_constr sigma termtype in - let term = Option.map (to_constr ~abort_on_undefined_evars:false sigma) term in - if not (Evd.has_undefined sigma) && not (Option.is_empty term) then - declare_instance_constant k pri global imps ?hook id decl - poly sigma (Option.get term) termtype - else if program_mode || refine || Option.is_empty term then begin - let kind = Decl_kinds.Global, poly, Decl_kinds.DefinitionBody Decl_kinds.Instance in - if program_mode then - let hook vis gr _ = - let cst = match gr with ConstRef kn -> kn | _ -> assert false in - Impargs.declare_manual_implicits false gr ~enriching:false [imps]; - let pri = intern_info pri in - Typeclasses.declare_instance (Some pri) (not global) (ConstRef cst) - in - let obls, constr, typ = - match term with - | Some t -> - let obls, _, constr, typ = - Obligations.eterm_obligations env id sigma 0 t termtype - in obls, Some constr, typ - | None -> [||], None, termtype - in - let hook = Lemmas.mk_hook hook in - let ctx = Evd.evar_universe_context sigma in - ignore (Obligations.add_definition id ?term:constr - ~univdecl:decl typ ctx ~kind:(Global,poly,Instance) ~hook obls); - id - else - (Flags.silently - (fun () -> - (* spiwack: it is hard to reorder the actions to do - the pretyping after the proof has opened. As a - consequence, we use the low-level primitives to code - the refinement manually.*) - let gls = List.rev (Evd.future_goals sigma) in - let sigma = Evd.reset_future_goals sigma in - Lemmas.start_proof id ~pl:decl kind sigma (EConstr.of_constr termtype) - (Lemmas.mk_hook - (fun _ -> instance_hook k pri global imps ?hook)); - (* spiwack: I don't know what to do with the status here. *) - if not (Option.is_empty term) then - let init_refine = - Tacticals.New.tclTHENLIST [ - Refine.refine ~typecheck:false (fun sigma -> (sigma,EConstr.of_constr (Option.get term))); - Proofview.Unsafe.tclNEWGOALS (CList.map Proofview.with_empty_state gls); - Tactics.New.reduce_after_refine; - ] - in - ignore (Pfedit.by init_refine) - else if Flags.is_auto_intros () then - ignore (Pfedit.by (Tacticals.New.tclDO len Tactics.intro)); - (match tac with Some tac -> ignore (Pfedit.by tac) | None -> ())) (); - id) - end - else CErrors.user_err Pp.(str "Unsolved obligations remaining.")) - + if abstract then + do_abstract_instance env sigma ?hook ~global ~poly k u ctx ctx' pri decl imps subst id + else + do_transparent_instance env env' sigma ?hook ~refine ~tac ~global ~poly ~program_mode + cty k u ctx ctx' pri decl imps subst id props len + let named_of_rel_context l = let open Vars in let acc, ctx = @@ -433,5 +430,5 @@ let context poly l = Lib.sections_are_opened () || Lib.is_modtype_strict () in status && nstatus - in + in List.fold_left fn true (List.rev ctx) diff --git a/vernac/classes.mli b/vernac/classes.mli index 9c37364cb0..bb70334342 100644 --- a/vernac/classes.mli +++ b/vernac/classes.mli @@ -37,7 +37,7 @@ val declare_instance_constant : Evd.evar_map -> (* Universes *) Constr.t -> (** body *) Constr.types -> (** type *) - Names.Id.t + unit val new_instance : ?abstract:bool -> (** Not abstract by default. *) diff --git a/vernac/explainErr.ml b/vernac/explainErr.ml index 7cf4e64805..b37fce645a 100644 --- a/vernac/explainErr.ml +++ b/vernac/explainErr.ml @@ -76,8 +76,8 @@ let process_vernac_interp_error exn = match fst exn with wrap_vernac_error exn (Himsg.explain_module_error e) | Modintern.ModuleInternalizationError e -> wrap_vernac_error exn (Himsg.explain_module_internalization_error e) - | RecursionSchemeError e -> - wrap_vernac_error exn (Himsg.explain_recursion_scheme_error e) + | RecursionSchemeError (env,e) -> + wrap_vernac_error exn (Himsg.explain_recursion_scheme_error env e) | Cases.PatternMatchingError (env,sigma,e) -> wrap_vernac_error exn (Himsg.explain_pattern_matching_error env sigma e) | Tacred.ReductionTacticError e -> diff --git a/vernac/g_vernac.mlg b/vernac/g_vernac.mlg index 7dd5471f3f..cf69a84b8b 100644 --- a/vernac/g_vernac.mlg +++ b/vernac/g_vernac.mlg @@ -60,10 +60,10 @@ let make_bullet s = | _ -> assert false let parse_compat_version = let open Flags in function - | "8.8" -> Current + | "8.9" -> Current + | "8.8" -> V8_8 | "8.7" -> V8_7 - | "8.6" -> V8_6 - | ("8.5" | "8.4" | "8.3" | "8.2" | "8.1" | "8.0") as s -> + | ("8.6" | "8.5" | "8.4" | "8.3" | "8.2" | "8.1" | "8.0") as s -> CErrors.user_err ~hdr:"get_compat_version" Pp.(str "Compatibility with version " ++ str s ++ str " not supported.") | s -> diff --git a/vernac/himsg.ml b/vernac/himsg.ml index 71155d7921..a4b3a75c9f 100644 --- a/vernac/himsg.ml +++ b/vernac/himsg.ml @@ -601,12 +601,12 @@ let explain_var_not_found env id = spc () ++ str "in the current" ++ spc () ++ str "environment" ++ str "." let explain_wrong_case_info env (ind,u) ci = - let pi = pr_inductive (Global.env()) ind in + let pi = pr_inductive env ind in if eq_ind ci.ci_ind ind then str "Pattern-matching expression on an object of inductive type" ++ spc () ++ pi ++ spc () ++ str "has invalid information." else - let pc = pr_inductive (Global.env()) ci.ci_ind in + let pc = pr_inductive env ci.ci_ind in str "A term of inductive type" ++ spc () ++ pi ++ spc () ++ str "was given to a pattern-matching expression on the inductive type" ++ spc () ++ pc ++ str "." @@ -1156,24 +1156,24 @@ let error_large_non_prop_inductive_not_in_type () = (* Recursion schemes errors *) -let error_not_allowed_case_analysis isrec kind i = +let error_not_allowed_case_analysis env isrec kind i = str (if isrec then "Induction" else "Case analysis") ++ strbrk " on sort " ++ pr_sort Evd.empty kind ++ strbrk " is not allowed for inductive definition " ++ - pr_inductive (Global.env()) (fst i) ++ str "." + pr_inductive env (fst i) ++ str "." -let error_not_allowed_dependent_analysis isrec i = +let error_not_allowed_dependent_analysis env isrec i = str "Dependent " ++ str (if isrec then "induction" else "case analysis") ++ strbrk " is not allowed for inductive definition " ++ - pr_inductive (Global.env()) i ++ str "." + pr_inductive env i ++ str "." -let error_not_mutual_in_scheme ind ind' = +let error_not_mutual_in_scheme env ind ind' = if eq_ind ind ind' then - str "The inductive type " ++ pr_inductive (Global.env()) ind ++ + str "The inductive type " ++ pr_inductive env ind ++ str " occurs twice." else - str "The inductive types " ++ pr_inductive (Global.env()) ind ++ spc () ++ - str "and" ++ spc () ++ pr_inductive (Global.env()) ind' ++ spc () ++ + str "The inductive types " ++ pr_inductive env ind ++ spc () ++ + str "and" ++ spc () ++ pr_inductive env ind' ++ spc () ++ str "are not mutually defined." (* Inductive constructions errors *) @@ -1194,12 +1194,12 @@ let explain_inductive_error = function (* Recursion schemes errors *) -let explain_recursion_scheme_error = function +let explain_recursion_scheme_error env = function | NotAllowedCaseAnalysis (isrec,k,i) -> - error_not_allowed_case_analysis isrec k i - | NotMutualInScheme (ind,ind')-> error_not_mutual_in_scheme ind ind' + error_not_allowed_case_analysis env isrec k i + | NotMutualInScheme (ind,ind')-> error_not_mutual_in_scheme env ind ind' | NotAllowedDependentAnalysis (isrec, i) -> - error_not_allowed_dependent_analysis isrec i + error_not_allowed_dependent_analysis env isrec i (* Pattern-matching errors *) diff --git a/vernac/himsg.mli b/vernac/himsg.mli index 02b3c45501..db05aaa125 100644 --- a/vernac/himsg.mli +++ b/vernac/himsg.mli @@ -29,7 +29,7 @@ val explain_mismatched_contexts : env -> contexts -> Constrexpr.constr_expr list val explain_typeclass_error : env -> typeclass_error -> Pp.t -val explain_recursion_scheme_error : recursion_scheme_error -> Pp.t +val explain_recursion_scheme_error : env -> recursion_scheme_error -> Pp.t val explain_refiner_error : env -> Evd.evar_map -> refiner_error -> Pp.t diff --git a/vernac/indschemes.ml b/vernac/indschemes.ml index 0a74a8cc4a..b354ad0521 100644 --- a/vernac/indschemes.ml +++ b/vernac/indschemes.ml @@ -82,7 +82,7 @@ let _ = let is_eq_flag () = !eq_flag -let eq_dec_flag = ref false +let eq_dec_flag = ref false let _ = declare_bool_option { optdepr = false; @@ -330,11 +330,10 @@ let declare_sym_scheme ind = (* Scheme command *) let smart_global_inductive y = smart_global_inductive y -let rec split_scheme l = - let env = Global.env() in +let rec split_scheme env l = match l with | [] -> [],[] - | (Some id,t)::q -> let l1,l2 = split_scheme q in + | (Some id,t)::q -> let l1,l2 = split_scheme env q in ( match t with | InductionScheme (x,y,z) -> ((id,x,smart_global_inductive y,z)::l1),l2 | CaseScheme (x,y,z) -> ((id,x,smart_global_inductive y,z)::l1),l2 @@ -345,7 +344,7 @@ let rec split_scheme l = requested *) | (None,t)::q -> - let l1,l2 = split_scheme q in + let l1,l2 = split_scheme env q in let names inds recs isdep y z = let ind = smart_global_inductive y in let sort_of_ind = inductive_sort_family (snd (lookup_mind_specif env ind)) in @@ -384,7 +383,7 @@ let do_mutual_induction_scheme ?(force_mutual=false) lnamedepindsort = and env0 = Global.env() in let sigma, lrecspec, _ = List.fold_right - (fun (_,dep,ind,sort) (evd, l, inst) -> + (fun (_,dep,ind,sort) (evd, l, inst) -> let evd, indu, inst = match inst with | None -> @@ -408,12 +407,12 @@ let do_mutual_induction_scheme ?(force_mutual=false) lnamedepindsort = let _ = List.fold_right2 declare listdecl lrecnames [] in fixpoint_message None lrecnames -let get_common_underlying_mutual_inductive = function +let get_common_underlying_mutual_inductive env = function | [] -> assert false | (id,(mind,i as ind))::l as all -> match List.filter (fun (_,(mind',_)) -> not (MutInd.equal mind mind')) l with | (_,ind')::_ -> - raise (RecursionSchemeError (NotMutualInScheme (ind,ind'))) + raise (RecursionSchemeError (env, NotMutualInScheme (ind,ind'))) | [] -> if not (List.distinct_f Int.compare (List.map snd (List.map snd all))) then user_err Pp.(str "A type occurs twice"); @@ -422,7 +421,8 @@ let get_common_underlying_mutual_inductive = function (function (Some id,(_,i)) -> Some (i,id.CAst.v) | (None,_) -> None) all let do_scheme l = - let ischeme,escheme = split_scheme l in + let env = Global.env() in + let ischeme,escheme = split_scheme env l in (* we want 1 kind of scheme at a time so we check if the user tried to declare different schemes at once *) if not (List.is_empty ischeme) && not (List.is_empty escheme) @@ -431,7 +431,7 @@ tried to declare different schemes at once *) else ( if not (List.is_empty ischeme) then do_mutual_induction_scheme ischeme else - let mind,l = get_common_underlying_mutual_inductive escheme in + let mind,l = get_common_underlying_mutual_inductive env escheme in declare_beq_scheme_with l mind; declare_eq_decidability_scheme_with l mind ) @@ -454,6 +454,9 @@ let fold_left' f = function let mk_coq_and sigma = Evarutil.new_global sigma (Coqlib.build_coq_and ()) let mk_coq_conj sigma = Evarutil.new_global sigma (Coqlib.build_coq_conj ()) +let mk_coq_prod sigma = Evarutil.new_global sigma (Coqlib.build_coq_prod ()) +let mk_coq_pair sigma = Evarutil.new_global sigma (Coqlib.build_coq_pair ()) + let build_combined_scheme env schemes = let evdref = ref (Evd.from_env env) in let defs = List.map (fun cst -> @@ -471,10 +474,25 @@ let build_combined_scheme env schemes = in let (c, t) = List.hd defs in let ctx, ind, nargs = find_inductive t in + (* We check if ALL the predicates are in Prop, if so we use propositional + conjunction '/\', otherwise we use the simple product '*'. + *) + let inprop = + let inprop (_,t) = + Retyping.get_sort_family_of env !evdref (EConstr.of_constr t) + == Sorts.InProp + in + List.for_all inprop defs + in + let mk_and, mk_conj = + if inprop + then (mk_coq_and, mk_coq_conj) + else (mk_coq_prod, mk_coq_pair) + in (* Number of clauses, including the predicates quantification *) let prods = nb_prod !evdref (EConstr.of_constr t) - (nargs + 1) in - let sigma, coqand = mk_coq_and !evdref in - let sigma, coqconj = mk_coq_conj sigma in + let sigma, coqand = mk_and !evdref in + let sigma, coqconj = mk_conj sigma in let () = evdref := sigma in let relargs = rel_vect 0 prods in let concls = List.rev_map @@ -492,7 +510,8 @@ let build_combined_scheme env schemes = (List.rev_map (fun (x, y) -> LocalAssum (x, y)) ctx) in let typ = List.fold_left (fun d c -> Term.mkProd_wo_LetIn c d) concl_typ ctx in let body = it_mkLambda_or_LetIn concl_bod ctx in - (!evdref, body, typ) + let sigma = Typing.check env !evdref (EConstr.of_constr body) (EConstr.of_constr typ) in + (sigma, body, typ) let do_combined_scheme name schemes = let open CAst in diff --git a/vernac/mltop.ml b/vernac/mltop.ml index d25dea1413..3620e177fe 100644 --- a/vernac/mltop.ml +++ b/vernac/mltop.ml @@ -69,9 +69,6 @@ type kind_load = (* Must be always initialized *) let load = ref WithoutTop -(* Are we in a native version of Coq? *) -let is_native = Dynlink.is_native - (* Sets and initializes a toplevel (if any) *) let set_top toplevel = load := WithTop toplevel; @@ -89,7 +86,7 @@ let is_ocaml_top () = |_ -> false (* Tests if we can load ML files *) -let has_dynlink = Coq_config.has_natdynlink || not is_native +let has_dynlink = Coq_config.has_natdynlink || not Sys.(backend_type = Native) (* Runs the toplevel loop of Ocaml *) let ocaml_toploop () = @@ -149,7 +146,7 @@ let dir_ml_use s = | WithTop t -> t.use_file s | _ -> let moreinfo = - if Dynlink.is_native then " Loading ML code works only in bytecode." + if Sys.(backend_type = Native) then " Loading ML code works only in bytecode." else "" in user_err ~hdr:"Mltop.dir_ml_use" (str "Could not load ML code." ++ str moreinfo) @@ -257,7 +254,8 @@ let file_of_name name = str"Loadpath: " ++ str(String.concat ":" !coq_mlpath_copy)) in if not (Filename.is_relative name) then if Sys.file_exists name then name else fail name - else if is_native then + else if Sys.(backend_type = Native) then + (* XXX: Dynlink.adapt_filename does the same? *) let name = match suffix with | Some ((".cmo"|".cma") as suffix) -> (Filename.chop_suffix name suffix) ^ ".cmxs" diff --git a/vernac/mltop.mli b/vernac/mltop.mli index ed1f9a12d8..3d796aa4aa 100644 --- a/vernac/mltop.mli +++ b/vernac/mltop.mli @@ -21,9 +21,6 @@ type toplevel = { (** Sets and initializes a toplevel (if any) *) val set_top : toplevel -> unit -(** Are we in a native version of Coq? *) -val is_native : bool - (** Removes the toplevel (if any) *) val remove : unit -> unit |
