Skip to content

Commit 97adfc3

Browse files
committed
Merge branch 'v8.5'
2 parents 54277ab + bd5da52 commit 97adfc3

File tree

13 files changed

+144
-75
lines changed

13 files changed

+144
-75
lines changed

checker/check_stat.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ let pr_engagement (impr_set,type_in_type) =
2828
match impr_set with
2929
| ImpredicativeSet -> str "Theory: Set is impredicative"
3030
| PredicativeSet -> str "Theory: Set is predicative"
31-
end ++
31+
end ++ fnl() ++
3232
begin
3333
match type_in_type with
3434
| StratifiedType -> str "Theory: Stratified type hierarchy"

configure.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,11 @@ let check_camlp5_version () =
566566
| _ -> die "Error: unsupported Camlp5 (version < 5.01 or unrecognized).\n"
567567

568568
let check_caml_version_for_camlp4 () =
569-
if caml_version_nums = [4;1;0] && !Prefs.debug then
570-
die ("Your version of OCaml is 4.01.0 which fails to compile Coq in -debug\n" ^
571-
"mode with Camlp4. Remove -debug option or use a different version of OCaml\n" ^
572-
"or use Camlp5.\n")
569+
if caml_version_nums = [4;1;0] && !Prefs.debug && not !Prefs.force_caml_version then
570+
die ("Your version of OCaml is detected to be 4.01.0 which fails to compile\n" ^
571+
"Coq in -debug mode with Camlp4. Remove -debug option or use a different\n" ^
572+
"version of OCaml or use Camlp5, or bypass this test by using option\n" ^
573+
"-force-caml-version.\n")
573574

574575
let config_camlpX () =
575576
try

doc/tutorial/Tutorial.tex

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,14 @@ \subsection{Definitions}
248248
\begin{coq_example}
249249
Check (forall m:nat, gt m 0).
250250
\end{coq_example}
251-
We may clean-up the development by removing the contents of the
252-
current section:
251+
We may revert to the clean state of
252+
our initial session using the \Coq~ \verb:Reset: command:
253253
\begin{coq_example}
254-
Reset Declaration.
254+
Reset Initial.
255255
\end{coq_example}
256+
\begin{coq_eval}
257+
Set Printing Width 60.
258+
\end{coq_eval}
256259

257260
\section{Introduction to the proof engine: Minimal Logic}
258261

@@ -658,10 +661,8 @@ \subsection{Sections and signatures}
658661
as global variables. But we must be careful about the pollution of our
659662
global environment by such declarations. For instance, we have already
660663
polluted our \Coq~ session by declaring the variables
661-
\verb:n:, \verb:Pos_n:, \verb:A:, \verb:B:, and \verb:C:. If we want to revert to the clean state of
662-
our initial session, we may use the \Coq~ \verb:Reset: command, which returns
663-
to the state just prior the given global notion as we did before to
664-
remove a section, or we may return to the initial state using~:
664+
\verb:n:, \verb:Pos_n:, \verb:A:, \verb:B:, and \verb:C:.
665+
665666
\begin{coq_example}
666667
Reset Initial.
667668
\end{coq_example}
@@ -770,7 +771,7 @@ \subsection{Existential quantification}
770771
End R_sym_trans.
771772
\end{coq_example}
772773

773-
Here \Coq's printout is a warning that all local hypotheses have been
774+
All the local hypotheses have been
774775
discharged in the statement of \verb:refl_if:, which now becomes a general
775776
theorem in the first-order language declared in section
776777
\verb:Predicate_calculus:. In this particular example, the use of section
@@ -1105,8 +1106,14 @@ \subsection{Principle of proof irrelevance}
11051106

11061107
Conversely, ordinary mathematical definitions can be unfolded at will, they
11071108
are {\sl transparent}.
1109+
11081110
\chapter{Induction}
11091111

1112+
\begin{coq_eval}
1113+
Reset Initial.
1114+
Set Printing Width 60.
1115+
\end{coq_eval}
1116+
11101117
\section{Data Types as Inductively Defined Mathematical Collections}
11111118

11121119
All the notions which were studied until now pertain to traditional
@@ -1195,7 +1202,7 @@ \subsection{Natural numbers}
11951202
\verb:Set: \verb:(P i):, \verb:prim_rec: computes uniformly an element of
11961203
\verb:nat:. Let us check the type of \verb:prim_rec::
11971204
\begin{coq_example}
1198-
Check prim_rec.
1205+
About prim_rec.
11991206
\end{coq_example}
12001207

12011208
Oops! Instead of the expected type \verb+nat->(nat->nat->nat)->nat->nat+ we
@@ -1241,22 +1248,16 @@ \subsection{Natural numbers}
12411248
For the rest of the session, we shall clean up what we did so far with
12421249
types \verb:bool: and \verb:nat:, in order to use the initial definitions
12431250
given in \Coq's \verb:Prelude: module, and not to get confusing error
1244-
messages due to our redefinitions. We thus revert to the state before
1245-
our definition of \verb:bool: with the \verb:Reset: command:
1251+
messages due to our redefinitions. We thus revert to the initial state:
12461252
\begin{coq_example}
1247-
Reset bool.
1248-
\end{coq_example}
1249-
1250-
1251-
\subsection{Simple proofs by induction}
1252-
1253-
\begin{coq_eval}
12541253
Reset Initial.
1255-
\end{coq_eval}
1254+
\end{coq_example}
12561255
\begin{coq_eval}
12571256
Set Printing Width 60.
12581257
\end{coq_eval}
12591258

1259+
\subsection{Simple proofs by induction}
1260+
12601261
Let us now show how to do proofs by structural induction. We start with easy
12611262
properties of the \verb:plus: function we just defined. Let us first
12621263
show that $n=n+0$.
@@ -1480,6 +1481,11 @@ \section{Logic programming}
14801481

14811482
\chapter{Modules}
14821483

1484+
\begin{coq_eval}
1485+
Reset Initial.
1486+
Set Printing Width 60.
1487+
\end{coq_eval}
1488+
14831489
\section{Opening library modules}
14841490

14851491
When you start \Coq~ without further requirements in the command line,
@@ -1543,19 +1549,23 @@ \section{Managing the context}
15431549
libraries have been loaded. A convenient \verb:Search: command
15441550
is available to lookup all known facts
15451551
concerning a given predicate. For instance, if you want to know all the
1546-
known lemmas about the less or equal relation, just ask:
1552+
known lemmas about both the successor and the less or equal relation, just ask:
1553+
\begin{coq_eval}
1554+
Reset Initial.
1555+
Set Printing Width 60.
1556+
\end{coq_eval}
15471557
\begin{coq_example}
1548-
Search le.
1558+
Search S le.
15491559
\end{coq_example}
15501560
Another command \verb:SearchHead: displays only lemmas where the searched
15511561
predicate appears at the head position in the conclusion.
15521562
\begin{coq_example}
15531563
SearchHead le.
15541564
\end{coq_example}
15551565

1556-
A new and more convenient search tool is \textsf{SearchPattern}
1566+
A new and more convenient search tool is \verb:SearchPattern:
15571567
developed by Yves Bertot. It allows finding the theorems with a
1558-
conclusion matching a given pattern, where \verb:\_: can be used in
1568+
conclusion matching a given pattern, where \verb:_: can be used in
15591569
place of an arbitrary term. We remark in this example, that \Coq{}
15601570
provides usual infix notations for arithmetic operators.
15611571

ide/coq.lang

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,24 @@
9595
<keyword>Type</keyword>
9696
</context>
9797

98-
<context id="coq" class="no-spell-check">
98+
<!-- Terms -->
99+
<context id="constr">
99100
<include>
100101
<context ref="string"/>
101102
<context ref="coqdoc"/>
102103
<context ref="comment"/>
104+
<context ref="constr-sort"/>
105+
<context ref="constr-keyword"/>
106+
<context id="dot-nosep">
107+
<match>\.\.</match>
108+
</context>
109+
</include>
110+
</context>
111+
112+
<context id="coq" class="no-spell-check">
113+
<include>
114+
<context ref="coqdoc"/>
115+
<context ref="comment"/>
103116

104117
<context id="declaration">
105118
<start>\%{decl_head}</start>
@@ -110,14 +123,7 @@
110123
<context sub-pattern="gal2" where="start" style-ref="gallina-keyword"/>
111124
<context sub-pattern="id_list" where="start" style-ref="identifier"/>
112125
<context sub-pattern="gal4list" where="start" style-ref="gallina-keyword"/>
113-
<context ref="constr-keyword"/>
114-
<context ref="constr-sort"/>
115-
<context id="dot-nosep">
116-
<match>\.\.</match>
117-
</context>
118-
<context ref="string"/>
119-
<context ref="coqdoc"/>
120-
<context ref="comment"/>
126+
<context ref="constr"/>
121127
</include>
122128
</context>
123129

@@ -127,21 +133,19 @@
127133
<include>
128134
<context sub-pattern="0" where="start" style-ref="vernac-keyword"/>
129135
<context sub-pattern="0" where="end" style-ref="vernac-keyword"/>
130-
<context ref="command-in-proof"/>
131-
<context ref="string"/>
132136
<context ref="coqdoc"/>
133137
<context ref="comment"/>
134-
<context ref="constr-keyword"/>
135-
<context ref="constr-sort"/>
136-
<context id="bullet" extend-parent="false">
137-
<match>\%{dot_sep}\s*(?'bul'\%{bullet})</match>
138+
<context id="bullet" style-ref="vernac-keyword" extend-parent="false">
139+
<match>\%{bullet}</match>
140+
</context>
141+
<context extend-parent="false">
142+
<start>\%[</start>
143+
<end>\%{dot_sep}</end>
138144
<include>
139-
<context sub-pattern="bul" style-ref="vernac-keyword"/>
145+
<context ref="command-in-proof"/>
146+
<context ref="constr"/>
140147
</include>
141148
</context>
142-
<context id="bullet-sol" style-ref="vernac-keyword">
143-
<match>^\s*\%{bullet}</match>
144-
</context>
145149
</include>
146150
</context>
147151

@@ -150,11 +154,19 @@
150154
<end>\%{dot_sep}</end>
151155
<include>
152156
<context sub-pattern="0" where="start" style-ref="vernac-keyword"/>
153-
<context ref="constr-keyword"/>
154-
<context ref="constr-sort"/>
157+
<context ref="constr"/>
155158
</include>
156159
</context>
157160

161+
<context ref="command"/>
162+
</include>
163+
</context>
164+
165+
<!-- Toplevel commands -->
166+
<context id="command" extend-parent="false">
167+
<start>\%[</start>
168+
<end>\%{dot_sep}</end>
169+
<include>
158170
<context id="command-in-proof" style-ref="vernac-keyword">
159171
<keyword>About</keyword>
160172
<keyword>Check</keyword>
@@ -166,7 +178,7 @@
166178
<keyword>Transparent</keyword>
167179
</context>
168180

169-
<context id="command" style-ref="vernac-keyword">
181+
<context id="toplevel-command" style-ref="vernac-keyword">
170182
<keyword>Add</keyword>
171183
<keyword>Load</keyword>
172184
<keyword>(Print|Reset)\%{space}+Extraction\%{space}+(Inline|Blacklist)</keyword>
@@ -228,7 +240,10 @@
228240
<context sub-pattern="qua_list" style-ref="identifier"/>
229241
</include>
230242
</context>
243+
244+
<context ref="constr"/>
231245
</include>
232246
</context>
247+
233248
</definitions>
234249
</language>

ide/coq.png

-57.6 KB
Loading

kernel/reduction.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ let convert_instances ~flex u u' (s, check) =
177177
let conv_table_key infos k1 k2 cuniv =
178178
if k1 == k2 then cuniv else
179179
match k1, k2 with
180-
| ConstKey (cst, u), ConstKey (cst', u') when eq_constant_key cst cst' ->
180+
| ConstKey (cst, u), ConstKey (cst', u') when Constant.equal cst cst' ->
181181
if Univ.Instance.equal u u' then cuniv
182182
else
183183
let flex = evaluable_constant cst (info_env infos)

lib/system.ml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ let skip_in_segment f ch =
264264
seek_in ch stop;
265265
stop, digest_in f ch
266266

267-
exception Bad_magic_number of string
267+
type magic_number_error = {filename: string; actual: int; expected: int}
268+
exception Bad_magic_number of magic_number_error
268269

269270
let raw_extern_state magic filename =
270271
let channel = open_trapping_failure filename in
@@ -274,8 +275,12 @@ let raw_extern_state magic filename =
274275
let raw_intern_state magic filename =
275276
try
276277
let channel = open_in_bin filename in
277-
if not (Int.equal (input_binary_int filename channel) magic) then
278-
raise (Bad_magic_number filename);
278+
let actual_magic = input_binary_int filename channel in
279+
if not (Int.equal actual_magic magic) then
280+
raise (Bad_magic_number {
281+
filename=filename;
282+
actual=actual_magic;
283+
expected=magic});
279284
channel
280285
with
281286
| End_of_file -> error_corrupted filename "premature end of file"
@@ -305,9 +310,11 @@ let intern_state magic filename =
305310

306311
let with_magic_number_check f a =
307312
try f a
308-
with Bad_magic_number fname ->
313+
with Bad_magic_number {filename=fname;actual=actual;expected=expected} ->
309314
errorlabstrm "with_magic_number_check"
310-
(str"File " ++ str fname ++ strbrk" has bad magic number." ++ spc () ++
315+
(str"File " ++ str fname ++ strbrk" has bad magic number " ++
316+
int actual ++ str" (expected " ++ int expected ++ str")." ++
317+
spc () ++
311318
strbrk "It is corrupted or was compiled with another version of Coq.")
312319

313320
(* Time stamps. *)

lib/system.mli

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ val file_exists_respecting_case : string -> string -> bool
6464
(** {6 I/O functions } *)
6565
(** Generic input and output functions, parameterized by a magic number
6666
and a suffix. The intern functions raise the exception [Bad_magic_number]
67-
when the check fails, with the full file name. *)
67+
when the check fails, with the full file name and expected/observed magic
68+
numbers. *)
6869

69-
exception Bad_magic_number of string
70+
type magic_number_error = {filename: string; actual: int; expected: int}
71+
exception Bad_magic_number of magic_number_error
7072

7173
val raw_extern_state : int -> string -> out_channel
7274

pretyping/cases.ml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,12 +1765,12 @@ let build_inversion_problem loc env sigma tms t =
17651765
Pushed (true,((tm,tmtyp),deps,na)))
17661766
dep_sign decls in
17671767
let subst = List.map (fun (na,t) -> (na,lift n t)) subst in
1768-
(* [eqn1] is the first clause of the auxiliary pattern-matching that
1768+
(* [main_eqn] is the main clause of the auxiliary pattern-matching that
17691769
serves as skeleton for the return type: [patl] is the
17701770
substructure of constructors extracted from the list of
17711771
constraints on the inductive types of the multiple terms matched
17721772
in the original pattern-matching problem Xi *)
1773-
let eqn1 =
1773+
let main_eqn =
17741774
{ patterns = patl;
17751775
alias_stack = [];
17761776
eqn_loc = Loc.ghost;
@@ -1781,19 +1781,24 @@ let build_inversion_problem loc env sigma tms t =
17811781
rhs_vars = List.map fst subst;
17821782
avoid_ids = avoid;
17831783
it = Some (lift n t) } } in
1784-
(* [eqn2] is the default clause of the auxiliary pattern-matching: it will
1785-
catch the clauses of the original pattern-matching problem Xi whose
1786-
type constraints are incompatible with the constraints on the
1784+
(* [catch_all] is a catch-all default clause of the auxiliary
1785+
pattern-matching, if needed: it will catch the clauses
1786+
of the original pattern-matching problem Xi whose type
1787+
constraints are incompatible with the constraints on the
17871788
inductive types of the multiple terms matched in Xi *)
1788-
let eqn2 =
1789-
{ patterns = List.map (fun _ -> PatVar (Loc.ghost,Anonymous)) patl;
1790-
alias_stack = [];
1791-
eqn_loc = Loc.ghost;
1792-
used = ref false;
1793-
rhs = { rhs_env = pb_env;
1794-
rhs_vars = [];
1795-
avoid_ids = avoid0;
1796-
it = None } } in
1789+
let catch_all_eqn =
1790+
if List.for_all (irrefutable env) patl then
1791+
(* No need for a catch all clause *)
1792+
[]
1793+
else
1794+
[ { patterns = List.map (fun _ -> PatVar (Loc.ghost,Anonymous)) patl;
1795+
alias_stack = [];
1796+
eqn_loc = Loc.ghost;
1797+
used = ref false;
1798+
rhs = { rhs_env = pb_env;
1799+
rhs_vars = [];
1800+
avoid_ids = avoid0;
1801+
it = None } } ] in
17971802
(* [pb] is the auxiliary pattern-matching serving as skeleton for the
17981803
return type of the original problem Xi *)
17991804
(* let sigma, s = Evd.new_sort_variable sigma in *)
@@ -1810,7 +1815,7 @@ let build_inversion_problem loc env sigma tms t =
18101815
pred = (*ty *) mkSort s;
18111816
tomatch = sub_tms;
18121817
history = start_history n;
1813-
mat = [eqn1;eqn2];
1818+
mat = main_eqn :: catch_all_eqn;
18141819
caseloc = loc;
18151820
casestyle = RegularStyle;
18161821
typing_function = build_tycon loc env pb_env s subst} in

0 commit comments

Comments
 (0)